- From: Michael Fuller <msf@io.mds.rmit.edu.au>
- Date: Sun, 6 Feb 2000 10:30:37 +1100
- To: www-xpath-comments@w3.org
- Cc: xsl-list@mulberrytech.com
The definition of nodeset equality, inequality, and relational operations in XPath seems more than a little unusual to me. For equality, XPath 3.4 says: "Comparison of the resulting objects is defined in the following three paragraphs. First, comparisons that involve node-sets are defined in terms of comparisons that do not involve node-sets; this is defined uniformly for =, !=, <=, <, >= and >. [...] If both objects to be compared are node-sets, then the comparison will be true if and only if there is a node in the first node-set and a node in the second node-set such that the result of performing the comparison on the string-values of the two nodes is true." Now, if I have interpreted those paragraphs correctly, that means given the nodesets NS1: {<a>-1</a>, <b>0</b>, <c>1</c>} and NS2: {<X>0</X>} that: NS1 = NS2 (the string value of the node <X>0</X> in the second set is equal to the string value of the node <b>0</b>) and: NS1 != NS2 (the string value of the node <X>0</X> in the second set is not equal to the string value of the node <a>-1</a>) and: NS1 < NS2 (the string value of the node <X>0</X> in the second set is > the string value of the node <a>-1</a>) and: NS1 > NS2 (the string value of the node <X>0</X> in the second set is < the string value of the node <c>1</c>) and: NS1 >= NS2 (the string value of the node <X>0</X> in the second set is >= the string value of the node <b>0</b>) and: NS1 <= NS2 (the string value of the node <X>0</X> in the second set is >= the string value of the node <b>1</b>) !! Testing with XT suggests this interpretation is right. Given the styleseheet: <?xml version="1.0" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text" /> <xsl:template match="doc"> <xsl:variable name="NS1" select="(a|b|c)" /> <xsl:variable name="NS2" select="X" /> "NS1 = NS2" <xsl:value-of select="$NS1 = $NS2" />. "NS1 != NS2" <xsl:value-of select="$NS1 != $NS2" />. "NS1 > NS2" <xsl:value-of select="$NS1 > $NS2" />. "NS1 < NS2" <xsl:value-of select="$NS1 < $NS2" />. "NS1 >= NS2" <xsl:value-of select="$NS1 <= $NS2" />. "NS1 <= NS2" <xsl:value-of select="$NS1 >= $NS2" />. </xsl:template> </xsl:stylesheet> and the document: <doc> <a>-1</a> <b>0</b> <c>1</c> <X>0</X> </doc> XT reports: "NS1 = NS2" true. "NS1 != NS2" true. "NS1 > NS2" true. "NS1 < NS2" true. "NS1 >= NS2" true. "NS1 <= NS2" true. So -- anyone care to: * enlighten me as to the correct interpretation of XPath 3.4 (which would indicate XT's behaviour is wrong... unlikely) or: * suggest a rationale for the strange-seeming definition of nodeset relationships? As it stands, the definition of nodeset relationships seems utterly internally consistent and... utterly useless? While I like the former characteristic :-), surely a definition such as: If both objects to be compared are node-sets, then the comparison will be true if and only if for each node in document order in the first node-set there is a corresponding node in the second node-set such that the result of performing the comparison on the string-values of the two nodes is true. would have been more intuitive, less expensive to evaluate, and (arguably) more useful? Other equally reasonable definitions are also seem possible, of course. Michael Fuller ____________________________________________ http://www.mds.rmit.edu.au/~msf/ Multimedia Databases Group, RMIT, Australia.
Received on Saturday, 5 February 2000 18:31:01 UTC