[XML-SIG] Validating a DOM w/xmlproc?

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Sat, 28 Apr 2001 08:45:16 +0200


> interesting question: can you invoke DOM methods such that the
> resultant structure is invalid?  Off the top of my head, I don't
> know.

Certainly. Suppose you have the DTD

<!ELEMENT foo EMPTY>

Still, it is certainly possible to do

>>> d=imp.createDocument(None,"foo",None)
>>> e=d.createElement("bar")
>>> d.documentElement.appendChild(e)
>>> d.toxml()
'<?xml version="1.0" ?>\n<foo><bar/></foo>'

How could the DOM implementation possibly know what DTD I had in mind?
I could have provided a DocumentType node also, but which of these
operations should then have failed, and how? Answer: the DOM does not
care about validity. 

During modification operations, it might well happen that the document
becomes invalid, eg. when removing one node and inserting a different
one elsewhere. If the DOM would reject such modifications, it would be
useless.

Regards,
Martin