[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: returning single result from apply-templates
Subject: Re: returning single result from apply-templates From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 10 Oct 2000 10:49:06 GMT |
> So the ()[integer] construct guarantees a single node? [integer] construct always guarantees at most one node from th enode set to which the predicate is applied. so bar[1] gives you the first bar node from the nodes selected by child::bar (or th eempty node set if there are no such nodes). 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 Not really. > whereas > > (2) (foo//bar)[1] creates the nodeset in () first, then applies the > predicate? Yes. The xpath selection only happens once in each case. foo//bar[1] is short for child::foo/descendant-or-self::node()/child::bar[1] the scope of the [1] here is just the last step ie child::bar so you get the first bar child of every descendant of every foo child. (foo//bar)[1] is short for (...)[1] so you get the first node selected by whatever I should have filled in for .... You can of course mix and match ( (foo//xxx)[1] | (foo[4]//yyy[3])[2] ) [1] selects the first node in document order that is either the first xxx that is a descendant of fff or the second yyy that is a third yyy child of a descendant of the fourth foo So, the important thing to consider with [ predicates ] is which node set they apply to. In the abscence of () then this is normally just the last step ie the stuff after the last / but using () you can apply them to any node set. David XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: returning single result from ap, DPawson | Thread | accessing text node content(text) i, Sunil Mathew |
RE: returning single result from ap, DPawson | Date | accessing text node content(text) i, Sunil Mathew |
Month |
Keywords