Re: [xsl] Techniques for Sorting and Reducing Maps in XSLT 3/XPath 3?

Subject: Re: [xsl] Techniques for Sorting and Reducing Maps in XSLT 3/XPath 3?
From: "David Carlisle d.p.carlisle@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 5 Jul 2018 21:33:55 -0000
here's a map free  xslt 2 version for comparison


$ saxon9 -it:main zz.xsl
### C
processing  file:/C:/tmp/ek1/A/B/C/en/1.2/foo.xml
processing  file:/C:/tmp/ek1/A/B/C/fr/1.3/foo.xml
### D
processing  file:/C:/tmp/ek1/A/B/D/en/1.4/foo.xml
processing  file:/C:/tmp/ek1/A/B/D/fr/1.3/foo.xml




<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>


 <xsl:template name="main">
  <xsl:for-each-group select="collection('./A?select=foo.xml;recurse=yes')"
              group-by="replace(base-uri(.),'.*/A/B/([A-Z]+)/.*','$1')">
   <xsl:sort select="base-uri(.)"/>
   <xsl:message select="'###',current-grouping-key()"/>
   <xsl:for-each-group select="current-group()"
               group-by="replace(base-uri(.),'.*/A/B/[A-Z]+/([a-z]+)/.*','$1')">
    <xsl:apply-templates select="current-group()[last()]"/>
   </xsl:for-each-group>
  </xsl:for-each-group>
 </xsl:template>

 <xsl:template match="/">
  <xsl:message select="'processing ', base-uri()"/>
 </xsl:template>

</xsl:stylesheet>

Current Thread