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

Re: RE: Re: Converting the flat XML to hierarchical fo

Subject: Re: RE: Re: Converting the flat XML to hierarchical format (plus grouping, data replication and sorting)
From: "Joerg Heinicke" <joerg.heinicke@xxxxxx>
Date: Wed, 30 Jan 2002 22:34:23 +0100
Re:  RE: Re: Converting the flat XML to hierarchical fo
add <xsl:sort> after <xsl:for-each>: http://www.w3.org/TR/xslt#sorting

Regards,

Joerg

----- Original Message -----
From: "Shyam Chebrolu" <schebrolu@xxxxxxxxxxxxxxx>
To: <XSL-List@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Wednesday, January 30, 2002 8:01 PM
Subject:  RE: Re: Converting the flat XML to hierarchical format (plus
grouping, data replication and sorting)


> I tried to post this before. It was bounced back for some reason...
>
> Anyway, I was able to comeup with some solution. But it is not complete.
>
> I couldn't figure out how to sort the items after they are grouped...
>
> I used the below XSL:
>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
>
> <xsl:key name="products-by-group" match="GROUP_ID" use="." />
> <xsl:variable name="product-id" select="DATA/PRODUCT_ID" />
> <xsl:variable name="product-desc" select="DATA/PRODUCT_DESC"/>
> <xsl:variable name="group-id" select="DATA/GROUP_ID"/>
>
> <xsl:template match="/">
> <DATA>
> <xsl:for-each select="DATA/GROUP_ID[count(. |
> key('products-by-group', .)[1]) = 1]">
> <PRODUCTS>
> <xsl:attribute name="ID"><xsl:value-of  select="."
> /></xsl:attribute>
> <xsl:variable name="n" select="." />
>
> <xsl:for-each select="$group-id[. = $n or . = 0]">
> <xsl:variable name="index"
> select="count(preceding-sibling::GROUP_ID) + 1" />
> <PRODUCT>
> <xsl:copy-of
> select="$product-id[$index]" />
>   <xsl:copy-of
> select="$product-desc[$index]" />
> </PRODUCT>
> </xsl:for-each>
> </PRODUCTS>
> </xsl:for-each>
> </DATA>
> </xsl:template>
> </xsl:stylesheet>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.