Hi,

John Nikolai wrote:
Basically I'm sorting an XML document (based on the date element) and dumping the contents into another XML document using the same elements and structure.

I think you are trying too hard. Dumping the contents of a XML document is what <xsl:copy-of> is for.

Try this:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
        xmlns:xalan="http://xml.apache.org/xslt";>

<xsl:output method="xml" indent="yes" xalan:indent-amount="4"/>

<xsl:template match="calendar">
        <calendar>
                <!-- also dump calendar attributes if any -->
                <xsl:copy-of select="@*"/>
                <xsl:apply-templates select="event">
                        <xsl:sort select="date"/>
                </xsl:apply-templates>
        </calendar>
</xsl:template>

<xsl:template match="event">
        <xsl:copy-of select="."/>
</xsl:template>

</xsl:stylesheet>

HTH,
Christophe




Reply via email to