XSLT, process elements one by one
Posted
by qui
on Stack Overflow
See other posts from Stack Overflow
or by qui
Published on 2010-06-01T10:58:20Z
Indexed on
2010/06/01
11:03 UTC
Read the original article
Hit count: 150
xslt
Hi
I am quite weak at XSLT so this might seem obvious. Here is some sample XML
<term>
<name>cholecystocolonic fistula</name>
<definition>blah blah</definition>
<reference>cholecystocolostomy</reference>
</term>
And here is the XSLT I wrote a while ago to process it
<xsl:template name="term">
{
"dictitle": "<xsl:value-of select="name" disable-output-escaping="yes" />",
"html": "<xsl:value-of select="definition" disable-output-escaping="yes"/>",
"referece": "<xsl:value-of select="reference" disable-output-escaping="yes"/>
}
</xsl:template>
Basically I am creating JSON from the XML.
The requirements have now changed so that now the XML can have more than one definition tag and reference tag. They can appear in any order, i.e definition, reference, reference, definition, reference.
How can I update the XSLT to accommodate this? Probably worth mentioning that because my XSLT processor is using .NET I can only use XSLT 1.0 commands.
Many thanks!
© Stack Overflow or respective owner