This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: expression comparing node and variable
- To: xsl-list at mulberrytech dot com
- Subject: Re: expression comparing node and variable
- From: Warren Hedley <w dot hedley at auckland dot ac dot nz>
- Date: Tue, 20 Jun 2000 17:43:07 -0400
- Organization: Department of Engineering Science, The University of Auckland
- References: <E1E01DE0B65CD311B70000A0C9DE5A95F4BABD@coopex.rim.net>
- Reply-To: xsl-list at mulberrytech dot com
Laura Price wrote:
>
> I'm probably overlooking something simple here... i hope.
The problem is that in your first test you are testing for
the value of section when you are already inside the section
element. You want to use '.'. Corrections and hints follow.
> I have this variable:
> <xsl:variable name="currentsection">other stuff</xsl:variable>
If you want to store a string in a variable, it's probably safer
to use (and quicker to parse) something like this
<xsl:variable name="currentsection" select="'other stuff'" />
Then use <xsl:otherwise> to avoid the second test. If you want
the <section> element in your output, use <xsl:copy-of> to
copy the selected node (in this case .) and all of its children.
> <xsl:for-each select="section">
> <xsl:choose>
> <xsl:when test=". = $currentsection">
> <highlight><xsl:copy-of select="."/></highlight>
> </xsl:when>
> <xsl:otherwise>
> <xsl:copy-of select="."/>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:for each
Hope this helps.
--
Warren Hedley
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list