[XML-SIG] Dissabling DTDs or arranging the Attribute order

Reza Naima Reza Naima <reza@reza.net>
Mon, 4 Dec 2000 17:12:24 -0800


On Tue, Dec 05, 2000 at 01:11:50AM +0100, Martin v. Loewis sent me this...
> > Now, there are to work-arounds... First off, would there be a way for me
> > to guarantee that attribute1 is first on the list of attributes for that
> > element. 
> 
> That shouldn't be hard to achieve if you use the xml.dom.ext.Printer
> framework - just subclass the PrintVisitor (or the PrettyPrintVisitor)
> and replace the visitNameNodeMap method. That iterates over the
> attributes in the order they have in the dictionary; you could sort
> them (lexically) before that.

I'm lost here.. I can't find anything called PrintVisitor or
PrettyPrintVisitor in any of the PyXML Code :

reza@gooz:/usr/local/src/PyXML-0.5.4 > find . -type f -print | xargs
grep -i NameNodeMap
reza@gooz:/usr/local/src/PyXML-0.5.4 > find . -type f -print | xargs
grep -i PrettyPrintVisitor
reza@gooz:/usr/local/src/PyXML-0.5.4 > find . -type f -print | xargs
grep -i PrintVisitor
reza@gooz:/usr/local/src/PyXML-0.5.4 > 

> 
> > The other work-around is to get rid of attribute2 and attribute3.  This
> > workes, but it seems as PyXML looks at the DTD spec, notices that they
> > are missing, and fills them in.  So, I'de like to find a way to get
> > PyXML to ignore the DTD.
> 
> I'm surprised it looks into the DTD. During parsing, you mean? Then
> you probably use xmlproc as the parser, which is validating. If you'd
> use pyexpat (or some other non-validating parser), it couldn't
> possibly use the DTD.

I tried to specify pyexpat as the parser :

-------------
from xml.dom import core, utils
import sys

fr = utils.FileReader()
path = sys.argv[1]
file = open(path, 'r')
document = fr.readXml(file, 'pyexpat')
print document.toxml()
---------------

and I got this exception thrown :

---------------
# /lc/bin/python /tmp/test.py /var/tmp/JUNIPER.xml 
Traceback (innermost last):
  File "/tmp/test.py", line 7, in ?
    document = fr.readXml(file, 'pyexpat')
  File "/lc/blackshadow/PyXML/xml/dom/utils.py", line 162, in readXml
    p = saxexts.make_parser(parserName)
  File "/lc/blackshadow/PyXML/xml/sax/saxexts.py", line 159, in make_parser
    return XMLParserFactory.make_parser(parser)
  File "/lc/blackshadow/PyXML/xml/sax/saxexts.py", line 65, in make_parser
    raise saxlib.SAXException("No parsers found",None)
xml.sax.saxlib.SAXException: No parsers found
-------------

Am I doing something wrong?

Thanks,
Reza