[XML-SIG] Problem using schema instead of DTD

Tim van Erven tve at vormig.net
Fri Jan 14 11:39:29 CET 2005


Dear all,

I'm using pyxml to read an xml file from stdin, modify it a bit, and
write it out again to stdout. In the process a doctype is added
automatically. In the output a <!DOCTYPE ...> line is added. I'm using a
schema to validate my output, but it won't validate when the !DOCTYPE is
present, so I think I'd like to get rid of that.

I'm doing something like:

import sys
from xml.dom.ext.reader import Sax2
from xml.dom.ext import PrettyPrint
reader = Sax2.Reader()
doc = reader.fromStream(sys.stdin)
# modify doc
PrettyPrint(doc)

The xml files I'm using look like this:

<?xml version="1.0" encoding="ISO-8859-1"?>
 
<ltp xmlns="http://www.example.org/info"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/info someschema.xsd">
 
<text>This is some sample text.</text>
</ltp>

And the output of my program looks like this, which won't validate:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ltp> 
<ltp xmlns="http://www.example.org/info"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/info someschema.xsd">
 
<text>This is some modified sample text.</text>
</ltp>

Does anyone know how to get rid of the !DOCTYPE line? Is that the right
thing to do anyway?

I'm rather new to xml, so any conceptual corrections would be much
appreciated as well.

Regards,
Tim

-- 
Tim van Erven <tve at vormig.net>


More information about the XML-SIG mailing list