Menu

#137 Support Pull operation

Feature Request
closed
None
5
2004-07-16
2002-04-16
No

Would it be hard to add the following functions?
- suspend() ...suspends parsing, remembers state
- resume() ...resumes parsing from where it was
suspended
- abort() ...cancels parsing

This looks like the concept of coroutines, and could
have the following benefit: One could implement a
"pull" based parser on top of the "push" based model
of Expat.

This has recently been chosen as Microsoft's new
approach, i.e. in XML.NET, SAX has been replaced by
a pull based parser("XMLReader").

Typical pull code would look like:
while parser.nextNode() do
begin
//process current node
end;

It seems to me such a parser could be implemented on
top of SAX or Expat, if there was functionality as
described above. Microsoft's MSXML3 implementation
has the IMXReaderControl interface, which allows
exactly that. Makes me think that (maybe) MS's "pull"
implementation is implemented on top of their own SAX
parser.

So, my question again: How hard would it be to add
such coroutine-like functionality to Expat?

Karl

Discussion

  • Karl Waclawek

    Karl Waclawek - 2002-07-28
    • assigned_to: nobody --> kwaclaw
     
  • Karl Waclawek

    Karl Waclawek - 2002-07-28

    Logged In: YES
    user_id=290026

    It looks as if I am going to try to port the block/unblock
    functionality from the Mozilla version of Expat.
    Assigned to me because of that.

     
  • Karl Waclawek

    Karl Waclawek - 2003-11-10

    Logged In: YES
    user_id=290026

    Check out patch #835123. If accepted, this should be
    a major step towards fulfilling this feature request.

    The question even is if patch #835123 would not be sufficient,
    as it may be a better approach to implement the actual
    Pull API in the target language that wraps the Expat parser.

    A C-style Pull API would then be only targeted at the
    C-language itself.

    Karl

     
  • Fred L. Drake, Jr.

    Logged In: YES
    user_id=3066

    Note that patch #835123 has been applied to current CVS.

    Karl, it's probably safe to close this.

     
  • Karl Waclawek

    Karl Waclawek - 2004-01-20

    Logged In: YES
    user_id=290026

    Yes, in principle Expat now has the capability to be
    used like a Pull API. However, I als came across the new
    XMLReader pull API implemented in libxml2 (in C), which
    is modelled after the same API in .NET.

    And, as I am working now (slowly) on writing a SAX wrapper
    in C#, I realized that an XMLReader wrapper might be nice too.
    One thing I am not sure about: Implement the Pull API
    wrapper in C#, or implement it in C, and call from C#.
    As far as I can tell, call-backs from C into .NET are quite
    expensive, and calls from .NET into C are not cheap either,
    so a less "chatty" API is better - which would mean that it
    would be better to implement XMLReader in C instead of C#.

     
  • Fred L. Drake, Jr.

    Logged In: YES
    user_id=3066

    The basic requirements are now supported, so I'm closing
    this. Implementing specific APIs on top of the current
    implementation is an exercise for the reader; Expat itself
    should remain small.

     
  • Fred L. Drake, Jr.

    • status: open --> closed
     

Log in to post a comment.