[Top] [All Lists]

Re: [xsl] ordered selection of child elements

2018-03-08 00:54:11
Am 08.03.2018 um 07:36 schrieb Dr. Patrik Stellmann patrik(_dot_)stellmann(_at_)gdv-dl(_dot_)de:


a question more motivated by curiosity than by a real problem:


<xsl:sequence select=“a, b“/>

I will get first element a and second element b – no matter of the order within the input document.

But with

<xsl:sequence select=“root/(a, b)“/>

I will get the elements a and b in document order. So this behaves identical to

            <xsl:sequence select=“root/(a | b)“/>


Of course I could write

<xsl:sequence select=“root/a, root/b“/>

To ensure a specific order. But sometimes the expression of “root” is much more complex so I’d like to avoid writing it twice or putting it in a variable…

You can move to XPath/XSLT 3 and use the "!" operator

  root!(a, b)

XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
<Prev in Thread] Current Thread [Next in Thread>