1 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
2 <xsl:output omit-xml-declaration="yes" method="xml" encoding="UTF-8" media-type="text/plain" />
4 <xsl:template match="/">
6 <xsl:for-each select="//a[substring(@href,1,5)='#mrcb']">
7 <xsl:call-template name="field">
8 <xsl:with-param name="datafieldLabel" select="substring-after(@href,'#')"/>
14 <xsl:template name="field">
15 <xsl:param name="datafieldLabel"/>
16 <xsl:variable name="locatorAnchor" select="//a[@name=$datafieldLabel]"/>
18 <xsl:variable name="tagValue" select="substring-before($locatorAnchor, ' - ')"/>
19 <xsl:if test="$tagValue != ''">
21 <xsl:variable name="nameStart" select="substring-after($locatorAnchor, ' - ')"/>
23 <xsl:variable name="nameValue" select="substring-before($nameStart, '(')"/>
25 <xsl:variable name="repeatable" select="substring-after($nameStart, '(')"/>
26 <xsl:variable name="description" select="$locatorAnchor/parent::node()/following-sibling::node()/descendant-or-self::*"/>
29 <xsl:attribute name="tag">
30 <xsl:value-of select="$tagValue"/>
32 <xsl:attribute name="repeatable">
34 <xsl:when test="substring($repeatable,1,1)='R'">
35 <xsl:text>true</xsl:text>
38 <xsl:text>false</xsl:text>
44 <xsl:value-of select="normalize-space($nameValue)"/>
48 <xsl:value-of select="normalize-space($description)"/>
51 <xsl:call-template name="indicators">
52 <xsl:with-param name="indUL" select="$locatorAnchor/parent::node()/following-sibling::h3[.='Indicators'][1]/following-sibling::ul[1]"/>
55 <xsl:if test="substring($tagValue,1,2) != '00'">
56 <xsl:call-template name="subfields">
57 <xsl:with-param name="sfUL" select="$locatorAnchor/parent::node()/following-sibling::h3[.='Subfield Codes'][1]/following-sibling::ul[1]"/>
66 <xsl:template name="indicators">
67 <xsl:param name="indUL"/>
68 <xsl:for-each select="$indUL/li">
69 <xsl:if test="string-length(substring-after(.,' - Undefi')) = 0">
71 <xsl:variable name="indPos">
73 <xsl:when test="starts-with(.,'First')">
74 <xsl:text>1</xsl:text>
77 <xsl:text>2</xsl:text>
82 <xsl:for-each select="./ul/li">
84 <xsl:attribute name="position">
85 <xsl:value-of select="$indPos"/>
88 <xsl:attribute name="value">
89 <xsl:value-of select="substring-before(.,' - ')"/>
93 <xsl:value-of select="normalize-space(substring-after(.,' - '))"/>
101 <xsl:template name="subfields">
102 <xsl:param name="sfUL"/>
103 <xsl:for-each select="$sfUL/li">
104 <xsl:variable name="sfCode" select="substring-before(., ' - ')"/>
105 <xsl:variable name="descStart" select="substring-after(., ' - ')"/>
106 <xsl:variable name="descValue" select="substring-before($descStart, '(')"/>
107 <xsl:variable name="sfRepeatable" select="substring-after(., '(')"/>
110 <xsl:attribute name="code">
111 <xsl:value-of select="substring($sfCode,2,1)"/>
114 <xsl:attribute name="repeatable">
116 <xsl:when test="substring($sfRepeatable,1,1)='R'">
117 <xsl:text>true</xsl:text>
120 <xsl:text>false</xsl:text>
126 <xsl:value-of select="normalize-space($descValue)"/>