[XML-SIG] Missing DOCTYPE when pretty printing
Nyenyec
nyenyec@mailbox.hu
5 Mar 2001 14:29:54 -0000
Hi,
I try to pretty-print an XML file using the XML package v0.6.2.
My problem is with the doctype node.
I'm writing a web.xml (Java Servlet config) file and it has a DOCTYPE
like this:
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
The problematic code in xml.dom.ext.Printer.py is in the PrintVisitor class:
def visitDocumentType(self, node):
if node.systemId != '': ################### WHY?????
self.__emptyReturn = 0
self.stream.write("<!DOCTYPE " + node.name)
if node.publicId != '':
self.stream.write(' PUBLIC "' + node.publicId + '"')
self.stream.write(' SYSTEM "' + node.systemId + '" ')
if node.entities.length or node.notations.length:
self.stream.write('[')
self.visitNamedNodeMap(node.entities)
self.visitNamedNodeMap(node.notations)
self.stream.write(']')
self.stream.write('>')
return
It seems that if the DOCTYPE node does not have a SYSTEM id, it will not
be printed at all? Is this deliberate or is this a bug?
What is the simplest workaround?
Is there another (simpler) way to pretty print XML files?
Thanks,
Nyenyec
--------------------------------------------------
Mi az Ön MailBox címe? - http://mailbox.hu