[Home] [By Thread] [By Date] [Recent Entries]
G. Ken Holman schrieb:
Now I said "in the same tree", but it works it just is implementation dependent when comparing nodes from one tree to another tree. One processor will have it one way and another processor will have it in another order. So you will get true/false when comparing document order between nodes from different trees, but not necessarily the same answer when using two different processors on the same tree. http://www.w3.org/TR/xpath20/#id-node-comparisons The spec does not seem to be talking about nodes from different documents. Is this a deliberate omission? What's the rationale behind admitting either of true and false as return values for this case? It seems to me that NULL (as in SQL) is most appropriate here. But that's not boolean logic any more, so it would have complicated things. In theory, an IllegalCrossTreeNodeComparisonException would also be conceivable. But I wouldn't want to have to do exception handling in XSLT because it complicates things. An unrecoverable error would be pretty drastic. A recoverable error would be similar in nature to leaving the return value up to the implementation. So maybe this is the best decision that could have been made? The user can always use the root() function to check if both nodes really originate in the same document. <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:variable name="t1"><Urmel/></xsl:variable> <xsl:variable name="t2"><Urmel/></xsl:variable> <xsl:template xml:space="preserve" match="/"> <xsl:value-of select="generate-id( /*)"/> <xsl:value-of select="generate-id($t1/*)"/> <xsl:value-of select="generate-id($t2/*)"/> <xsl:value-of select="$t1/* >> $t2/*"/> <xsl:value-of select="$t1/* << $t2/*"/> <xsl:value-of select="root($t1/*) is root($t2/*)"/> </xsl:template> </xsl:stylesheet> -- Michael Ludwig
|

Cart



