[XML-SIG] DOCTYPEs question with 4DOM (4DOM bug?)
Derek Fountain
derekfountain at yahoo.co.uk
Wed Jul 7 10:27:45 CEST 2004
> PyXML-0.8.3 on SUSE-9.1. If you didn't serialize anything, how are you
> seeing the system and public IDs?
>
> I'm totally confused. It seems the only way to get a DOCTYPE with the
> correct root element and no SYSTEM or PUBLIC ids is to provide a non blank
> PUBLIC id:
>
> docType = implementation.createDocumentType( None, "xxx", None )
> document = implementation.createDocument( None, "test", docType )
>
> which gives:
>
> <?xml version='1.0' encoding='UTF-8'?>
> <!DOCTYPE test>
> <test>
> ...
>
> The "xxx" seems to be ignored, but passing None or a blank string in its
> place means the serialisation doesn't produce a DOCTYPE line at all.
Replying to myself, it seems to be a problem specific to 4DOM. The serialiser
in dom/ext/Printer.py is quite clear:
def visitDocumentType(self, doctype):
if not doctype.systemId and not doctype.publicId: return
Both the sax/saxutils.py serialiser and the dom/minidom.py serialiser print
the "<DOCTYPE" part of the line before considering if a system or public id
is known about.
That visitDocumentType() method is pretty straightforward, but it doesn't look
right. The XML-1.1 spec, which I'm not really familiar with, but which isn't
too hard to read, seems to say that a doctype with neither an External ID nor
an internal subset is valid, so shouldn't the serialiser be able to produce
it?
/me remains puzzled... :o)
--
> eatapple
core dump
More information about the XML-SIG
mailing list