I'm not sure if what I'm asking for is possible, but I need to first add two nodes into a parent XML node and then output the whole lot in xhtml using a different template. I don't know how to get the result of the transform in to the second template. I'm not entirely new to XSL but, I'm new to the Identity Transformations so this is likely above my pay grade.
Here's the example.
I have:
<metadata>
<app><name>a</name></app>
<app><name>b</name></app>
<app><name>c</name></app>
</metadata>
I need to insert 2 more <app> nodes into <metadata> and so far I've used:
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="metadata">
<xsl:copy-of select="."/>
<app><name>d</name></app>
<app><name>e</name></app>
</xsl:template>
Once the 2 new <app> nodes have been added, I need to output the newly transformed <metadata> as html using another template. I assume I can use:
<xsl:apply-templates select="app"><xsl:sort select="app/name" /></xsl:apply-templates>
<xsl:template match="app">
<h1><xsl:value-of select="name"/></h1>
...
</xsl:template>
...but I don't know where or how to correctly get the new <metadata> into the last template using the apply-templates. Thanks in advance for your help.
No comments:
Post a Comment