|
Subject: Re: [xsl] Anyone can explain me this syntax? From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 13 Jan 2004 15:38:55 GMT |
this is explained in jeni's pages on grouping but basically
> Why the . (dot) is used?
. is the current node as always in xpath
> What's the meaning of the | (pipe)?
| is set union select="a|b" selects all nodes called a and all nodes
called b and returns the union of those sets (which means, it can
often be read as "or") select="a|b" selects all elements called a or
b.
> - What's the meaning of [1]?
if a predicate is numeric it is tests the value of position()
select="a[3]"
selects the third a child of the current node.
> I tried by using [2] and it worked too... or, perhaps I was lucky?
[2] wouldn't work in general, that would select the second item of each
group rather than the first, and in particular if a group only had one
item you would get nothing.
You want to test if the current node is the first item of the group
in XPath 2 draft that is
. is key('relacion_x_cobertura', REL_ID)[1]
but Xpath 1 does not have the "is" operator or any other direct way to
test node identity so you can use either one of two methods
testing generated ids:
generate-id(.) = generate-id(key('relacion_x_cobertura', REL_ID)[1])
this does a string equality test of the generated ids, which will be
equal only if they are the same node
or you can do the test you had
count(. | key('relacion_x_cobertura', REL_ID)[1]) = 1
. | key('relacion_x_cobertura', REL_ID)
is the union of the two nodes . and key('relacion_x_cobertura',
REL_ID)[1], so eiether these nodes are different and so this set has two
elements or they are the same in which case the set will have one
element (so count(....) =1.
(Note this test relies on the fact that in this context you know that
there is some element with key('relacion_x_cobertura', REL_ID) as
in general you need to check that the key('relacion_x_cobertura',
REL_ID) is non-empty, as if that is the empty set the union with . would
again only have one element in it.
David
--
http://www.dcarlisle.demon.co.uk/matthew
________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Anyone can explain me this sy, Jaime Stuardo | Thread | Re: [xsl] Anyone can explain me thi, Eliot Kimber |
| RE: [xsl] Anyone can explain me thi, Jarno . Elovirta | Date | Re: [xsl] Anyone can explain me thi, Eliot Kimber |
| Month |