[XML-SIG] Repost - disabling entity expansion

Bill Eldridge bill@rfa.org
Tue, 17 Dec 2002 10:32:20 -0500

I have an element v_function referencing external
entities &vf1; &vf2; and &vf3;

<!ELEMENT v_function (#PCDATA)>
                       <!ENTITY vf1 "Animal">
                       <!ENTITY vf2 "Vegetable">
                       <!ENTITY vf3 "Mineral">

Sometimes I'd like to expand these entities
as normal, but other times I'd like to select
and get &vf1;  or vf3 returned or
even <!ENTITY vf1 "Animal"> ???

Is there a simple way to disable the entity expansion?
I'm able to do this in libxml2-python but haven't found a way
to do this in pyxml

from xml.dom.ext.reader.Sax2 import FromXmlStream, FromXmlFile, Reader
from xml.sax import xmlreader, make_parser
from xml.sax.handler import feature_external_ges, feature_external_pes

p = make_parser()
#p.setFeature(feature_external_ges, 0)
#p.setFeature(feature_external_pes, 0)
#doc = FromXmlFile("test.xml", parser=p, validate=0)
doc = FromXmlFile("test.xml", parser=p)

for library in doc.getElementsByTagName("v_function"):
 if library.firstChild:
     print library.firstChild.data