xsl-list
[Top] [All Lists]

Re: Equivalence between XSL and XPath expression

2004-12-11 14:24:52
Err, correct me if I am wrong, but doesn't the 'preceding' axis include the 
ancestors as well?

I would have guessed that the 'equivalent' would have been:
    count(self::menu)+count(preceding::menu)

(apart from the zero-count case mentioned below)

Cheers,
Geert

Michael Kay wrote:

And the question is: Is this XPath expression

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

equivalent to this XSL expression?

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


Almost. xsl:number will never return 0, but the XPath expression might. Take
a look at the XSLT 2.0 spec which defines xsl:number in terms of equivalent
XPath expressions.

Michael Kay
http://www.saxonica.com/


--~------------------------------------------------------------------
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>
--~--




--
Geert(_dot_)Josten(_at_)Daidalos(_dot_)nl
IT-consultant at Daidalos BV, Zoetermeer (NL)

http://www.daidalos.nl/
tel:+31-(0)79-3316961
fax:+31-(0)79-3316464

GPG: 1024D/12DEBB50


--~------------------------------------------------------------------
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>
--~--