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

RE: XSLT 1.0 - are parentless elements in a node-set

Subject: RE: XSLT 1.0 - are parentless elements in a node-set siblings?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 10 Dec 2007 16:21:27 -0000
RE:  XSLT 1.0 - are parentless elements in a node-set
exslt:node-set() isn't defined in the W3C standard so it's hard to argue
that any implementation of it is incorrect.

But I find it hard to imagine a coherent instance of the XPath 1.0 data
model in which there are four elements reachable by the expression "/*", and
yet none of those elements is reachable using the preceding axis from any
other.

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

> -----Original Message-----
> From: Andrew Welch [mailto:andrew.j.welch@xxxxxxxxx] 
> Sent: 10 December 2007 16:06
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  XSLT 1.0 - are parentless elements in a 
> node-set siblings?
> 
> 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

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.