xsl-list
[Top] [All Lists]

Re: [xsl] Best Way to Select Following Elements With An Ancestor?

2014-03-22 08:28:04
I was somehow unaware of the after (>>) operator. That does seem to
express exactly the test I need to make. (Note to self: find time to do a
careful reading of the XQuery and XPath 2.0 Functions and Operators spec.)

So I guess the question would be whether or not a particular XSLT
processor (e.g., Saxon in my case) would be more or less efficient using
the after operation or using keys?

Cheers,

Eliot
—————
Eliot Kimber, Owner
Contrext, LLC
http://contrext.com




On 3/22/14, 8:13 AM, "Andrew Welch" 
<andrew(_dot_)j(_dot_)welch(_at_)gmail(_dot_)com> wrote:

On 22 March 2014 12:46, Eliot Kimber <ekimber(_at_)contrext(_dot_)com> 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?

I don't know if it's more efficient or more elegant, but you could do:

$myDitaAncestor//* >> current()

Keying elements by their <dita> ancestor might help, eg

key name="elems-by-dita" match="*" use="generate-id(ancestor::dita)"

key('elems-by-dita', $dita-id) >> current()

where $dita-id is the generate-id() of the dita ancestor passed down
as a tunnelled param.

-- 
Andrew Welch
http://andrewjwelch.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--