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
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--