xsl-list
[Top] [All Lists]

Re: [xsl] Grouping

2020-10-21 11:05:51
Am 21.10.2020 um 17:57 schrieb Christoph Naber 
pentium120mhz(_at_)gmail(_dot_)com:

The group-wrap should be performed for sequences of <points> of @type =
'1'. <Points> of other types and completeley other nodes should not be
grouped.

The "group-adjacent" solution seemes obvious but I have to account for
various parent elements that all have different templates. Wouldn't
using the group-adj. solution mean that I have to edit each and every
template that can possibly contain <points>?

I did not notice the requirement of different parent templates so I was
thinking in doing

  <xsl:template match="*[point/@type = 1]">
      <xsl:copy>
          <xsl:for-each-group select="*"
group-adjacent="boolean(self::point[@type = 1])">
              <xsl:choose>
                  <xsl:when test="current-grouping-key()">
                      <group>
                          <xsl:apply-templates select="current-group()"/>
                      </group>
                  </xsl:when>
                  <xsl:otherwise>
                      <xsl:apply-templates select="current-group()"/>
                  </xsl:otherwise>
              </xsl:choose>
          </xsl:for-each-group>
      </xsl:copy>
  </xsl:template>


It is certainly possible to put the grouping code into a function to use
it in different templates, hard to tell whether that will work with the
various parent elements having different templates without seeing how
these templates look.

--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>
  • [xsl] Grouping, Christoph Naber pentium120mhz(_at_)gmail(_dot_)com
    • Re: [xsl] Grouping, Martin Honnen martin(_dot_)honnen(_at_)gmx(_dot_)de
      • Re: [xsl] Grouping, Christoph Naber pentium120mhz(_at_)gmail(_dot_)com
        • Re: [xsl] Grouping, Martin Honnen martin(_dot_)honnen(_at_)gmx(_dot_)de <=
        • Re: [xsl] Grouping, Martin Honnen martin(_dot_)honnen(_at_)gmx(_dot_)de
        • Re: [xsl] Grouping, Christoph Naber pentium120mhz(_at_)gmail(_dot_)com