xml-0.5.1 and comments

Lars Marius Garshol larsga at ifi.uio.no
Wed Jul 7 15:04:38 EDT 1999


* Cees Wesseling
| 
| But the DOM walker seems not to pass comment's through.  What I want
| is an exact copy of the input xml minus the transformations I want
| to made. But in Walker overriding doComment does not trigger any
| comments.

Probably because the DOM builder you use does not pass on comments.
Most of them are built on top of SAX, which does not report comments
(see below).

If you really want this you can write a DOM builder on top of your
favourite parser. Should be pretty easy to do and you can look at
xml.dom.builder and the SAX driver for that parser for guidance.
 
| Also wading to some of the SAX code, I started wondering if I can do
| this with SAX. 

SAX 1.0 does not report comments, since they're not part of the
logical document. SAX 2, which will have lexical information beyond
the pure logical stuff, will be able to report comments.

| Does anyone has some sample code, for DOM or SAX that does nothing
| else then replicating the xml input exactly, is that possible?

No. Stuff like whitespace in tags etc etc is not available through the
DOM or SAX, so you can't do that. With xmlproc 0.62 you should be able
to do it since it will let you peek at the raw markup (although I
think you'll lose the entity structure).

BTW: you may want to subscribe to the XML-SIG to discuss this sort of
thing. 

--Lars M.




More information about the Python-list mailing list