Sunday, 13 July 2014

the select attribute in xsl:apply-templates



I am trying to get back into XSL/XSLT after many years and need some help to understand some XSL that I have received as an example. The TEI-based XML file that I would like to transform, has the following schematic structure:



<text>
<body>
<div>
<div type="text">
<ab>
<lg type="text-de">
<l>TEXT</l>
...
</lg>
</ab>
</div>
<div type="text">
<ab>
<lg type="text-en">
<l>TEXT</l>
...
</lg>
</ab>
</div>
</div>
</body>
</text>


I have a snippet of XSL that I would like to use to transform the above file. The XSL that I have looks like this:



<xsl:template match="tei:div">
SOME HTML CODE
<div class="text-de">
<xsl:apply-templates select="tei:lg[(@type='text-de')]"/>
</div>
<div class="text-en">
<xsl:apply-templates select="tei:lg[(@type='text-en')]"/>
</div>
</xsl:template>


I think the expected HTML output is clear, but please let me know if you need me to explain anything. What I am trying to achieve is that the two different blocks of text get inserted into two different elements in various places of the resulting HTML. However, when I run the above XSLT no block of text is selected. I would be grateful for any explanations that make me understand the nature of the select attribute in this example.


No comments:

Post a Comment