[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.
#!/usr/bin/python2
import libxml2
import sys
import string
ctxt = libxml2.createFileParserCtxt("efd_1.xml")
ctxt.validate(1)
ctxt.parseDocument()
doc=ctxt.doc()
valid=ctxt.isValid()
print "VF1:",doc.docEntity("vf1").serialize()
atts=doc.docEntity("vf1").serialize().split()
ent,entfull=atts[1],string.join(atts[2:])
print "ENTITY %s: %s" % (ent,entfull)
sys.exit()
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
>><v_function>&vf1;</v_function>
>>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
>resolution.
>
>I don't know that there is an easy solution for you, though.
>
>
>
>