Well, I'm stumped.

The attached file cleanly reproduces the malformed doctype breakage on my OS
X 10.4, Java 5 MacBook, without any dependencies loaded, just plain old
Java.  But I can't find any mention of this bug via Google.  This can't be
the first time anybody's noticed ... ?  I'd check on something other than my
Mac, but the power is out here due to windstorms and about all I can do is
email and web via Bluetooth to my cell  =)

- R

... the error occurs -- I get the malformed doctype on standard out.  I
> reproduced this using a standalone Java application and no Restlet plumbing
> at all.  I'm a little shocked to see this behavior occurring in a core api
> like TRAX, but there it is.  As I said, more diligence to follow.
>
>
package com.solertium.test;

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class XmlIssue {
        
        public static void main(String[] args) throws Exception {
                Document doc = 
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
                final Element root = doc.createElement("html");
                doc.appendChild(root);

                final Element head = doc.createElement("head");
                root.appendChild(head);
                final Element title = doc.createElement("title");
                title.appendChild(doc.createTextNode("My Title"));
                root.appendChild(head);

                final Element body = doc.createElement("body");
                body.appendChild(doc.createTextNode("My text"));
                root.appendChild(body);

                Transformer t = 
TransformerFactory.newInstance().newTransformer();
        t.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM,
                        "-//W3C//DTD XHTML 1.0 Strict//EN");
        t.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC,
                        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";);
                t.transform(new DOMSource(doc),new StreamResult(System.out));

        }

}

Reply via email to