xsl-list
[Top] [All Lists]

Re: [xsl] Grouping lists from flat to nested

2011-01-31 10:28:25
Stefanie Haupt wrote:

this looks great, thank you!  - the only downside is that the input to
this grouping attempt is a variable containing the input. So I fear I
can't use<template match="text">  here. I think I would need a new
transformation document in the pipeline with this attempt - which I
would love to avoid. - Or am I mistaken?

  <xsl:template match="test">
    <xsl:copy>
      <xsl:for-each-group select="*" group-adjacent="boolean(self::item)">
        <xsl:choose>
          <xsl:when test="current-grouping-key()">
            <xsl:sequence select="mf:group(current-group(), 0)"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:apply-templates select="current-group()"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:for-each-group>
    </xsl:copy>
  </xsl:template>

Instead of that template you could just apply the code to your variable e.g.

<xsl:for-each-group select="$variable/*" group-adjacent="boolean(self::item)">
        <xsl:choose>
          <xsl:when test="current-grouping-key()">
            <xsl:sequence select="mf:group(current-group(), 0)"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:apply-templates select="current-group()"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:for-each-group>


--

        Martin Honnen
        http://msmvps.com/blogs/martin_honnen/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>