[XML-SIG] Reader() newbie question

Uche Ogbuji uche.ogbuji@fourthought.com
Wed, 27 Jun 2001 15:24:19 -0600


> Where my confusion really starts is that in most examples I have seen (i.e.
> xmldoc/doc/demo/dom) a slightly different method seems to be used, i.e...
> 
> from xml.dom.ext.reader import PyExpat
> from xml.dom.ext.reader import Sax
> reader = PyExpat.Reader()
> xml_object = reader.fromUri(xmluri)
> 
> This is fine, but I really want a validating parser.  Is is possible for me
> to do something like reader=ValidatingParser.Reader()?  Which validating
> parser can I instanciate like that?  xmlproc? What are the advantages from
> one method over the other?
> 
> Thanks a lot for the help -  being a newbie can but fun and frustrating at
> the same time.  If these are questions that I should have been able to
> quickly answer from the documentation I would appreciate a pointer to the
> right place/doc so that I don't need to waste people's time in the future.

from xml.dom.ext.reader import Sax
from xml.sax.saxexts import make_parser
p = make_parser("xml.sax.drivers.drv_xmlproc")
reader = Sax.Reader(parser=p)

If this works for you, do you mind contributing back a demo that illustrates 
this?  Just a very brief script that does something after having created a 
validating parser.  We'd check it in alongside the other demos in the demo/dom 
directory of PyXML.  You can look at these others for examples.

This way this tip could help many others as well.

In general to all: I've got a lot of mail about lack of good 4DOM examples 
(Greg Wilson will be happy to know he's not alone).  I keep meaning to do so, 
but time is really short these days.  If anyone wants to comment up some of 
their quick and dirty DOM scripts for includion in the demos, please consider 
this.  I'm happy to gather them, test them and check them in.

Thanks.

-- 
Uche Ogbuji                               Principal Consultant
uche.ogbuji@fourthought.com               +1 303 583 9900 x 101
Fourthought, Inc.                         http://Fourthought.com 
4735 East Walnut St, Ste. C, Boulder, CO 80301-2537, USA
XML strategy, XML tools (http://4Suite.org), knowledge management