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

Re: Best Way to Select Following Elements With An Anc

Subject: Re: Best Way to Select Following Elements With An Ancestor?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Sat, 22 Mar 2014 13:18:13 +0000
Re:  Best Way to Select Following Elements With An  Anc
On 22/03/2014 12:46, Eliot Kimber wrote

:
I have a document where each child of the root element establishes a
unique content with regard to the output result (in this case,
corresponding to InDesign frames).

For a given descendant of one of these elements I need to know if there
are any following elements within the same context. So simply doing
following::* won't work and the following elements I'm checking for need
not be siblings of the current element.

The solution I arrived at is:

<xsl:variable name="myDitaAncestor" select="ancestor::dita"
as="element()*"/>

     <xsl:variable name="followingWithinDita" as="element()*"
   select="following::*[count(ancestor::dita | $myDitaAncestor) = 1]"
     />

This works but I'm wondering if there's a better solution, either one that
is more efficient or one that is more elegant?





well if you know there's a dita acestor,


count(ancestor::dita | $myDitaAncestor) = 1

can be written

ancestor::dita is $myDitaAncestor


you could also do


following::* union $myDitaAncestor//*

but I'd guess that's less efficient.

Something tells me you should be using a key, but keying the dita elements on all its descendents sounds a bit expensive.

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.