RE: [xsl] XSLT grouping without Muenchen Method

Subject: RE: [xsl] XSLT grouping without Muenchen Method
From: "Kienle, Steven C" <steven.c.kienle@xxxxxxxxxx>
Date: Tue, 31 Aug 2004 08:27:25 -0400

You can combine Anton's method into one transform.  With some rewriting, you
can put his Pass1 transform into a variable, then actually use that variable
in the Pass2 transform rather than an input file.  I've done this below:

<xsl:stylesheet version="1.0"
  <xsl:output method="text"/>

  <xsl:variable name="pass1">
    <xsl:for-each select="/root/object">
      <object name="{@name}"
        instance="{concat('Instance', instance/@number)}">
        <xsl:attribute name="interval">
            select="substring-before(instance/sample/@date_time, ':')"/>
          <xsl:call-template name="calculate-interval">
            <xsl:with-param name="time"
              select="substring-after(instance/sample/@date_time, ':')"/>

  <xsl:template name="calculate-interval">
    <xsl:param name="time"/>
    <xsl:variable name="hour"
      select="number(substring-before($time, ':'))"/>
      <xsl:when test="$hour &lt; 15">:00:00</xsl:when>
      <xsl:when test="$hour &lt; 30">:15:00</xsl:when>
      <xsl:when test="$hour &lt; 45">:30:00</xsl:when>

  <xsl:template match="/">
    <xsl:apply-templates select="$pass1/object">
      <xsl:sort select="@interval"/>
      <xsl:sort select="@instance"/>

  <xsl:template match="object">
    <xsl:variable name="interval" select="@interval"/>
    <xsl:variable name="instance" select="@instance"/>
      test="not(preceding-sibling::object[@interval=$interval and
      <!-- first of group -->
        select="self::object | following-sibling::object[@interval=$interval
and @instance=$instance]"
      <xsl:value-of select="@instance"/>
      <xsl:value-of select="@interval"/>

  <xsl:template match="object" mode="write">
    <xsl:variable name="interval" select="@interval"/>
    <xsl:variable name="instance" select="@instance"/>
    <xsl:value-of select="@name"/>
        test="following-sibling::object[@interval=$interval and


This works for me using Saxon 7.8, but I don't think I'm using anything
beyond what XT can do.  If this does work in XT, I'm out of ideas.


-----Original Message-----
From: Ismael Cams [mailto:xslt@xxxxxxxxxxx]
Sent: Tuesday, August 31, 2004 1:55 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] XSLT grouping without Muenchen Method

On Mon, 30 Aug 2004 20:47:46 +0200
  "cking" <cking@xxxxxxxxxx> wrote:

Hello Anton,

thanks for the provided solution. Unfortunately I can not use a two step
solution, as I can only integrate one stylesheet into the application. XTh
 as a node-set function and this can indeed used as a solution for my
problem. Normally I try to avoid to use extension functions as I want to
have my stylesheets processor independent, but in this case I do not see any

other solution to solve it.

Unless expressly stated otherwise, this message is confidential and may be
privileged. It is intended for the addressee(s) only. Access to this E-mail by
anyone else is unauthorized. If you are not an addressee, any disclosure or
copying of the contents of this E-mail or any action taken (or not taken) in
reliance on it is unauthorized and may be unlawful. If you are not an
addressee, please inform the sender immediately.

Current Thread