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

Re: Sorting a sequence and selecting the first element

Subject: Re: Sorting a sequence and selecting the first element after sort
From: "Imsieke, Gerrit, le-tex gerrit.imsieke@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 8 May 2015 12:06:22 -0000
Re:  Sorting a sequence and selecting the first element
You could also use the union operator, or its short form |, as in
(foo | *[descendant::foo | descendant::bar])[1]

In contrast to the sequence operator (the comma), it will eliminate
duplicates and return its results in document order.

Gerrit

On 08.05.2015 13:57, Jorge . chocolate.camera@xxxxxxxxx wrote:
> I answer both questions to myself:
> 
>     <xsl:sequence="*[local-name() eq 'foo' or descendant::foo or
> descendant::bar][1]"/>
> 
> (unless I got something wrong again).
> 
> Please, excuse me for the noise.
> 
> On Fri, May 8, 2015 at 1:50 PM, Jorge . chocolate.camera@xxxxxxxxx
> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>> I now see that, on top of that, I am adding duplicate copies of nodes
>> that match both conditions to the sequence (-_-;). I would also
>> appreciate a hint on how to make that selection without dupes.
>>
>> On Fri, May 8, 2015 at 1:44 PM, Jorge . chocolate.camera@xxxxxxxxx
>> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>>> I'd like to select the first child of the current node that either:
>>>
>>> 1.    is a "foo" element
>>> 2.    has "foo" or "bar" descendant(s)
>>>
>>> The following sequence returns me all nodes matching either or both of
>>> those conditions:
>>>
>>>     <xsl:sequence select="foo, *[descendant::foo, descendant::bar]"/>
>>>
>>> but not necessarily ordered according to their position as children of
>>> the current node. As a result, the first element in that sequence,
>>> selected like this:
>>>
>>>     <xsl:sequence select="(foo, *[descendant::foo, descendant::bar])[1]"/>
>>>
>>> is not necessarily the first matching child of the current node.
>>>
>>> How do I sort elements in that sequence according to their position as
>>> children of the current context, so that the first element in that
>>> sequence is actually the first matching child in the current node?
>>>
>>
> 
> 

-- 
Gerrit Imsieke
GeschC$ftsfC<hrer / Managing Director
le-tex publishing services GmbH
Weissenfelser Str. 84, 04229 Leipzig, Germany
Phone +49 341 355356 110, Fax +49 341 355356 510
gerrit.imsieke@xxxxxxxxx, http://www.le-tex.de

Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930

GeschC$ftsfC<hrer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard VC6ckler

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.