Subject: Re: [xsl] exit <xsl:for-each> or change <xsl:variable> From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Thu, 28 Mar 2002 15:44:15 +0000 |
Hi Matts, > Is it possible to change the value of a <xsl:variable> tag to > something else than it is declared to? [snip] > Is it possibe to exit a <xsl:for-loop>. Like this: No. XSLT is a declarative language, not a procedural one, so it doesn't allow you to reassign values to variables or to break out of loops. It will probably help if you try to write the code in terms of what you want it to do rather than how you want to do it. In your first example, it looks as though you want to have something happen if the $var variable has the value 'true' or if the value attribute is not equal to 'new': <xsl:template match="root"> <xsl:if test="$var = 'true' and @value != 'new'"> <!-- do something --> </xsl:if> </xsl:template> Or perhaps you want the $var variable to have the value 'true' by default, but the value 'false' if the root element has a value attribute whose value is 'new': <xsl:variable name="var"> <xsl:choose> <xsl:when test="/root/@value = 'new'">false</xsl:when> <xsl:otherwise>true</xsl:otherwise> </xsl:choose> </xsl:variable> In your second example, it looks as though you only want to process the root element in a particular way if it has a value attribute equal to 'new'. You could use: <xsl:for-each select="root[@value = 'new']"> <!-- do something --> </xsl:for-each> Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] exit <xsl:for-each> or change, Matts Isuls | Thread | RE: [xsl] problem with transforming, Uslu, Cihan Y (MED) |
Re: [xsl] dynamically generate styl, Peter Davis | Date | [xsl] Looping and assigning into va, Venkateshwar Bommine |
Month |