[XML-SIG] Trying to validate a document which is not in a file
Stephane Bortzmeyer
bortzmeyer@nic.fr
Mon, 21 Oct 2002 22:25:45 +0200
I'm trying to validate a XML document. It is not in a file (it was received
from the network) and I do not want to write it on disk just to validate it.
So, I cannot use parse_resource() and I tried:
import xml.parsers.xmlproc.xmlapp
from xml.parsers.xmlproc import xmlval
class MessageValidator (xml.parsers.xmlproc.xmlapp.ErrorHandler):
...
def validate (text):
val = xmlval.XMLValidator()
val.feed(text)
And it always fail:
Traceback (most recent call last):
File "validator.py", line 36, in ?
validate(content)
File "validator.py", line 26, in validate
val.feed(text)
File "/usr/lib/python2.1/site-packages/_xmlplus/parsers/xmlproc/xmlval.py",
line 45, in feed
self.parser.feed(data)
File "/usr/lib/python2.1/site-packages/_xmlplus/parsers/xmlproc/xmlutils.py",
line 330, in feed
self.do_parse()
File "/usr/lib/python2.1/site-packages/_xmlplus/parsers/xmlproc/xmlproc.py",
line 101, in do_parse
self.parse_doctype()
File "/usr/lib/python2.1/site-packages/_xmlplus/parsers/xmlproc/xmlproc.py",
line 510, in parse_doctype
p.deref()
UnboundLocalError: local variable 'p' referenced before assignment
Reading the source, I tried to add various assignments such as
val.current_sysID = "Nothing" but I still get the same mistake.