xsl:template node selection question
This is an open discussion with 4 replies, filed under XSLT.
Search
Can you post some more of your XSLT, and your Data Source XML? At the moment your two templates are mutually exclusive: the first template calls a named template called new-template
rather than an apply-templates selecting node1/node2
.
I think you were trying to do this:
<xsl:template match="data"> <xsl:apply-templates select="node1/node2"/> </xsl:template> <xsl:template match="node2"> <h1><xsl:value-of select="."/></h1> </xsl:template>
Although you might have to switch the arguments of select
and match
… I am not sure.
Thanks phoque that did the trick.
Glad I could help.
Basically, apply-templates
executes a certain template (the one with the correct match
) for every element you’re selecting. call-template
executes a template (the one with the correct name
) only once.
You can find more on apply-templates
in one of Allens screencasts.
Create an account or sign in to comment.
I am running into an issue with a second template that is called with in the first not selecting a node the way it seems it should.
Instead of of returning
node2
it returnsdate
. When I call it within axsl:for-each
it does matches the node level of the for-each. Can someone enlighten me on what I am doing wrong, or what I am misunderstanding? Thanks!