Subject: Re: [xsl] Add a level of structure? From: "Sam D. Chuparkoff" <sdc@xxxxxxxxxx> Date: Mon, 20 Jun 2005 03:39:42 -0700 |
On Mon, 2005-06-20 at 09:32 +0300, George Cristian Bina wrote: > Hi Edmund, > > You can use something like below: > > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="2.0"> > <xsl:output indent="yes"/> > <xsl:template match="a"> > <foo> > <xsl:apply-templates/> > </foo> > </xsl:template> > <xsl:template match="b"> > <bar> > <xsl:variable name="sortedCs"> > <xsl:for-each select="c"> > <xsl:sort select="c1" data-type="number"/> > <xsl:copy-of select="."/> > </xsl:for-each> > </xsl:variable> George is right, you'll want to take two passes at those <c> s. After that, you just need to go with: <baz> <x att="val" att2="val2"/> <y att="val" att2="val2"/> <xsl:apply-templates select="subsequence($sortedCs/*, 1, 3)"/> </baz> <baz> <q att="val" att2="val2"/> <r att="val" att2="val2"/> <xsl:apply-templates select="subsequence($sortedCs/*, 4, 3)"/> </baz> <baz> <g att="val" att2="val2"/> <h att="val" att2="val2"/> <xsl:apply-templates select="subsequence($sortedCs/*, 7, 3)"/> </baz> > <xsl:for-each select="$sortedCs/*"> > <xsl:if test="position() mod 3 =1"> > <baz> > <xsl:call-template name="specificContent"> > <xsl:with-param name="pos" select="(position()-1) div 3"/> > </xsl:call-template> > <xsl:apply-templates select="."/> > <xsl:apply-templates select="following-sibling::c[1]"/> > <xsl:apply-templates select="following-sibling::c[2]"/> > </baz> > </xsl:if> > </xsl:for-each> > </bar> > </xsl:template> But you'll probably want to do something like the above someday soon. sdc
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Add a level of structure?, George Cristian Bina | Thread | RE: [xsl] Add a level of structure?, Aron Bock |
Re: [xsl] preceding/following chara, David Carlisle | Date | [xsl] join two files - plz help, Michael Donabauer |
Month |