xsl-list
[Top] [All Lists]

Re: [xsl] Grouping

2020-10-21 11:37:56
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.


Another approach not using grouping with for-each-group is trying to key
on the generated id of the first node in the group; usually that leads
to patterns that make my head spin but so did your original code:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
        xmlns:xs="http://www.w3.org/2001/XMLSchema";
        exclude-result-prefixes="#all"
        version="3.0">

  <xsl:key name="point-group"
           match="point[@type = 1 and
preceding-sibling::*[1][self::point[@type = 1]]]"
           use="generate-id(preceding-sibling::point[@type =
1][not(preceding-sibling::*[1][self::point[@type = 1]])][1])"/>

  <xsl:mode on-no-match="shallow-copy"/>

  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="point[@type =
1][not(preceding-sibling::*[1][self::point[@type = 1]])]">
      <group>
          <xsl:copy-of select="., key('point-group', generate-id())"/>
      </group>
  </xsl:template>

  <xsl:template match="point[@type = 1 and
preceding-sibling::*[1][self::point[@type = 1]]]"/>

</xsl:stylesheet>
--~----------------------------------------------------------------
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