Marc Harding wrote:
thanks for your fast reply, but as you already assumed, i need an xslt
1.0 solution.
i should have made it more clear that i'm limited to php5.2.x
xslt-capabilities (libxml/libxslt).
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/*[(_at_)sort-order]" mode="group">
<xsl:param name="grtf"/>
<xsl:choose>
<xsl:when test="following-sibling::*[1][(_at_)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/
--~------------------------------------------------------------------
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>
--~--