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

Re: Process the following group

Subject: Re: Process the following group
From: "Wendell Piez wapiez@xxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 7 Jul 2022 19:22:01 -0000
Re:  Process the following group
Hey Rick,

I think this is much easier if instead of conceiving of grouping by div
level, then subgrouping, you go straight to the groups including their
subgroups.

This suggests to me not a group-adjacent but a group-starting-with pattern
in your for-each-group

<xsl:for-each-group group-starting-with="h1">
  current group is every h1 followed by everything up to the next h1
</xsl:for-each>

Or is there something I am missing?

Also - in your case, local-name(current-group()[1]) is the same as
current-grouping-key() is it not?

Good luck, Wendell


On Thu, Jul 7, 2022 at 3:10 PM rick@xxxxxxxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> Hi All,
>
>
>
> I have something like this:
>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <root>
>
>     <div1/>
>
>     <div1/>
>
>     <div2/>
>
>     <div2/>
>
>     <div1/>
>
> </root>
>
>
>
> And I want to end up with this:
>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <root>
>
>     <div1/>
>
>     <div1>
>
>         <div2/>
>
>         <div2/>
>
>     </div1>
>
>     <div1/>
>
> </root>
>
>
>
> Here is my stylesheet. When I am the last in the <div1> group, I want to
> process the following <div2> group, if there is one.
>
>
>
> <?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"
>
>     xmlns:math="http://www.w3.org/2005/xpath-functions/math"
>
>     exclude-result-prefixes="xs math"
>
>     version="3.0" expand-text="yes">
>
>
>
>     <xsl:output indent="yes"/>
>
>
>
>     <xsl:template match="/root">
>
>         <root>
>
>             <xsl:for-each-group select="*" group-adjacent="local-name()">
>
>                 <xsl:choose>
>
>                     <xsl:when test="local-name(current-group()[1])='div1'">
>
>                         <xsl:apply-templates select="current-group()"/>
>
>                     </xsl:when>
>
>                 </xsl:choose>
>
>             </xsl:for-each-group>
>
>         </root>
>
>     </xsl:template>
>
>
>
>     <xsl:template match="div1">
>
>         <div1>
>
>             <!-- Am I the last in the group? -->
>
>             <xsl:if test="position()=last()">
>
>                 <xsl:comment>I want process the entire following div2
> group in here.</xsl:comment>
>
>             </xsl:if>
>
>         </div1>
>
>     </xsl:template>
>
>
>
> </xsl:stylesheet>
>
>
>
> Thanks for any pointers you can provide.
>
>
>
> Rick
>
>
>
> Rick Quatro
>
> Carmen Publishing Inc.
>
> 585-729-6746
>
> rick@xxxxxxxxxxxxxxx
>
> http://www.frameexpert.com/store
>
>
>
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/174322> (by
> email <>)
>


-- 
...Wendell Piez... ...wendell -at- nist -dot- gov...
...wendellpiez.com... ...pellucidliterature.org... ...pausepress.org...
...github.com/wendellpiez... ...gitlab.coko.foundation/wendell...

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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