Subject: Re: [xsl] Apply for-each-group to a node subset From: Tony Graham <Tony.Graham@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 21 Sep 2007 17:31:31 +0100 |
On Fri, Sep 21 2007 16:28:47 +0100, rocketraman@xxxxxxxxxxx wrote: > Tony Graham wrote: >> On Fri, Sep 21 2007 08:51:13 +0100, rocketraman@xxxxxxxxxxx wrote: >> ... >> I'm still trying to get my head around what you want to do with your >> template, but the likely reasons that your simplification doesn't work >> are: > > I should have provided the output I wanted (obviously ignoring > templates applied to irrelevant nodes). Here it is (basically grouping > all nodes between g1 and g2 into a hierarchical structure). > > <r> > <n1/> > ... > <n2/> > > <group> > <g1/> > ... > <g2/> > </group> > > <group> > <g1/> > ... > <g2/> > </group> > > <n3/> > ... > <n4/> > </r> > > I stated in my original email, but didn't emphasize, that there are an > arbitrary number of nodes between g1 - g2, n1 - n2, and n3 - n4 (my > example nodes were badly named). It may be simpler if you do it all using ">>": <xsl:template match="r"> <xsl:copy> <xsl:apply-templates select="*[../g1[1] >> .]"/> <xsl:for-each-group select="g1[1] | *[(. >> ../g1[1]) and (../g2[last()] >> .)] | g2[last()]" group-ending-with="g2"> <group> <xsl:apply-templates select="current-group()"/> </group> </xsl:for-each-group> <xsl:apply-templates select="*[. >> ../g2[last()]]"/> </xsl:copy> </xsl:template> (The logic might be clearer if the predicates used "<<" instead, except that "<<" has to be written as "<<".) Regards, Tony Graham. ====================================================================== Tony.Graham@xxxxxxxxxxxxxxxxxxxxxx http://www.menteithconsulting.com Menteith Consulting Ltd Registered in Ireland - No. 428599 Registered Office: 13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland ---------------------------------------------------------------------- Menteith Consulting -- Understanding how markup works ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Apply for-each-group to a, Tony Graham | Thread | Re: [xsl] Apply for-each-group to a, Raman Gupta |
Re: [xsl] Apply for-each-group to a, Tony Graham | Date | Re: [xsl] Apply for-each-group to a, Raman Gupta |
Month |