Subject: Re: [xsl] Axis order and variables From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Fri, 23 May 2003 09:47:24 -0400 |
Consider the following XML
<x n="1"> <x n="2"> <test/> </x> </x>
and transform it via the following XSLT:
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template match="/"> <xsl:for-each select="//test"> <xsl:variable name="x" select="ancestor::x"/> <xsl:value-of select="$x[1]/@n"/> </xsl:for-each> </xsl:template>
</xsl:transform>
What is the expected result? Is it "1" or "2"?
If this is all what we have then the result of the above test should be "1", since the value of a variable is an object rather than an expression and thus is an (unordered) node-set.
Therefore, its members, when forced to be ordered, should be ordered in document order.
Is it a definite answer?
Does it depend on a realization?
I have run into this question because the result of MSXML 3.0 and Saxon differs from that of MSXML 4.0: the former give "1", while the latter gives "2". Who is right? Or they are both right?
-- Upcoming hands-on courses: (registration still open!) - (XSLT/XPath and/or XSL-FO) North America: June 16-20, 2003
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) ISBN 0-13-065196-6 Definitive XSLT and XPath ISBN 0-13-140374-5 Definitive XSL-FO ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath ISBN 1-894049-11-X Practical Formatting Using XSL-FO Member of the XML Guild of Practitioners: http://XMLGuild.info Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Axis order and variables, David Carlisle | Thread | Re: [xsl] Axis order and variables, Jeni Tennison |
RE: [xsl] Axis order and variables, David Neary | Date | Re: [xsl] Axis order and variables, David Carlisle |
Month |