Re: [xsl] Re: Adjacent grouping?

Subject: Re: [xsl] Re: Adjacent grouping?
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 19 Nov 2017 14:00:39 -0000
On 19.11.2017 14:38, rus tle profrustyleafiii@xxxxxxxxxxx wrote:
Hi Michael,

I have actually hit a further snag with this solution.

It appears to work well when all the content nodes have the same parent node as in the original question. However, on coming to apply this solution to my real world scenario each content node is actually a child of itbs own p node. I have tried - but I cannot work out how to tweak your solution to adjust to this new revelation. Any thoughts?

The new xml:

 1. <pfrequency=b30">
 2. <Contentvalue="0b/>
 3. </p>
 4. <pfrequency=b30">
 5. <Contentvalue=b10b/>
 6. </p>

You could adjust the iteration and the value selection with e.g.


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:xs="http://www.w3.org/2001/XMLSchema";
xmlns:math="http://www.w3.org/2005/xpath-functions/math";
exclude-result-prefixes="xs math"
version="3.0">

<xsl:strip-space elements="*"/>
<xsl:output indent="yes"/>

<xsl:template match="root">
<xsl:copy>
<xsl:iterate select="p">
<xsl:param name="previous" as="xs:integer?" select="()"/>
<xsl:choose>
<xsl:when test="empty($previous) or xs:integer(Content/@value) gt $previous+30">
<xsl:copy-of select="."/>
<xsl:next-iteration>
<xsl:with-param name="previous" select="Content/@value"/>
</xsl:next-iteration>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:copy-of select="@*"/>
<Content value=""/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:iterate>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>


Current Thread