Subject: Re: [xsl] Can templates be invoked based on the value of a variable? From: Michael Ludwig <milu71@xxxxxx> Date: Wed, 1 Apr 2009 22:22:43 +0200 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Can templates be invoked , Michael Ludwig | Thread | RE: [xsl] Can templates be invoked , Xia Li |
Re: [xsl] Can templates be invoked , Michael Müller-Hille | Date | RE: [xsl] Can templates be invoked , Xia Li |
Month |