[Expat-discuss] Discussion: InternalEntityRefHandler

Karl Waclawek karl@waclawek.net
Tue Jun 11 13:15:06 2002


We plan to add an InternalEntityRefHandler for release 1.95.4.
Among other reasons, such a handler would make Expat more fully
SAX compliant.

If you have any ideas about it, please say so.

Here is what we have so far:

An internal entity reference handler should probably
do two things:

1) pass name, entity value and entity type (PE or GE)
2) allow the application to return a value that
   indicates if the entity should be expanded or not

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 ignoring the entity automatically.

Here are a few problems that need to be resolved:

1) There is possible interference with the SetDefaultHandler
and SetDefaulthandlerExpand functions. The former will
turn off expansion of internal general entities.
However, this could now also be done with the InternalEntityRefHandler.
So, what happens when expansion is turned off?

Personally, I don't like to have such a feature as a side-effect
of setting a handler. My vote would go for having only
one function - SetDefaultHandler - *and* removing the influence
it has on internal entity expansion completely.
The InternalEntityRefHandler could deal with that on a per-call basis.

2) How does that work with the skippedEntityHandler if
the InternalEntityRefHandler returns with a value indicating
that the entity reference should be ignored?

To be consistent with the ExternalEntityRefhandler, it should
 be the application's job to deal with it, since this handler
has no way of telling the parser that the external entity has been skipped.
In other words - we should not delegate the skipped entity notification
back to Expat, if we are the ones generating the event in the first place.

The skippedEntityHandler should only be invoked when the parser
comes across an undefined entity and this is *not* an error
(which can only happen for non-validating parsers).

Comments welcome,

Karl