Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

XSLT: how to deep copy (including DOCTYPE, encoding, etc.)

416044Nov 10 2003 — edited Nov 13 2003
I've written the following stylesheet to copy an existing XML. during testing, i noticed that the DOCTYPE was not copied at all and the XML encoding defaultet to UTF-8 (though the original XML has ISO-8859-1). to fix this, i have to set the encoding and doctype-system hard coded:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <!-- adjust doctype-system to generate a different DOCTYPE SYSTEM value: -->
    <xsl:output method="xml" encoding="ISO-8859-1" doctype-system="mine.dtd"/>

    <!-- copy nodes: -->
    <xsl:template match="node()|@*" >
       <xsl:copy>
            <xsl:apply-templates select="node()|@*" />
       </xsl:copy>
    </xsl:template>

</xsl:stylesheet>
but this results in a specialized copy-XSL. is there a generalized way to copy a XML with all content (including <! and <? tags, etc.)? (of course,
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 11 2003
Added on Nov 10 2003
4 comments
542 views