| 1 |
<?xml version="1.0" encoding="UTF-8"?> |
|---|
| 2 |
<!-- $Id: demoFoxmlToLucene.xslt 5734 2006-11-28 11:20:15Z gertsp $ --> |
|---|
| 3 |
<xsl:stylesheet version="1.0" |
|---|
| 4 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|---|
| 5 |
xmlns:exts="xalan://dk.defxws.fedoragsearch.server.GenericOperationsImpl" |
|---|
| 6 |
exclude-result-prefixes="exts" |
|---|
| 7 |
xmlns:zs="http://www.loc.gov/zing/srw/" |
|---|
| 8 |
xmlns:foxml="info:fedora/fedora-system:def/foxml#" |
|---|
| 9 |
xmlns:dc="http://purl.org/dc/elements/1.1/" |
|---|
| 10 |
xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" |
|---|
| 11 |
xmlns:uvalibdesc="http://dl.lib.virginia.edu/bin/dtd/descmeta/descmeta.dtd" |
|---|
| 12 |
xmlns:uvalibadmin="http://dl.lib.virginia.edu/bin/admin/admin.dtd/" |
|---|
| 13 |
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" > |
|---|
| 14 |
<xsl:output method="xml" indent="yes" encoding="UTF-8"/> |
|---|
| 15 |
|
|---|
| 16 |
<!-- |
|---|
| 17 |
This xslt stylesheet generates the Solr doc element consisting of field elements |
|---|
| 18 |
from a FOXML record. The PID field is mandatory. |
|---|
| 19 |
Options for tailoring: |
|---|
| 20 |
- generation of fields from other XML metadata streams than DC |
|---|
| 21 |
- generation of fields from other datastream types than XML |
|---|
| 22 |
- from datastream by ID, text fetched, if mimetype can be handled |
|---|
| 23 |
currently the mimetypes text/plain, text/xml, text/html, application/pdf can be handled. |
|---|
| 24 |
--> |
|---|
| 25 |
|
|---|
| 26 |
<xsl:param name="REPOSITORYNAME" select="repositoryName"/> |
|---|
| 27 |
<xsl:param name="FEDORASOAP" select="repositoryName"/> |
|---|
| 28 |
<xsl:param name="FEDORAUSER" select="repositoryName"/> |
|---|
| 29 |
<xsl:param name="FEDORAPASS" select="repositoryName"/> |
|---|
| 30 |
<xsl:param name="TRUSTSTOREPATH" select="repositoryName"/> |
|---|
| 31 |
<xsl:param name="TRUSTSTOREPASS" select="repositoryName"/> |
|---|
| 32 |
<xsl:variable name="PID" select="/foxml:digitalObject/@PID"/> |
|---|
| 33 |
<xsl:variable name="docBoost" select="1.4*2.5"/> <!-- or any other calculation, default boost is 1.0 --> |
|---|
| 34 |
|
|---|
| 35 |
<xsl:template match="/"> |
|---|
| 36 |
<add> |
|---|
| 37 |
<doc> |
|---|
| 38 |
<xsl:attribute name="boost"> |
|---|
| 39 |
<xsl:value-of select="$docBoost"/> |
|---|
| 40 |
</xsl:attribute> |
|---|
| 41 |
<!-- The following allows only active demo FedoraObjects to be indexed. --> |
|---|
| 42 |
<xsl:if test="foxml:digitalObject/foxml:objectProperties/foxml:property[@NAME='http://www.w3.org/1999/02/22-rdf-syntax-ns#type' and @VALUE='FedoraObject']"> |
|---|
| 43 |
<xsl:apply-templates mode="activeDemoFedoraObject"/> |
|---|
| 44 |
</xsl:if> |
|---|
| 45 |
</doc> |
|---|
| 46 |
</add> |
|---|
| 47 |
</xsl:template> |
|---|
| 48 |
|
|---|
| 49 |
<xsl:template match="/foxml:digitalObject" mode="activeDemoFedoraObject"> |
|---|
| 50 |
<field name="PID" boost="2.5"> |
|---|
| 51 |
<xsl:value-of select="$PID"/> |
|---|
| 52 |
</field> |
|---|
| 53 |
<xsl:for-each select="foxml:objectProperties/foxml:property"> |
|---|
| 54 |
<field > |
|---|
| 55 |
<xsl:attribute name="name"> |
|---|
| 56 |
<xsl:value-of select="concat('fgs.', substring-after(@NAME,'#'))"/> |
|---|
| 57 |
</xsl:attribute> |
|---|
| 58 |
<xsl:value-of select="@VALUE"/> |
|---|
| 59 |
</field> |
|---|
| 60 |
</xsl:for-each> |
|---|
| 61 |
<xsl:for-each select="foxml:datastream/foxml:datastreamVersion[last()]/foxml:xmlContent/oai_dc:dc/*"> |
|---|
| 62 |
<field > |
|---|
| 63 |
<xsl:attribute name="name"> |
|---|
| 64 |
<xsl:value-of select="concat('dc.', substring-after(name(),':'))"/> |
|---|
| 65 |
</xsl:attribute> |
|---|
| 66 |
<xsl:value-of select="text()"/> |
|---|
| 67 |
</field> |
|---|
| 68 |
</xsl:for-each> |
|---|
| 69 |
|
|---|
| 70 |
<xsl:for-each select="foxml:datastream/foxml:datastreamVersion[last()]/foxml:xmlContent/dc:dc/*"> |
|---|
| 71 |
<field > |
|---|
| 72 |
<xsl:attribute name="name"> |
|---|
| 73 |
<xsl:value-of select="concat('dc.', substring-after(name(),':'))"/> |
|---|
| 74 |
</xsl:attribute> |
|---|
| 75 |
<xsl:value-of select="text()"/> |
|---|
| 76 |
</field> |
|---|
| 77 |
</xsl:for-each> |
|---|
| 78 |
|
|---|
| 79 |
<xsl:for-each select="foxml:datastream[@ID='RELS-EXT']/foxml:datastreamVersion[last()]/foxml:xmlContent/rdf:RDF/rdf:Description/*"> |
|---|
| 80 |
<field > |
|---|
| 81 |
<xsl:attribute name="name"> |
|---|
| 82 |
<xsl:value-of select="concat('rdf.', translate(name(), ':', '.'))"/> |
|---|
| 83 |
</xsl:attribute> |
|---|
| 84 |
<xsl:value-of select="substring-after(@rdf:resource, 'info:fedora/')"/> |
|---|
| 85 |
<xsl:value-of select="text()"/> |
|---|
| 86 |
</field> |
|---|
| 87 |
</xsl:for-each> |
|---|
| 88 |
|
|---|
| 89 |
<!-- a managed datastream is fetched, if its mimetype |
|---|
| 90 |
can be handled, the text becomes the value of the field. --> |
|---|
| 91 |
<xsl:for-each select="foxml:datastream[@CONTROL_GROUP='M']"> |
|---|
| 92 |
<field index="TOKENIZED" store="YES" termVector="NO"> |
|---|
| 93 |
<xsl:attribute name="name"> |
|---|
| 94 |
<xsl:value-of select="concat('dsm.', @ID)"/> |
|---|
| 95 |
</xsl:attribute> |
|---|
| 96 |
<xsl:value-of select="exts:getDatastreamText($PID, $REPOSITORYNAME, @ID, $FEDORASOAP, $FEDORAUSER, $FEDORAPASS, $TRUSTSTOREPATH, $TRUSTSTOREPASS)"/> |
|---|
| 97 |
</field> |
|---|
| 98 |
</xsl:for-each> |
|---|
| 99 |
|
|---|
| 100 |
</xsl:template> |
|---|
| 101 |
|
|---|
| 102 |
</xsl:stylesheet> |
|---|