xsl-list
[Top] [All Lists]

[xsl] Sorting a sequence and selecting the first element after sort

2015-05-08 06:44:30
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?
--~----------------------------------------------------------------
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>