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

Re: Equivalence between XSL and XPath expression

Subject: Re: Equivalence between XSL and XPath expression
From: xptm <xptm@xxxxxxx>
Date: Sat, 11 Dec 2004 11:12:04 +0000
xptm
That was

<xsl:variable name="position">
   <xsl:number level='any' count="*"/>
</xsl:variable>

Sorry for the trafic...

xptm wrote:

So, in conclusion,

The equivalent on

<xsl:variable name="position">
    <xsl:number level='any' count="menu"/>
</xsl:variable>

is

count(./ancestor-or-self::*)+count(./preceding::*)



but the generalization to every node on a tree of my menu use

count(./ancestor-or-self::menu)+count(./preceding::menu)

is
count(./ancestor-or-self::node())+count(./preceding::node())


Ok, thanks peolple...






Dimtre Novatchev wrote:

On Sat, 11 Dec 2004 00:54:19 +0000, xptm <xptm@xxxxxxx> wrote:


So basically you're saying that the root element doesn't have the self::
axis, besides the obvious ancestor, parent and preceding. Is that so?


Any node, including "/" "has a self axis".

However, the expression you suggested:
         count(./ancestor-or-self::*)+count(./preceding::*)

evaluates to 0 in the case when the context node is the document node.

The reason?

The principal node kind for the self axis is the element-node kind.

Therefore,
      self::*

selects the context node only if the context node is an element. This
is not the case with the root (document) node.

Correct the above to:

self::node()

and it now selects the context node always, regardless of its node-kind.


Cheers, Dimitre.

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.