xsl-list
[Top] [All Lists]

Re: Test expression : Is Context Node an ancestor of node with Id!

2005-02-19 00:33:40
Tempore 02:52:24, die 02/19/2005 AD, hinc in xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com scripsit Adam J Knight <adam(_at_)brightidea(_dot_)com(_dot_)au>:

     <xsl:choose>
        <xsl:when test="@id=$id | ancestor::tree_node[(_at_)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[(_at_)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)

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--