[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: xsl:for-each-group and identity transform
Sorry, forgot the new stylesheet. The impossible turned out to be easy. We have now identity transformation and xsl:for-each-group working side by side: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns="http://www.w3.org/1999/xhtml" xpath-default-namespace="http://www.w3.org/1999/xhtml"> <xsl:output method="xml" indent="yes"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="body"> <xsl:copy> <xsl:for-each-group select="element()|comment()|processing-instruction()" group-starting-with="h1"> <xsl:apply-templates select="." mode="group"/> </xsl:for-each-group> </xsl:copy> </xsl:template> <xsl:template match="h1" mode="group"> <h> <xsl:copy-of select="node()"/> </h> <xsl:for-each-group select="current-group() except ." group-starting-with="h2"> <xsl:apply-templates select="." mode="group"/> </xsl:for-each-group> </xsl:template> <xsl:template match="h2|h3|h4|h5|h6" mode="group"> <xsl:variable name="this" select="name()"/> <xsl:variable name="next" select="translate($this, '23456', '34567')"/> <section> <h> <xsl:copy-of select="node()"/> </h> <xsl:for-each-group select="current-group() except ." group-starting-with="*[name() = $next]"> <xsl:apply-templates select="." mode="group"/> </xsl:for-each-group> </section> </xsl:template> <xsl:template match="element()|comment()|processing-instruction()" mode="group"> <xsl:apply-templates select="current-group()"/> </xsl:template> <!-- more templates here to delete what is copied out of DTD --> <xsl:template match="@shape"/> </xsl:stylesheet> Cheers, Jesper Tverskov
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|