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

Re: for-each-group

Subject: Re: for-each-group
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 28 Mar 2018 16:05:59 -0000
Re:  for-each-group
Try group-adjacent="concat(local-name(), if (self::figure) then position()
else 0))"

which will work for your example though it may not match your general
intent...

Michael Kay
Saxonica


> On 28 Mar 2018, at 16:53, Rick Quatro rick@xxxxxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Hi All,
>
> I have a <step> element that looks something like this:
>
> <steps>
>   <step>
>     <para>Intro stuff</para>
>     <para>More intro stuff</para>
>     <figure/>
>     <figure/>
>     <para>Conclusion stuff</para>
>     <para>More conclusion stuff</para>
>   </step>
> </steps>
>
> I want 4 separate groups:
>
> 1) First two <para> elements.
> 2) First <figure>
> 3) Second <figure>
> 4) Last two <para> elements.
>
> Here is my stylesheet:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform
<http://www.w3.org/1999/XSL/Transform>"
>     xmlns:xs="http://www.w3.org/2001/XMLSchema
<http://www.w3.org/2001/XMLSchema>"
>     exclude-result-prefixes="xs"
>     version="2.0">
>
>     <xsl:template match="/steps">
>         <xsl:apply-templates select="step"/>
>     </xsl:template>
>
>     <xsl:template match="step">
>         <xsl:for-each-group select="*" group-starting-with="figure">
>             <xsl:message select="count(current-group())"></xsl:message>
>         </xsl:for-each-group>
>     </xsl:template>
>
> </xsl:stylesheet>
>
> I get the first two groups, but the last two <para> elements are part of the
last <figure>'s group instead of being separate.
>
> I tried using group-by="figure" but I don't get any output. Any help would
be appreciated. Thank you very much.
>
> Rick
>
> Rick Quatro
> Carmen Publishing Inc.
> rick@xxxxxxxxxxxxxxx <mailto:rick@xxxxxxxxxxxxxxx>
> FrameMaker toys: www.frameexpert.com/store
<http://www.frameexpert.com/store>
> 585-366-4017
>
>
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <-list/293509> (by email <>)

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.