RE: returning single result from apply-templates

Subject: RE: returning single result from apply-templates
From: DPawson@xxxxxxxxxxx
Date: Tue, 10 Oct 2000 09:51:12 +0100
David Carlisle

> foo//bar[1]
>   All the bar which are the first child of any descendent of any foo
>   child of the current node. 
> 
> foo/descendant::bar[1]
>   All the bar which are the first descendant of any foo child of the
>   current node.
> 
> foo//bar
>   All the bar which are descendants of any foo child of the current
>   node.
> 
> (foo//bar)[1]
>   The first node in document order in the node set constructed above.
>   Note if there is more than one foo child this is the only one
>   guaranteed to select at most one node


Picks out a nodeset matching foo//bar, picks out the first of this nodeset?
So the ()[integer] construct guarantees a single node? 

Whereas foo//bar[1], given a number of matches, will return n nodes.



>    Just what do the () do here?
> 
> Make the [] apply to the whole node set constructed by foo//bar rather
> than just the last step in //bar[1].


Reasonable (if not DC accurate) view then would be

(1)   foo//bar[1] applies the whole path as many times as are found in the
src document

whereas

(2)	(foo//bar)[1] creates the nodeset in () first, then applies the
predicate?



Thanks David. Very clear.

Regards DaveP


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread