#16 predefined entities...


Co-workers and myself have found it useful to be able
to disable the expansion of default entities under
certain circumstances. For example, in a pipeline
such as:
app1 | app2 | app3

you only want app3 to actually expand default
entities, otherwise you'll get wellformedness (is that
a word ?:) errors if you have a character handler

A buddy of mine actually hacked the xmltok_impl code
and recompiled (which works quite well), but I decided
to take a stab at providing a function/runtime means
of changing this behavior.

The attached patch compiles, runs, and it produces the
expected results against my test cases.

changes include:
* new func decl in expat.h (or expat.h.in I suppose)
* a few mods to xmlparse.c



  • Fred L. Drake, Jr.

    Logged In: YES

    Assigned to me since I'm interested in something similar.

    Would you consider is acceptable to get a callback for all references to internal entities? I'd like to have an event for internal entities defined in the internal subset and predefined entities like "lt" & friends. You should be able to use a handler for that to present the output you require as well. This would be useful when building a DOM or generating a SAX event stream that contains all the little niggly details.

  • Fred L. Drake, Jr.

    • assigned_to: nobody --> fdrake
  • David MacCormack

    Logged In: YES

    Hi Fred. So if I'm following you, you'd define an
    XML_InternalEntityRefHandler callback -- or perhaps
    deprecate the current XML_ExternalEntityRefHandler and
    simply define a generic XML_EntityRefHandler, combining
    them as you did with XML_EntityDeclHandler -- as well as
    the accompanying XML_Set??? function. And, if the user has
    set a callback, that will be called for each reference;
    otherwise, the current behavior will be done (as not to
    break existing code). Is that the gist?

    It's far more functionality than we (www.bna.com) need, but
    if (as you say) you want a generic solution that would
    allow the user to take any action (such as building a DOM),
    then it looks good to me... go for it :)!

  • Karl Waclawek

    Karl Waclawek - 2002-06-01

    Logged In: YES

    Joining this discussion late:

    An internal entity reference handler should probably
    do two things:

    1) pass name and entity value
    2) allow the application to return a value
    that indicates: skip that entity

    The second one is necessary, since - contrary
    to the external entity ref handler, the entity value
    is already determined, whereas in the external
    entity ref handler it is the handler that "creates"
    that data, so by doing nothing it achieves the
    effect of skipping automatically.

    Such a handler would also be needed to make Expat
    more fully SAX capable.



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks