This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]