[Home] [By Thread] [By Date] [Recent Entries]
Marc Harding wrote:
thanks for your fast reply, but as you already assumed, i need an xslt 1.0 solution. Here is an attempt to solve it with XSLT 1.0 plus exsl:node-set which I think libxslt supports: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" exclude-result-prefixes="exsl" version="1.0"> <xsl:output indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template> <xsl:template match="group">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="*[1]" mode="group">
<xsl:with-param name="grtf">
<xsl:copy-of select="*[1]"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:copy>
</xsl:template> <xsl:template match="group/*[@sort-order]" mode="group">
<xsl:param name="grtf"/>
<xsl:choose>
<xsl:when test="following-sibling::*[1][@sort-order]">
<xsl:apply-templates select="following-sibling::*[1]" mode="group">
<xsl:with-param name="grtf">
<xsl:copy-of select="$grtf"/>
<xsl:copy-of select="following-sibling::*[1]"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="exsl:node-set($grtf)/*">
<xsl:sort select="@sort-order" data-type="number"/>
</xsl:apply-templates>
<xsl:apply-templates select="following-sibling::*[1]" mode="group">
<xsl:with-param name="grtf">
<xsl:copy-of select="following-sibling::*[1]"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:template> <xsl:template match="group/*[not(@sort-order)]" mode="group">
<xsl:apply-templates select="."/>
<xsl:apply-templates select="following-sibling::*[1]" mode="group">
<xsl:with-param name="grtf">
<xsl:copy-of select="following-sibling::*[1]"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:template></xsl:stylesheet> -- Martin Honnen http://msmvps.com/blogs/martin_honnen/
|

Cart



