[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: Fri, 8 Jul 2022 14:08:50 -0000
Re:  Process the following group
Just writing again to note there's a bug in the code I just posted! :->


On Fri, Jul 8, 2022 at 10:03 AM Wendell Piez wapiez@xxxxxxxxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> Rick,
>
> That being said, this can also be done in one pass, and indeed without
> xsl:for-each-group at all ....
>
> <xsl:key name="myDivs" match="div2" use="(preceding-sibling::div1,
> following-sibling::div1)[1]/generate-id()"/>
>
> <xsl:template match="div1">
>   <xsl:copy>
>     <xsl:apply-templates select="key('myDivs',generate-id())"
> mode="include"/>
>   </xsl:copy>
> </xsl:template>
>
> etc.
>
> This works on the principle that groups can be created by relating
> elements together using keys (old 1.0 approach).
>
> Not disagreeing with Eliot's advice here however -- splitting into
> multiple passes will often yield a more maintainable as well as clearer
> solution to a problem. A solution like this is both more obscure, and more
> apt to break when something subtle turns up.
>
> Cheers, Wendell
>
>
>
> On Fri, Jul 8, 2022 at 9:30 AM rick@xxxxxxxxxxxxxx <
> xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
>> Hi Eliot, thank you for walking me through the logic. It makes sense so I
>> will try to code it that way. But I think the advice from you and others
to
>> do a multiple pass may be a more robust approach. Thanks to all that
>> responded. -Rick
>>
>>
>>
>> *From:* Eliot Kimber eliot.kimber@xxxxxxxxxxxxxx <
>> xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
>> *Sent:* Thursday, July 7, 2022 6:11 PM
>> *To:* xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>> *Subject:* Re:  Process the following group
>>
>>
>>
>> So the first two div2 elements should be grouped with the first div1?
>>
>>
>>
>> If you do group-starting-with div1 then the first two div2s will be in
>> the first group and that group will not start with a div1, so you can have
>> logic to ignore that first group and then in a group that starts with
>> <div1>, you can pull any <div2> elements that do not have a <div1>
>> preceding sibling, which will get the <div2>s that would have formed the
>> first group. No subsequent group will have <div2>s that do not have a
>> <div1> preceding sibling.
>>
>>
>>
>> But this is also a case where it might be easier to pre-process your
>> content before grouping, for example, to move things so that therebs
always
>> a <div1> before any <div2>s or what ever it might be.
>>
>> I generally find these kinds of challenges are most effectively solved by
>> breaking them into several steps, each one of which is relatively easy to
>> implement.
>>
>>
>>
>> Cheers,
>>
>>
>>
>> E.
>> 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...
> 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.