Re: Question about Entity and EntityReferance again.

Mike Champion wrote:

> At 12:15 PM 8/20/98 +0900, KAZUMI Saito wrote:
> >
> >I want to implement Entity and EntityReference as "Entity has expanded entity
> >as its children and EntityReference dosen't have children only have entity
> name".
>
> Not quite, but I think you can achieve your objectives and still be DOM
> compliant.

I believe you are correct that there is no wiggle room on this point as it
currently stands.

For Entity, the spec says:

"The structure of the child list is exactly the same as the structure of the child
list for an EntityReference with the same nodeName value."

and for EntityReference, the spec says:

"XML does not mandate that a non-validating XML processor read and process entity
declarations made in the external subset or declared in external parameter
entities. This means that parsed entities declared in the external subset need not
be expanded by some classes of applications, and that the replacement value of the
entity may not be available."

If iterators became available in the future that could keep track of traversal in
and especially back out of shared entities (since they have no parent), it might
be nice to allow a mode where shared entities (and perhaps default attributes as
well) were not replicated in the hierarchy.

> Any implementation is legal so long as it preserves the DOM interfaces.
> The DOM API "presents the illusion" that all expanded entity references
> have the subtree that would result from parsing the entity replacement text
> as its children.  Since the DOM Level 1 does not allow entity declarations
> to be edited, these subtrees can be shared by all references to the same
> entity, I believe.  The implementation would have to get tricky to handle
> the getParent() method on the top of this subtree so that it navigated back
> to the EntityReference rather than the Entity, but other than that, I don't
> see a problem *physically* hanging the subtree off Entity and having
> EntityReference point back to the Entity.  BUT this has to be hidden from
> the DOM user, who will *see* the EntityReference as having the expansion as
> its children.

I do not believe that nodes can be directly shared in this way, because
getParentNode() on such nodes would not return the EntityReference.  I do a
similar thing, but with proxy objects that hide the real shared objects behind the
scenes.  I wish it were possible to do this without proxies at every shared node,
but I don't see how.

Ray Whitmer

Received on Thursday, 20 August 1998 12:36:49 UTC