I am using a SAX TransformerHandler to generate some XML with a DOCTYPE declaration. My simple test application is included at the bottom of this email. I am using Java 1.5.0_04.

When I run it without saxon8.jar in my classpath, I get the expected output with the DOCTYPE declaration.

When I run it with saxon8.jar in my classpath, I get the same output but the DOCTYPE declaration is missing.

As anyone already ran into this issue? Thank you in advance for your help and any information.

Best Regards,

Nicolas Beney

PS: Please reply to nbeney@kbcfp.com



% java -cp . -Djaxp.debug=1 TestC

JAXP: find factoryId =javax.xml.transform.TransformerFactory
JAXP: loaded from fallback value: com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl
JAXP: created new instance of class com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl using ClassLoader: sun.misc.Launcher$AppClassLoader@1855af5

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE a SYSTEM "http://abc.com/report.dtd">


% java -cp .:saxon8.jar -Djaxp.debug=1 TestC

JAXP: find factoryId =javax.xml.transform.TransformerFactory
JAXP: found jar resource=META-INF/services/javax.xml.transform.TransformerFactory using ClassLoader: sun.misc.Launcher$AppClassLoader@1855af5

JAXP: found in resource, value=net.sf.saxon.TransformerFactoryImpl
JAXP: created new instance of class net.sf.saxon.TransformerFactoryImpl using ClassLoader: sun.misc.Launcher$AppClassLoader@1855af5

<?xml version="1.0" encoding="UTF-8"?>


import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TransformerHandler;
import javax.xml.transform.stream.StreamResult;

import org.xml.sax.helpers.AttributesImpl;

public class TestC
    public static void main(String[] args) throws Exception
        SAXTransformerFactory factory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();

        TransformerHandler handler = factory.newTransformerHandler();

        handler.setResult(new StreamResult(System.out));

        handler.startDTD(null, null, "http://abc.com/report.dtd");
        handler.startElement("", "a", "a", new AttributesImpl());
        handler.endElement("", "a", "a");

This message may contain confidential, proprietary, or legally privileged information. No confidentiality or privilege is waived by any transmission to an unintended recipient. If you are not an intended recipient, please notify the sender and delete this message immediately. Any views expressed in this message are those of the sender, not those of KBC Financial Products or any affiliate thereof.

This message does not create any obligation, contractual or otherwise, on the part of any such entity. It is not an offer (or solicitation of an offer) of, or a recommendation to buy or sell, any financial product. Any prices or other values included in this message are indicative only, and do not necessarily represent current market prices, the prices at which any KBC entity would enter into a transaction or the prices at which similar transactions may be carried on that entity's own books. The information contained in this message is provided "as is", without representations or warranties, express or implied, of any kind. Past performance is not indicative of future returns.