[Home] [By Thread] [By Date] [Recent Entries]
On 7/24/07, Michael Kay <mike@xxxxxxxxxxxx> wrote:
In trying to reverse-engineer your code, it looks to me as if you are doing a classic "group-adjacent" problem, where a group of adjacent row elements are wrapped in a table element. In XSLT 2.0 the most efficient way to do this should be <xsl:for-each-group group-adjacent="boolean(self::row)">. In 1.0 the most efficient would probably be sibling-recursion Ahh I missed that bit. To do sibling recursion in this case you need: <xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="node()[1]"/>
</xsl:copy>
<xsl:apply-templates select="following-sibling::node()[1]"/>
</xsl:template><xsl:template match="row"> <table> <xsl:apply-templates select="." mode="copy"/> </table> <xsl:apply-templates select="following-sibling::*[not(self::row)][1]"/> </xsl:template> <xsl:template match="row" mode="copy"> <xsl:copy-of select="."/> <xsl:apply-templates select="following-sibling::*[1][self::row]" mode="copy"/> </xsl:template>
|

Cart



