You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Niranjan Kundapur <ni...@air2web.com> on 2002/02/11 18:18:54 UTC

DOCTYPE is *not* output when using DOMSource and DOMResult

I am trying to output DOCTYPE while transforming XML to WML using Xalan 2.2
and JDK 1.3

My stylesheet contains:
<xsl:output method="xml"
   doctype-public="-//WAPFORUM//DTD WML 1.1//EN" 
   doctype-system="http://www.wapforum.org/DTD/wml_1.1.xml"
/>

The DOCTYPE is output when the code uses the StreamSource and StreamResult:
        Transformer transformer = tFactory.newTransformer(new
StreamSource(theXSLFile));
        transformer.transform(new StreamSource(theXMLFile), new
StreamResult(System.out);

The DOCTYPE is *not* output when the code uses DOMSource and DOMResult. The
'xmlRootNode' is the root node of the XML document. When I print to stdout,
the node name, value, and type, I do not see the DOCTYPE.
        DOMResult domResult = new DOMResult();
        transformer.transform(new DOMSource(xmlRootNode), domResult);
        return domResult.getNode();

I also tried to do set outputProperties before transforming, but this does
not work either:
    Properties theOutputProperties= new Properties();
    theOutputProperties.setProperty(OutputKeys.METHOD, "xml");
    theOutputProperties.setProperty(OutputKeys.DOCTYPE_PUBLIC, );
    theOutputProperties.setProperty(OutputKeys.DOCTYPE_SYSTEM, );
    transformer.setOutputProperties(theOutputProperties);

How can I get the DOCTYPE to be output while using DOMSource and DOMResult?
I searched the FAQs and the mailing list. Though there appear to be similar
problems, I did not see this specific one.

Thanks in advance for any help.

Niranjan