Interpretation of the XPath Rec.

Subject: Interpretation of the XPath Rec.
From: Mike Olson <Mike.Olson@xxxxxxxxxxxxxxx>
Date: Sun, 05 Mar 2000 20:08:28 -0700
I have a qeustion about predicates and predicate lists.  We were going over an answer posted by Mike Kay a bit ago.  The example had input XML of:

<?xml version="1.0"?>
<elementList>
    <element>
        <x>
            <y>a</y>
        </x>
    </element>
    <element>
        <x>
            <y>z</y>
        </x>
    </element>
</elementList>

And a stylesheet of:

<xsl:variable name="pos">
   <xsl:for-each select="//element[descendant::y[.='z']][1]">
       <xsl:number/>
   <xsl:for-each>
</xsl:variable>
 

Thr question arose in 4XSLT when we tested this and got different results then expected.  After reading the spec we came to our question.

When filtering a node set with multiple predicates, does the context size and context  proximity position change after each predicate is tested, or are the size and position of the node set that results from the node test used?

In section 2.4, the spec gets really unclear with a lot of node-set and new node-set references.

It would seem from the above xslt and answer that size and position do change, as [1] would only evaluate to true for the second "element" if it was in the first position in the "new node-set".  If position does not change with each new predicate then the above xslt would not work because there is no "element" with a descendant of y equal to z that is the first "element" in the descendants.
 

Mike
 
 
 

-- 
Mike Olson
Senior Consultant Fourthought, Inc.
http://www.fourthought.com http://www.opentechnology.com
720-304-0152
 
Current Thread