rshk2001
asked on
XSL: Match ID and IDREFS
I have problem with resolving ID and IDREFS linking and below is my input as well as XSL and corresponding output
input XML doc:
<root>
<p>These afferent fibres project <link rid="r1">1</link> to the dorsal horn of the spinal cord where they synapse on neurons <link rid="r1">1</link> projecting to higher .... to the dorsal horn of the spinal cord where they synapse to the dorsal horn of the spinal cord <link rid="r2">2</link> where they synapse</p>
<ftn id="r1">First footnote</ftn>
<ftn id="r2">Second footnote</ftn>
</root>
current xsl:
<xsl:key name="key1" match="ftn" use="@id"/>
<xsl:template match="p">
<text:p><xsl:apply-templat es /></text:p>
</xsl:template>
<xsl:template match="link">
<xsl:apply-templates select="key('key1', @refid)"/>
</xsl:template>
<xsl:template match="ftn">
<text:footnote><xsl:apply- templates /></text:footnote>
</xsl:template>
When I use the above XSL syntax all of the links are turned into respective footnotes. But I do want only for the first instances when key pattern matches. ie for the second <link rid="r1">1</link>, I just need content of link.
I tried count the key as count(key('key1',@refid)) =1 do something and if its value is greater just copy the value of <link> but it is not working.
Pl shed your thoughts.
input XML doc:
<root>
<p>These afferent fibres project <link rid="r1">1</link> to the dorsal horn of the spinal cord where they synapse on neurons <link rid="r1">1</link> projecting to higher .... to the dorsal horn of the spinal cord where they synapse to the dorsal horn of the spinal cord <link rid="r2">2</link> where they synapse</p>
<ftn id="r1">First footnote</ftn>
<ftn id="r2">Second footnote</ftn>
</root>
current xsl:
<xsl:key name="key1" match="ftn" use="@id"/>
<xsl:template match="p">
<text:p><xsl:apply-templat
</xsl:template>
<xsl:template match="link">
<xsl:apply-templates select="key('key1', @refid)"/>
</xsl:template>
<xsl:template match="ftn">
<text:footnote><xsl:apply-
</xsl:template>
When I use the above XSL syntax all of the links are turned into respective footnotes. But I do want only for the first instances when key pattern matches. ie for the second <link rid="r1">1</link>, I just need content of link.
I tried count the key as count(key('key1',@refid)) =1 do something and if its value is greater just copy the value of <link> but it is not working.
Pl shed your thoughts.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.