[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Union of XPath sequences and the meaning of the u
Hi Kenneth, > The union operator in XPath 2.0 is described as eliminating > duplicates from the two sequences that it is combining. What is the > criterion used for determining if two nodes in the resulting > sequence are unique? Duplicates are removed based on node identity. When you set a variable using the content of <xsl:variable>, and don't use an 'as' attribute, as in: <xsl:variable name="a"> <xsl:sequence select="2" /> </xsl:variable> the XSLT processor automatically creates a document node and adds the result of the sequence constructor inside the <xsl:variable> element to that document node. When you add an atomic value to a document node, the atomic value is converted to a text node and that text node is added. So, in your code, the variable $a is set to a document node with a single text node child whose string value is "2". Similarly, $b is set to a *different* document node with a single text node child whose string value is "2". These are different document nodes, so "$a | $b" is a sequence of two document nodes. But "$a | $a" results in a sequence containing the single document node held by the variable $a. If you want the variable $a to hold the atomic value "2", then you should either use the select attribute on <xsl:variable>, as in: <xsl:variable name="a" select="2" /> or use the 'as' attribute to say that the variable should hold an integer, as in: <xsl:variable name="a" as="xs:integer"> <xsl:sequence select="2" /> </xsl:variable> If you do this, then you will find that the expressions "$a | $a" and "$a | $b" will give you an error, since the union operator can only operate over sequences of nodes. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|