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

xsl:for-each-group question

Subject: xsl:for-each-group question
From: "Markus Ohlenroth markus.ohlenroth@xxxxxxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 27 Jan 2016 13:15:17 -0000
 xsl:for-each-group question
Unsing xsl 2.0

 

The below xsl changes the below xml with a list of flat <P/> nodes into
groups based on values in subnodes of <p/>

The result achived with the xsl below is what I want.

 

But what I cannot figure out is:

 

What values must the "select" argument and/or the "group-starting-with"
arguments have in my example

so that the resulting current-group() nodes are <p/> nodes (i.e. the parent
node) instead of <rStyle/> nodes.

 

I cannot achieve the wanted grouping with the resulting current-group()
nodes being <p/> nodes.

I can only achieve the wanted grouping with the resulting current-group()
nodes being <rStyle/> nodes.

 

Thank you for any help.

Kind regards

Markus

 

XML INPUT File:

<Root>

                <p>

                               <rStyle val="Lemma"/>

                </p>

                <p>

                               <rStyle val="description"/>

                </p>

                <p>

                               <rStyle val="Lemma"/>

                </p>

                <p>

                               <rStyle val="description"/>

                </p>

                <p>

                               <rStyle val="description"/>

                </p>

                <p>

                               <rStyle val="Lemma"/>

                </p>

                <p>

                               <rStyle val="description"/>

                </p>

                <p>

                               <rStyle val="description"/>

                </p>

                <p>

                               <rStyle val="description"/>

                </p>

                <p>

                               <rStyle val="description"/>

                </p>

</Root>

 

################ XSL Processing FILE extract
###################################

 

<xsl:template match="Root">

                               <xsl:copy>

 
<xsl:for-each-group select="p/rStyle"
group-starting-with="p/rStyle[@val='Lemma']">

                                                               <service>

<!--                                                                       

This is what I really want as current-group()

<xsl:copy-of select="current-group()/parent::node() "/> 

-->

 
<xsl:copy-of select="current-group()"/>

                                                               </service>

                                               </xsl:for-each-group>

                               </xsl:copy>

                </xsl:template>

 

 

################ Desired Result XML snippet
###################################

<service>

                               <p>

                                               <rStyle val="Lemma"/>

                               </p>

                               <p>

                                               <rStyle val="description"/>

                               </p>

                               <p>

                                               <rStyle val="description"/>

                               </p>

                </service>

################ Current Result XML snippet
#########################################

<service >

                               <rStyle val="Lemma"/>

                               <rStyle val="description"/>

                               <rStyle val="description"/>

</service>

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.