|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Can templates be invoked based on the value of a
pilgrim cnonline.net schrieb am 01.04.2009 um 14:52:01 (-0500):
> I would like to be able to invoke templates based on the value of a
> variable.
> My data has the structure:
>
> <data>
> <item1>
> ...
> </item1>
> <item2>
> ....
> </item2>
> </data>
>
> I want to process the nodes <item1/> or <item2/>, but not both,
> depending on a variable derived from some other processing.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="data">
<xsl:variable name="i" select="2"/>
<xsl:variable name="item" select="concat( 'item', $i)"/>
<xsl:apply-templates select="*[ local-name() = $item ]"/>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
But I think there is nothing wrong with using <xsl:choose> here.
Michael Ludwig
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








