Hi all:
How would the conditional statement look like if I'm to insert a section of text into the xml below using xslt?
<items xmlns="http://mynamespace.com/definition">
<item>
<number id="1"/>
</item>
<item>
<number id="2"/>
</item>
<!-- insert the below text -->
<reference>
<refNo id="a"/>
<refNo id="b"/>
</reference>
<!-- end insert -->
</items>
This is how my xsl looks like at the moment (the condition is wrong...):
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://mynamespace.com/definition"
version="1.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:param name="addRef">
<reference>
<refNo id="a"/>
<refNo id="b"/>
</reference>
</xsl:param>
<xsl:template match="node()|@*" name="identity">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<!-- here is where the condition got stuck... -->
<xsl:template match="/items[namespace-url()=*]/item[position()=last()]">
<xsl:call-template name="identity"/>
<xsl:copy-of select="$addRef"/>
</xsl:template>
</xsl:stylesheet>
I wanted to add the reference section after the bottom-most , but I got stuck with how to get around matching an element that has a (explicit) namespace.
Thanks.