[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: expression comparing node and variable

Subject: Re: expression comparing node and variable
From: Warren Hedley <w.hedley@xxxxxxxxxxxxxx>
Date: Tue, 20 Jun 2000 17:43:07 -0400
Re: expression comparing node and variable
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.