[jdom-interest] Issue with Doctype (systemId , publicId whitespace)

Per Norrman pernorrman at telia.com
Fri May 7 02:26:07 PDT 2004


Collin VanDyck wrote:

> I'm using JDOM b8, and having a little bit of trouble assigning a 
> DocType to my Document.  I assign the DocType to my document:
> DocType newDocType = new DocType(document.getRootElement().getName());
> newDocType.setPublicID(publicId);
> newDocType.setSystemID(systemId);
> document.setDocType(newDocType);
> This executes without error.  However, transforming this Document at a 
> later point gives me the error:
> [Fatal Error] :1:53: White spaces are required between publicId and 
> systemId.

But the transformation works, doesn't it? I assume you transform the 
JDOM document using JDOMSource, and in that case the error shouldn't
have any effect on the actual tranformation.

Here's the case: JDOMSource uses SAXOutputter to generate SAX events.
SAXOutputter constructs a string representing a doctype declaration,
creates a parser and feeds this string to the parser, which in turn
generates SAX dtd events. SAXOutputter indeed contains a bug here,
there is no whitespace between the public identifier and the system
identifier, as the XML specification mandates.

If I fix this, I get another error:
[Fatal Error] :-1:-1 Premature end of file

which is pretty obvious.

If I configure the parser that is created to have the same error handler
as the SAXOutputter, the error reporting goes away. SAXOuputter gets an
error handler assigned from the transformer code somewhere.

> And the doctype is then removed from the Document.

I don't understand this. Surley the Doctype isn't removed from
your source Document. If you want to have a doctype declaration in
your result, use the <xsl:output> element to declare this.

Apart from that, why do you need the DocType present when doing the


More information about the jdom-interest mailing list