Subject: Re: [xsl] 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 |
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: [xsl] 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] RE: Re: Converting the flat X, Shyam Chebrolu | Thread | [xsl] XSL Generator in XSL., Avula, Raj |
[xsl] about impoting and applying T, gbk | Date | Re: [xsl] XSL Generator in XSL., Joerg Heinicke |
Month |