-
Notifications
You must be signed in to change notification settings - Fork 17
/
XML_text_nodes_to_solr.xslt
executable file
·28 lines (26 loc) · 1.16 KB
/
XML_text_nodes_to_solr.xslt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?xml version="1.0" encoding="UTF-8"?>
<!-- for all inline xml glob all the text nodes into one field-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:foxml='info:fedora/fedora-system:def/foxml#'>
<!-- have the template match whatever datastream needs this type of processing -->
<xsl:template match="foxml:datastream[@ID='HOCR']/foxml:datastreamVersion[last()]" name="index_text_nodes_as_a_text_field">
<xsl:param name="content"/>
<xsl:param name="prefix">text_nodes_</xsl:param>
<xsl:param name="suffix">_hlt</xsl:param>
<field>
<xsl:attribute name="name">
<xsl:value-of select="concat($prefix, ../@ID , $suffix)"/>
</xsl:attribute>
<xsl:apply-templates select="$content" mode="index_text_nodes_as_a_text_field"/>
</field>
</xsl:template>
<!-- Only output non-empty text nodes (followed by a single space) -->
<xsl:template match="text()" mode="index_text_nodes_as_a_text_field">
<xsl:variable name="text" select="normalize-space(.)"/>
<xsl:if test="$text">
<xsl:value-of select="$text"/>
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
</xsl:stylesheet>