Is there a way to limit the XSLT section to a single node so that the entire node path is not needed every time?
For instance...
Name: <xsl:value-of select="/root/item[@attrib=1]/name"/>
Age: <xsl:value-of select="/root/item[@attrib=1]/age"/>
This can be done with each team, but I am convinced that they should be avoided, if at all possible ...
<xsl:for-each select="/root/item[@attrib=1]"/>
Name: <xsl:value-of select="name"/>
Age: <xsl:value-of select="age"/>
</xsl:for-each>
I think I'm asking if there is an XSLT equivalent of the VB.NET With command?
I would prefer to avoid xsl: template for readability, since the XSLT file in question is large, but would gladly accept if this is the only way to do this. And if so, what syntax calls a specific template based on a specific node?
Update
In response to the answer by @javram, individual patterns can be mapped based on specific attributes / nodes.
<xsl:apply-templates select="/root/item[@attrib=1]"/>
<xsl:apply-templates select="/root/item[@attrib=2]"/>
<xsl:template match="/root/item[@attrib=1]">
Name: <xsl:value-of select="name"/>
Age: <xsl:value-of select="age"/>
</xsl:template>
<xsl:template match="/root/item[@attrib=2]">
Foo: <xsl:value-of select="foo"/>
</xsl:template>
source
share