Subject: Re: [xsl] Fetch a sequence of nodes from input file From: Michael Ludwig <mlu@xxxxxxxxxxxxx> Date: Thu, 24 Sep 2009 12:15:28 +0200 |
$a << $b is true when the singleton node in the variable "a" is before the singleton node "b" in document order in the same tree.
$a >> $b is true when $a is after $b in document order in the same tree.
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.
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.
A recoverable error would be similar in nature to leaving the return value up to the implementation.
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Fetch a sequence of nodes, G. Ken Holman | Thread | Re: [xsl] Fetch a sequence of nodes, David Carlisle |
Re: [xsl] Fetch a sequence of nodes, G. Ken Holman | Date | Re: [xsl] Fetch a sequence of nodes, David Carlisle |
Month |