Subject: Re: [xsl] [XSLT2] Some common, generic grouping problems From: omprakash.v@xxxxxxxxxxxxx Date: Fri, 30 Jun 2006 18:32:01 +0530 |
Hi, Please see the below stylesheet. This was done by me independently by me. Of course after taking some help from previous postings. <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:foo="http://whatever"> <xsl:output indent="yes"/> <xsl:template match="root"> <root> <xsl:variable name="origdoc" select="/"/> <xsl:for-each-group select="*" group-starting-with="*[@color=('dark-red')] "> <xsl:choose> <xsl:when test="self::*[@color='dark-red']"> <xsl:for-each-group select="current-group()" group-ending-with="*[@color='light-red']"> <xsl:choose> <xsl:when test="current-group()[last()][self::*[@color='light-red']]"> <red> <xsl:copy-of select="current-group()"/> </red> </xsl:when> <xsl:otherwise> <xsl:copy-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:for-each-group> </xsl:when> <xsl:otherwise> <xsl:copy-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:for-each-group> </root> </xsl:template> </xsl:stylesheet> Regards, V.Omprakash Sr. Technical Architect, Product Architecture group 4555 Intellect ct, Extn: 4547 Mobile: 98843 07767 "andrew welch" <andrew.j.welch@ To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx gmail.com> cc: (bcc: omprakash.v/Polaris) Subject: Re: [xsl] [XSLT2] Some common, generic grouping problems 06/30/2006 04:29 PM Please respond to xsl-list On 6/30/06, Christian Roth <roth@xxxxxxxxxxxxxx> wrote: > andrew welch wrote: > > ><root> > > <arbitrary /> > > <elem color="dark-red" /> > > <elem color="red" /> > > <arbitrary color="none" /> > > <elem color="red" /> > > <elem color="light-red" /> > > <arbitrary /> > > <elem color="dark-red" /> > > <elem color="red" /> > > <arbitrary color="none" /> > > <elem color="red" /> > > <elem color="light-red" /> > > <arbitrary /> > ></root> > [...] > >That is of course if I've scaled up the input correctly, no comment > >from the OP so far. > > Yes, this is how the input would scale. I'm sorry for not replying > earlier to the solutions given so far (Andrew, David) - I must admit > that I am still digesting the code given to extract and understand the > underlying idea(s). > > For your (Andrew's) solution to example #1, am I right that the > underlying idea could be paraphrased as: > > "Group by start, then tail-trim the resulting groups to end (using a > nested grouping from end)"? Yes - I would call it "intersecting" rather than "trimming", its providing the end marker for the group. The elements that aren't in the intersect are copied to the result (in the xsl:otherwise blocks) so trimming might give the wrong impression. This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited. Visit us at http://www.polaris.co.in
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] [XSLT2] Some common, gene, andrew welch | Thread | [xsl] Moving (promoting) XML elemen, Mark Peters |
Re: [xsl] Moving (promoting) XML el, David Carlisle | Date | Re: [xsl] Moving (promoting) XML el, Florent Georges |
Month |