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

RE: multi-level grouping on attributes

Subject: RE: multi-level grouping on attributes
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 6 Oct 2005 13:02:02 +0100
xsl multilevel grouping
If the grouping key for an item is an empty sequence, the item doesn't go in
any group. So you need to invent an artificial grouping key for such items.
For example

@group-by="(@absatz, -1)[1]"

will allocate a grouping key of -1 to eintrdge that have no absatz.

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Klocker Christoph [mailto:Christoph.Klocker@xxxxxxxxxxxxx]
> Sent: 06 October 2005 12:50
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  multi-level grouping on attributes
>
> 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.