[XML-SIG] Removing Whitespace

Tonguç Yumruk tongucyumruk@interaktif.gen.tr
Wed, 23 Apr 2003 16:37:36 +0300


--BOKacYhQ+x31HxR3
Content-Type: text/plain; charset=iso-8859-9
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Thanks, but I don't use Sax, I just use the Sax2 reader from xml.dom.ext
package to build a dom tree. I'm looking for a function that will remove
whitespace nodes from my dom tree.

Wed, Apr 23, 2003 at 01:55:18PM +0200 Tarihinde Alexandre Fayolle Demi=FEki=
 :
> On Wed, Apr 23, 2003 at 02:40:57PM +0300, Tongu=E7 Yumruk wrote:
> > Hi,
> >=20
> > I'm new to Python & XML processing, and I'm in trouble with whitespace.=
 I
> > use xml.dom to process xml and Sax2.Reader() from xml.dom.ext.reader. I
> > don't want the whitespace interpreted as a text node. Although the
> > Reader() class have some option like keepAllWs I don't think it really
> > does what I need.
>=20
> In order to have Sax handle whitespace for you, you need:
>  * a validating parser
>  * a DTD for your document
>=20
> You need to install python-xml on Debian to have a validating parser
> (there are no validating parsers in python-xmlbase).=20
>=20
> With this package, you can get a validating parser with the following
> code :
>=20
> from xml.sax.sax2ext import XMLValParserFactory
> parser =3D XMLValParserFactory.make_parser()
>=20
> Then attach your handlers as usual. Ignorable whitespace should be
> reported to the ContentHandler.ignorableWhitespace() method if you
> provided it, and not to the characters() method.
>=20
> --=20
> Alexandre Fayolle
> LOGILAB, Paris (France).
> http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org
> D=E9veloppement logiciel avanc=E9 - Intelligence Artificielle - Formations
>=20
> _______________________________________________
> XML-SIG maillist  -  XML-SIG@python.org
> http://mail.python.org/mailman/listinfo/xml-sig

--=20
Sevgi Sayg=FD Linux
###########################################################################=
#####
BOFH excuse #84:
=20
Someone is standing on the ethernet cable, causeing a kink in the cable
###########################################################################=
#####
Tongu=E7 Yumruk

--BOKacYhQ+x31HxR3
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.0 (GNU/Linux)

iD8DBQE+ppcg1xWu4MLSyoYRAokEAKDnontQZLgPd0M/ip1JeNqwaZjgHQCgyzi2
1CGOa0Z1TYLDPX+u3gAyOlc=
=yPsj
-----END PGP SIGNATURE-----

--BOKacYhQ+x31HxR3--