[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

  • From: "Ernest G. Allen" <ernestgallen@e...>
  • To: jamesm@b..., xml-dev@l...
  • Date: Sat, 20 Oct 2001 11:50:46 -0700

perl xml
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!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.