[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Pattern notation for preceding-sibling

Subject: Re: Pattern notation for preceding-sibling
From: "Abel Braaksma (Exselt) abel@xxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 12 Aug 2014 16:09:44 -0000
Re:  Pattern notation for preceding-sibling
Note that your subjectline suggests patterns, but your question is about
expressions. Patterns (as in <xsl:template match="X">) cannot use the
preceding-sibling axis, unless inside a predicate.


> From: Heiko Niemann kontakt@xxxxxxxxxxxxxxxx [mailto:xsl-list-
> Sent: Monday, August 11, 2014 11:50 AM
>
>
> /foo/E/preceding-sibling::(A,N)

Indeed, this is currently disallowed syntax.

>
> But it does not, so I either have to write
>
> /foo/E/(preceding-sibling::A, preceding-sibling::N) or
>
> /foo/E/*[name() = ('A','N')]
>

These two are not the same, the latter takes the children of E, not the
preceding siblings.

You can also do:
/foo/E/preceding-sibling::*[self::A | self::N]

Or, if you have a sequence of names, you can use:
/foo/E/preceding-sibling::*[name() = $names]

Or you can revert the test and use following-sibling in a predicate
(potentially shortest):
/foo/(A, N)[following-sibling::E]

The only reason that expressions such as (A, N) are shorter, is that they are
implicitly using the child axis. You are actually writing (child:A, child:N).
The axis specification is required, which is why, if you are not processing
the default child axis, expressions can quickly get verbose, because the axis
has to be specified for each node test.

Note that if you have multiple sibling E elements, the result may not be what
you expect, you will return overlapping elements.

Cheers,

Abel Braaksma
Exselt streaming XSLT 3.0 processor
http://exselt.net

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.