[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Ordered union of sequences

Subject: Re: Ordered union of sequences
From: "Imsieke, Gerrit, le-tex" <gerrit.imsieke@xxxxxxxxx>
Date: Thu, 08 Apr 2010 16:47:05 +0200
Re:  Ordered union of sequences
Given this input:

<?xml version="1.0" encoding="utf-8"?>

applying this XSLT:

<?xml version="1.0" encoding="utf-8"?>
  version="2.0"  >


<xsl:template match="/"> <xsl:apply-templates /> </xsl:template>

  <xsl:template match="foo">
      <xsl:for-each-group select="seq/*" group-by="name(.)" >
        <xsl:sort select="my:sortkey(.)"/>
        <xsl:element name="{current-grouping-key()}" />

<xsl:function name="my:sortkey" as="xs:integer?">
<xsl:param name="input" as="element(*)" />
<xsl:variable name="preceding-siblings" select="$input/../../seq/*[name() = name($input)]/preceding-sibling::*[1]" as="element(*)*" />
<xsl:sequence select="if ($preceding-siblings) then max(for $ps in $preceding-siblings return my:sortkey($ps)) + 1 else 1"/>


I receive:


Does that make sense?

If I include <o/> at the other position, i.e.,
I receive "Too many nested function calls. May be due to infinite recursion." as expected.


On 08.04.2010 16:38, Michael Kay wrote:
There is an arbitrary number of sequences, sometimes
containing items
with the same name:

(k, o, p, c, f)
(d, e, f, g)
(k, f, z, o)
(a, b, c, d)

I want to create a master sequence which contains every item once,
preserving the original order.

Doesn't xsl:for-each-group over combined sequence solves the problem?

No, it puts groups in order of first appearance, which would put f before d.


Michael Kay

-- Gerrit Imsieke Geschdftsf|hrer / Managing Director le-tex publishing services GmbH Weissenfelser Str. 84, 04229 Leipzig, Germany Phone +49 341 355356 110, Fax +49 341 355356 510 gerrit.imsieke@xxxxxxxxx, http://www.le-tex.de

Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930

Geschdftsf|hrer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard Vvckler

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.