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.
>> And the doctype is then removed from the Document.
>> Any idea on what could be causing this? Is this a bug in JDOM? I have
> tried padding the publicId and systemId with whitespaces, but with no
> success.
This is a bug in SAXOutputter.
> I saw a similar problem online:
>>http://www.junlu.com/msg/49224.html
This is exactly the same problem and a patch was proposed which also applies
to your JDOM version :
- Look for the method dtdEvents(Document document).
In the following code:
// No internal subset defined => Try to parse original DTD
if ((publicID != null) || (systemID != null)) {
if (publicID != null) {
buf.append(" PUBLIC ");
buf.append('\"').append(publicID).append('\"');
}
else {
buf.append(" SYSTEM ");
}
buf.append('\"').append(systemID).append('\"');
}
else {
// Doctype is totally empty! => Skip parsing
buf.setLength(0);
}
Replace the lines:
buf.append(" SYSTEM ");
}
buf.append('\"').append(systemID).append('\"');
by:
buf.append(" SYSTEM");
}
buf.append(" \"").append(systemID).append('\"');
For the "Fatal error" message display issue, you need to patch the
createDTDParser() method : Just before the return statement, at the end of
method, insert the following line :
parser.setErrorHandler(new DefaultHandler());
Hope this helps,
Laurent