Re: AW: [xsl] Matching two consecutive <br><br>

Subject: Re: AW: [xsl] Matching two consecutive <br><br>
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 23 Aug 2004 11:29:27 +0100
> Could you be so kind and translate the predicates into plain english
> to help my understanding - I'm especially keen on knowing to which
> node "self" maps and in which order the predicates are mapped to the
> node sets? 

self:: is an axis that just contains the current node
so self::br matches the current node if it's a br and matches nothing
otherwise. so when used as a predicate it's the same as
name(.)='br'
except it's probably a bit more efficient and more importantly it's
"namespace safe", if you are using namespaces you can never be 100%
certain what string name() is going to return as a processor may think
up arbitrary prefixes on the fly so you may be expecting
name(.)='br' but actually teh processor returns a name(0 of _xx_654:br
(this can't happen for the no-namespace case as such elements can never
have a prefix)

predicates are always applied left-to-right
so
br[following-sibling::node()[1][self::br]]
matches all br's for which
following-sibling::node()[1][self::br]
is true
as that is a node set "true" here means non-empty
following-sibling::node()
selscts all following siblings (so this is empty if we are not the
youngest child)
[1]
selcts the first such node (if there is one) so again this is non empty
if we are not the youngest child.
[self::br]
selcts the one remaining node that got pas the [1] if that is a br.
so

following-sibling::node()[1][self::br]

is a node set of size 1 consisting of a br element if the node following
the current br is a br, and it's an empty node set otherwise.

David




________________________________________________________________________
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
________________________________________________________________________

Current Thread