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

Re: Test expression : Is Context Node an ancestor of n

Subject: Re: Test expression : Is Context Node an ancestor of node with Id!
From: "Joris Gillis" <roac@xxxxxxxxxx>
Date: Sat, 19 Feb 2005 08:33:40 +0100
xsl test expression
Tempore 02:52:24, die 02/19/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Adam J Knight <adam@xxxxxxxxxxxxxxxxx>:

     <xsl:choose>
        <xsl:when test="@id=$id | ancestor::tree_node[@id=$id]">
        </xsl:when>
        <xsl:otherwise>
        </xsl:otherwise>
  </xsl:choose>

Hi,


1)The union operater '|' works only for node-sets, not boolean value. Use 'or' here.
2)'ancestor' should become 'descendant'


Suppose you have this:
<xsl:template select="foo">
<xsl:if test="ancestor::bar">
Hooray
</xsl:if>
</xsl:template>
The 'xsl:if' will *not* test that the context node ('foo') is an ancestor of 'bar'.
The oppposite is true:
It will test wether 'foo' has an ancestor named 'bar'.


This is because 'ancestor' is an axis (containing all ancestors of the context node), not a boolean test or something alike.

I do hope this clears it a bit. If you did not understand at first reading, I advise you to read this again.


I want to use a test expression to test whether the node currently matched
(context node?)
correct
is an ancestor of a node with a specified id.


  <xsl:choose>
        <xsl:when test="descendant-or-self::tree_node[@id=$id]">
        </xsl:when>
        <xsl:otherwise>
        </xsl:otherwise>
  </xsl:choose>

regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
Veni, vidi, wiki (http://www.wikipedia.org)

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.