users@jaxb.java.net

Re: JAXB Marshal Not specifying the DTD in generated XML

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Thu, 09 Jan 2003 10:04:16 -0800

> I am trying to implement JAXB. But when I marshal the Java Content Tree,
> the resulting output does not have the DTD (<!DOCTYPE CIN PUBLIC
> "-//Interleaf//DTD CIN//EN" "cin.dtd" [ ]) that this document has to be
> validated against. Please let me know if I have to do anything special
> in order to achieve this result.

Probably the easiest way to do is for you to look for XMLWriter
implementation that supports DOCTYPE. I'm not 100% sure but it seems
like Apache XMLSerializer [1] supports this.

XMLSerializer can receive SAX events and produce the equivalent textual XML
representation, you then configure XMLSerialiier to produce the desired
DOCTYPE declaration, then marshal JAXB content tree into XMLSerializer
by using the marshal(Object,ContentHandler) method.

[1]
http://www-3.ibm.com/software/webservers/appserv/doc/v35/ae/apidocs/org/apache/xml/serialize/XMLSerializer.html

regards,
--
Kohsuke KAWAGUCHI                  408-276-7063 (x17063)
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com