[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Grouping

Subject: Re: Grouping
From: "Christoph Naber pentium120mhz@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 21 Oct 2020 18:07:11 -0000
Re:  Grouping
Thank you Martin!

This is the perfect solution for the overall stylesheet. Even if it's not as readable as the solution with a function, it requires no knowledge about the special grouping logic when applying templates somewhere in the rest of the stylesheet.

And it's _way_ more understandable than the stuff I came up with.

Wish you a good evening.

Best regards


Am 21.10.2020 um 18:38 schrieb Martin Honnen martin.honnen@xxxxxx:
Am 21.10.2020 um 17:57 schrieb Christoph Naber pentium120mhz@xxxxxxxxx:

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

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"
B B B B xmlns:xs="http://www.w3.org/2001/XMLSchema"
B B B B exclude-result-prefixes="#all"
B B B B version="3.0">

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

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

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

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

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


Current Thread


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