[XML-SIG] Repost - disabling entity expansion

Bill Eldridge bill@rfa.org
Tue, 17 Dec 2002 11:16:30 -0500

Okay, as I slipped in a note in the repost,
I do have a solution in libxml2-python that
follows, so I guess I'll live with that, thanks.


import libxml2
import sys
import string

ctxt = libxml2.createFileParserCtxt("efd_1.xml")
print "VF1:",doc.docEntity("vf1").serialize()
print "ENTITY %s: %s" % (ent,entfull)

Uche Ogbuji wrote:

>>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
>I didn't respond to this because I don't know the answer.  I don't think there 
>is a simple way to disable entity expansion from the internal subset, because 
>I don't know of any XML parsers that offer this option.  Maybe Xerces does?  
>After all, DOM does keep entity ref stuff around and I think Xerces is the 
>strictest DOM implementation out there, which means the undrlying parser 
>probably reports all lexical entities, rather than just those that need 
>I don't know that there is an easy solution for you, though.