[XML-SIG] DOCTYPEs question with 4DOM
derekfountain at yahoo.co.uk
Wed Jul 7 09:58:12 CEST 2004
On Wednesday 07 July 2004 10:04, Thomas B. Passin wrote:
> Derek Fountain wrote:
> > According to my book (Inside XML, New Riders) a document type declaration
> > can have one of several forms:
> > <!DOCTYPE rootname [DTD]>
> > <!DOCTYPE rootname SYSTEM url>
> > <!DOCTYPE rootname SYSTEM url [DTD]>
> > <!DOCTYPE rootname PUBLIC identifier>
> > <!DOCTYPE rootname PUBLIC identifier [DTD]>
> Not quite ... the XML Rec requires a system identifier even when there
> is a PUBLIC keyword and identifier.
Um, I was just quoting the book! Since my example doesn't have a DTD I was
just after the first option without the optional DTD.
> > I want to create a doctype like this:
> > <!DOCTYPE test>
> > and this:
> > docType = implementation.createDocumentType( "1", "test", "2" )
> > produces:
> > <!DOCTYPE storage PUBLIC "test" "2">
> > with the "1" nowhere to be seen.
> > I have no idea what is going on. Can someone explain? Thanks! :o)
> I can see how it would not know what to do with the "1", since it cannot
> be a legal element name,
Fair point, but it's actually the same with any legal element name.
> but some of those outputs look pretty strange,
> don't they? But what version of the PyXML package are you using? I
> just created document types like yours and they at least had the proper
> sytem and public IDs (I did not serialize anything, though)
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 )
<?xml version='1.0' encoding='UTF-8'?>
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.
More information about the XML-SIG