xsl-list
[Top] [All Lists]

Re: [xsl] Problem sorting incoming node list

2019-05-08 15:48:00
On 08.05.2019 19:18, Michael Kay mike(_at_)saxonica(_dot_)com wrote:
I haven't had a chance to study all of this, but please note that if you want 
to use the XPath 3.1 function then you should be using a more recent Saxon 
release than 9.3. The current version is 9.9. Also, only the 1-argument version 
of sort() will work in Saxon-HE; the more useful versions of the function (that 
allow a user-defined sort key) are higher order functions and therefore require 
Saxon-PE or Saxon-EE. The syntax would be

<xsl:for-each-group select=“sort(entry[location=$undulator], function($entry) 
{data($entry/(isodate,time))})" group-by="statistics_category">

To do it with HE you could implement a sort function with xsl:function
based on xsl:perform-sort e.g. declare some namespace for your function
xmlns:mf="http://example.com/mf"; and define

<xsl:function name="mf:sort-entries" as="element(entry)*">
  <xsl:param name="entries" as="element(entry)*"/>
  <xsl:perform-sort select="$entries">
    <xsl:sort select="isodate"/>
    <xsl:sort select="time"/>
  </xsl:perform-sort>
</xsl:function>

then you can use

  <xsl:for-each-group
select="mf:sort-entries(entry[location=$undulator])" group-by="..."
--~----------------------------------------------------------------
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>