W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2005

validate dom tree object in python

From: Leticia Larrosa <LETICIA@tesla.cujae.edu.cu>
Date: Wed, 06 Apr 2005 09:52:13 -0400
To: www-dom@w3.org
Message-ID: <WorldClient-F200504060952.AA52130565@tesla.cujae.edu.cu>
Hi all:

I have to validate a dom tree but i canīt save it to a xml file.
I have been using the validating parser "xmlproc":
"
xml.parsers.xmlproc.xmlapp.DTDConsumer
xml.parsers.xmlproc.xmlapp.ErrorHandler
xml.parsers.xmlproc.xmlval
"
but i found that the function "create_input_source" in the following code 
that are placed in the module "xml.parsers.xmlproc.xmlapp": 
"
class InputSourceFactory:
    "A class that creates file-like objects from system identifiers."
    def create_input_source(self,sysid):
        if sysid[1:3]==":\\" or urlparse.urlparse(sysid)[0] == '':
            return open(sysid)
        else:
            return urllib2.urlopen(sysid)
"
donīt accept a instance of a xml dom tree.
I get the following error:
"
File "C:\Python23\Lib\site-packages\_xmlplus\parsers\xmlproc\xmlval.py", 
line 31, in parse_resource
self.parser.parse_resource(sysid)
File "C:\Python23\Lib\site-packages\_xmlplus\parsers\xmlproc\xmlutils.py", 
line 123, in parse_resource
infile = self.isf.create_input_source(sysID)
File "C:\Python23\Lib\site-packages\_xmlplus\parsers\xmlproc\xmlapp.py", 
line 224, in create_input_source
if sysid[1:3]==":\\" or urlparse.urlparse(sysid)[0] == '':
AttributeError: Document instance has no attribute '__getitem__'
"

My question is if exist a way of validate a xml dom tree object, not a xml 
file.
I accept any suggestions about other way of validate rather than "xmlproc".
I'm using python2.4

If this isn't the place to make this question please, if any know tell me 
where is

Thanks in advance
Received on Wednesday, 6 April 2005 16:56:36 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:58 GMT