xsl-list
[Top] [All Lists]

Re: [xsl] XSLT 1.0 - are parentless elements in a node-set siblings?

2007-12-10 09:31:16
An RTF is just a root node (and in most cases it typically has
children), according to the XSLT 1.0 Recommendation:


"A result tree fragment represents a fragment of the result tree. A
result tree fragment is treated equivalently to a node-set that
contains just a single root node"

http://www.w3.org/TR/xslt#section-Result-Tree-Fragments


Therefore, the Xalan implementation of EXSLT's common:node-set()  is
clearly in error (they provide the children of the root node, but
forgot to include the root node itself).

Dr. Kay and David Carlisle are right that the specification of EXSLT's
common:node-set()  is not too-detailed. However, it is quite clear
that this function takes an RTF and returns the node-set this RTF
represents. And the node-set, according to the very clear and precise
definition from the XSLT 1.0 Rec. (above), is the root node !





-- 
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play



On Dec 10, 2007 8:06 AM, Andrew Welch 
<andrew(_dot_)j(_dot_)welch(_at_)gmail(_dot_)com> wrote:
Given:

<foo>
 <baz>a</baz>
 <baz>b</baz>
 <baz>a</baz>
 <baz>b</baz>
</foo>

and a stylesheet that finds unique values using the preceding axis on
a node-set:

<xsl:stylesheet
   xmlns:exslt="http://exslt.org/common";
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">

   <xsl:variable name="baz-rtf">
       <xsl:copy-of select="//baz"/>
   </xsl:variable>

   <xsl:variable name="baz" select="exslt:node-set($baz-rtf)"/>

   <xsl:template match="/">
       <xsl:for-each select="$baz/baz[not(. = preceding::baz)]">
           <xsl:value-of select="."/>
       </xsl:for-each>
   </xsl:template>

</xsl:stylesheet>

Xalan produces:

"abab"

whilst Saxon 6.5.5 gives (the expected result):

"ab"

It seems to be because the elements copied to "baz-rtf" don't have a
common parent element, they aren't siblings in Xalan...

If I modify the rtf to have a common parent:

   <xsl:variable name="baz-rtf">
       <root>
           <xsl:copy-of select="//baz"/>
       </root>
   </xsl:variable>

then it generates the expected results using both Saxon and Xalan...

Which is correct in this case?

cheers
andrew

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



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