xsl-list
[Top] [All Lists]

Re: [xsl] Sort List of Maps By Key Value

2018-09-29 16:38:26
If you're in XSLT then you can also do

<xsl:for-each select="$maps">
  <xsl:sort select="?sortonme"/>
  <xsl:sequence select="func:operate-on-map(.)"/>
</xsl:for-each>

Michael Kay
Saxonica

On 29 Sep 2018, at 19:32, Martin Honnen martin(_dot_)honnen(_at_)gmx(_dot_)de 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

On 29.09.2018 20:23, Martin Honnen martin(_dot_)honnen(_at_)gmx(_dot_)de 
wrote:
On 29.09.2018 19:57, Eliot Kimber ekimber(_at_)contrext(_dot_)com wrote:
Using XPath 3 maps:

I have a list of maps where all the maps have a key on whose value I want 
to sort the list of maps.
A list? What does that mean in the XPath type system, a sequence of maps, 
i.e. map(*)*?
Can't you just use
  $maps => sort((), function($m) { $m?sortonme })
?

In Saxon with 
http://saxonica.com/html/documentation/extensions/syntax-extensions/simple-inline-functions.html
 (--allowSyntaxExtensions:on) you could shorten that to

  $maps => sort((), fn{?sortonme})


--~----------------------------------------------------------------
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>