[XML-SIG] Bug with XML file having a doctype declaration
Uche Ogbuji
uche.ogbuji@fourthought.com
Wed, 26 Mar 2003 06:31:56 -0700
> #! /usr/bin/env python =
> =
> from xml.sax.expatreader import \
> ExpatParser, \
> expat
> =
> class pyExpatWrapper(ExpatParser):
> """
> Wrapper f=C3=BCr den ExpatParser, der verhindert, dass versucht wir=
d das
> externe Subset der DOCTYPE-Spezifikation zu parsen.
> """
> def reset(self):
> ExpatParser.reset(self)
> self._parser.SetParamEntityParsing (
> expat.XML_PARAM_ENTITY_PARSING_NEVER)
> import xml.dom
> from xml.dom.ext.reader import Sax2
> =
> reader =3D Sax2.Reader()
> doc =3D reader.fromString("""<?xml version=3D"1.0" ?>
> <!DOCTYPE kasten PUBLIC "-//Jochen Voss//DTD Zettel 1.0//EN" "zettel.dt=
d">
> <kasten>
> </kasten>
> """)
> for c in doc.childNodes:
> if c.nodeType=3D=3Dxml.dom.Node.DOCUMENT_TYPE_NODE:
> print "public ID: "+c.publicId
> print "system ID: "+c.systemId
> --------------><---------------------><--------------------------
expat.XML_PARAM_ENTITY_PARSING_NEVER should probably be a parameter to th=
e =
relevant readers. Anyone object if I make a backwards-compatible change =
in =
this direction?
-- =
Uche Ogbuji Fourthought, Inc.
http://uche.ogbuji.net http://4Suite.org http://fourthought.com
Universal Business Language (UBL) - http://www-106.ibm.com/developerworks=
/xml/l
ibrary/x-think16.html
EXSLT by example - http://www-106.ibm.com/developerworks/library/x-exslt.=
html
The worry about program wizards - http://www.adtmag.com/article.asp?id=3D=
7238
Use rdf:about and rdf:ID effectively in RDF/XML - http://www-106.ibm.com/=
develo
perworks/xml/library/x-tiprdfai.html
Keep context straight in XSLT - http://www-106.ibm.com/developerworks/xml=
/libra
ry/x-tipcurrent.html
Python Generators + DOM - http://www.xml.com/pub/a/2003/01/08/py-xml.html=
Using SAX for Proper XML Output - http://www.xml.com/pub/a/2003/03/12/py-=
xml.ht
ml
SAX filters for flexible processing - http://www-106.ibm.com/developerwor=
ks/xml
/library/x-tipsaxflex.html