[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Perl XML::Parser and nested external entity references
At 2:54 PM -0700 2001-10-19, D.J. Miller II wrote: (snipped) (Ernest G. Allen wrote...) >> but how about pushing the old base immediately upon entry to >> ExternEnt and popping it just before exit? That would do >> the popping at the same point that the ExternEntFin hook in >> the newer version would be used. (D.J. Miller II wrote...) > >This wouldn't quite work. These callbacks are called serially in time >but are not recursive (on a stack); the ExternEntFin hook gets called >after the ExternEnt hook has returned. > I guess I wasn't being precise when I wrote "That would do the popping at the same point that the ExternEntFin hook in the newer version would be used." I wasn't precise about inside the ExternEnt (at its very end, just before it returns) and just after the return from ExternEnt. Sorry for any confusion. (D.J. Miller II wrote... > >Actually I had it wrong, too. To keep track of this you'd have to push >the base location each time you enter an external entity reference, >apply this base to each sysid found in external entity *declarations* >found in this reference (and then stash the result for each declaration >for subsequent use), and then pop the base upon exit from the reference. > That's what I meant, except that the popping is inside your ExternEnt, at its very end. (D.J. Miller II wrote... > >The mechanisms for this roll-you-own scheme aren't all quite there in >2.27 (no ExternEntFin hook, so you don't know when to pop the base) or, >apparently, in 2.28 either (which does have the ExternEntFin hook, and >which reports general entity declarations but, unlike 2.27, not >parameter entity declarations to the Entity handler -- maybe there's a >grungier way to catch the parameter entity declarations that I couldn't >find). > Doing the popping inside ExternEnt, just before return, avoids the need for ExternEntFin. Roughly something like this, using a global "stack" array. sub ExternEnt { 1. push old base 2. set new base 3. process 4. pop old base 5. return } If ExternEnt is called during "3. process" the base set in "2. set new base" will be pushed by "1. push old base" in the recursive invocation of ExternEnt. (snipped) /s/ Ernest G. Allen Sunnyvale, CA, USA
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|