Search

Dark theme | Light theme

July 4, 2008

Copy XML as-is with XSLT

Working with Cocoon pipelines makes it easy to modularize XSLT. Because each XSLT module contains a small part of the functionality we usually have to copy along a lot of the XML structure. The XML structure can than be used in a following XSL transformation. The following piece of code will copy all XML:

    <xsl:template match="*">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="@*|text()|comment()|processing-instruction()">
        <xsl:copy-of select="."/>
    </xsl:template>