[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 18:22:20 +0200
Re:  Ordered union of sequences
Still found the time to correct a typo and to remove the redundant distinct-values():

  <xsl:function name="my:sortkey" as="xs:integer">
    <xsl:param name="input" as="element(*)" />
    <xsl:param name="seen" as="xs:string*" />
    <xsl:if test="name($input) = $seen">
      <xsl:message terminate="yes">Element
        <xsl:value-of select="name($input)"/>
        doesn't seem to occur at a deterministic
        position.
      </xsl:message>
    </xsl:if>
    <xsl:variable
      name="preceding-siblings"
      select="$input/../../seq/*[
                name() = name($input)
              ]/preceding-sibling::*[1]"
      as="element(*)*" />
    <xsl:variable name="seen" select="($seen, name($input))" />
    <xsl:sequence select="(
                            max(
                              for $ps in $preceding-siblings
                                return my:sortkey($ps, $seen)
                            ) + 1,
                            1
                          )[1]"/>
	<!-- short form of if(not(empty($preceding-siblings))) -->
  </xsl:function>



On 08.04.2010 18:07, Imsieke, Gerrit, le-tex wrote:
<xsl:function name="my:sortkey" as="xs:integer">
<xsl:param name="input" as="element(*)" />
<xsl:param name="previously-seen" as="xs:string*" />
<xsl:if test="name($input) = $previously-seen">
<xsl:message terminate="yes">Element <xsl:value-of
select="name($input)"/> doesn't seem to occur at an deterministic position.
</xsl:message>
</xsl:if>
<xsl:variable name="preceding-siblings"
select="$input/../../seq/*[name() =
name($input)]/preceding-sibling::*[1]" as="element(*)*" />
<xsl:variable name="seen" select="distinct-values(($previously-seen,
name($input)))" />
<xsl:sequence select="(max(for $ps in $preceding-siblings return
my:sortkey($ps, $seen)) + 1, 1)[1]"/>
</xsl:function>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.