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

multi-level grouping on attributes

Subject: multi-level grouping on attributes
From: "Klocker Christoph" <Christoph.Klocker@xxxxxxxxxxxxx>
Date: Thu, 6 Oct 2005 13:49:40 +0200
multi level grouping
Hi

I try to achieve a multilevel grouping on attributes:
I got several items like these

<SI>
<eintrag pos="181" paragraph="3">aa</eintrag>
<eintrag pos="182" paragraph="3" absatz="1">aa</eintrag>
<eintrag pos="183" paragraph="3" absatz="1">bb</eintrag>
<eintrag pos="184" paragraph="3" absatz="2" a_litera="a" >aa</eintrag>
<eintrag pos="185" paragraph="3" absatz="2" a_litera="a"
ziffer="15">aa</eintrag>
<eintrag pos="186" paragraph="3" absatz="2" a_litera="a"
ziffer="15">bb</eintrag>
<eintrag pos="187" paragraph="3" absatz="2" ziffer="16">aa</eintrag>
<eintrag pos="188" paragraph="5" absatz="5">aa</eintrag>
<eintrag pos="189" paragraph="5" absatz="5" a_litera="a">aa</eintrag>
</SI>

Result should be:
<SI>
 <document>
    <eintrag pos="180" paragraph="3">aa</eintrag>
    <eintrag pos="181" paragraph="3">bb</eintrag>
 </document>
 <document>
   <eintrag pos="182" paragraph="3" absatz="1">aa</eintrag>
   <eintrag pos="183" paragraph="3" absatz="1">bb</eintrag>
 </document>
 <document>
    <eintrag pos="184" paragraph="3" absatz="2">aa</eintrag>
 </document>
<document>
    <eintrag pos="185" paragraph="3" absatz="2" a_litera="a"
ziffer="15">aa</eintrag>
    <eintrag pos="186" paragraph="3" absatz="2" a_litera="a"
ziffer="15">bb</eintrag>
</document>
</SI>

I started with:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" >
	<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>

<xsl:template match="/">
<SI>
	<xsl:for-each-group select="//eintrag" group-by="@paragraph">
	  <xsl:choose>
				<xsl:when
test="current-group()/@absatz">
					<xsl:for-each-group
select="current-group()" group-by="@absatz">
						<document>
						<xsl:copy-of
select="current-group()" copy-namespaces="no"/>
					</document>
					</xsl:for-each-group>
				</xsl:when>
				<xsl:otherwise>
					<document>
						<xsl:copy-of
select="current-group()" copy-namespaces="no"/>
					</document>
				</xsl:otherwise>
		</xsl:choose>
	</xsl:for-each-group>
</SI>
</xsl:template>
</xsl:stylesheet>

The problem is, I loose the <entry> which has no @absatz.
What is the right <xsl:choose> to achieve the required result.

Thx
Christoph

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.