Re: [xsl] Equivalence between XSL and XPath expression

Subject: Re: [xsl] Equivalence between XSL and XPath expression
From: xptm <xptm@xxxxxxx>
Date: Fri, 10 Dec 2004 23:59:01 +0000
How can the XPath return 0, if has a context node (.) and has the self axis in ancestor-or-self? This way it has to return at least 1!


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/

Current Thread