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

RE: Multiple for-each-group in a single template

Subject: RE: Multiple for-each-group in a single template
From: "V.Ramkumar" <v.ramkumar@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 20 Nov 2008 16:42:47 +0530
RE:  Multiple for-each-group in a single template
Well formed Input only I am using. Mistakes happened when I compose a
mail(sample input)

<body>
       <p class="heading-1">Heading 1</p>
               <p>para 1</p>
               <p class="box">para 2</p>
               <p class="box">para 3</p>
               <p>para 4</p>
       <p class="heading-2">Heading 2</p>
               <p>para 1</p>
               <p class="exercise">para 2</p>
               <p class="exercise">para 3</p>
               <p>para 4</p>
</body>


Regards,
Ramkumar

-----Original Message-----
From: Vasu Chakkera [mailto:vasucv@xxxxxxxxx] 
Sent: Thursday, November 20, 2008 4:38 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Multiple for-each-group in a single template

Your XML is not wel formed.  if you could send back the XML that is
properly closes ( see the h1, h2, and p class= "heading.. ) is not
closed.
its hard to device a solution with out knowing the correct input.

<body>
       <p class="heading-1">Heading 1</p>
               <p>para 1</p>
               <p class="box">para 2</p>
               <p class="box">para 3</p>
               <p>para 4</p>
       <p class="heading-2">Heading 2</p>
               <p>para 1</p>
               <p class="exercise">para 2</p>
               <p class="exercise">para 3</p>
               <p>para 4</p>
</body>

Vasu

> Hi List,
>
> I am getting duplicate when use multiple for-each-group in a single
template
> (based on single parent). Please find mistakes in my xslt.
>
> Input:
> <body>
>        <p class="heading-1">Heading 1</h1>
>                <p>para 1</p>
>                <p class="box">para 2</p>
>                <p class="box">para 3</p>
>                <p>para 4</p>
>        <p class="heading-2">Heading 2</h2>
>                <p>para 1</p>
>                <p class="exercise">para 2</p>
>                <p class="exercise">para 3</p>
>                <p>para 4</p>
> </body>
>
> Exp.Output:
>
> <body>
>        <section title="Heading-1">
>                <p>para 1</p>
>                <box>
>                        <p>para 2</p>
>                        <p>para 3</p>
>                </box>
>                        <p>para 4</p>
>        </section>
>        <section title="Heading-2">
>                <p>para 1</p>
>                <excecise>
>                        <p>para 2</p>
>                        <p>para 3</p>
>                </excecise>
>                <p>para 4</p>
>        </section>
> </body>
>
> My XSLT: (sample)
>        <xsl:template match="body">
>        <body>
>                        <xsl:for-each-group select="*"
> group-adjacent="string(self::p/@class[contains(.,'box')])">
>                        <xsl:choose>
>                                <xsl:when
> test="self::p/@class[contains(.,'box')]">
>                                        <box>
>                                                <xsl:apply-templates
> select="current-group()"/>
>                                        </box>
>                                </xsl:when>
>                                <xsl:otherwise>
>                                        <xsl:apply-templates
> select="current-group()"/>
>                                </xsl:otherwise>
>                        </xsl:choose>
>                        </xsl:for-each-group>
>                <xsl:for-each-group select="*"
> group-adjacent="string(self::p/@class[contains(.,'exercise')])">
>                        <xsl:choose>
>                                <xsl:when
> test="self::p/@class[contains(.,'exercise')]">
>                                        <exercise>
>                                                <xsl:apply-templates
> select="current-group()"/>
>                                        </exercise>
>                                </xsl:when>
>                                <xsl:otherwise>
>                                        <xsl:apply-templates
> select="current-group()"/>
>                                </xsl:otherwise>
>                        </xsl:choose>
>                </xsl:for-each-group>
> ......like wise section and all
>
>        </body>
>
> Regards,
> Ramkumar
>
>



-- 
Vasu Chakkera
Numerical Algorithms Group Ltd.
Oxford
www.vasucv.com

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.