W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2000

Re: Example for Entity and EntityReferences

From: <keshlam@us.ibm.com>
Date: Thu, 27 Apr 2000 19:05:42 -0400
To: "'www-dom@w3.org'" <www-dom@w3.org>
Message-ID: <852568CE.007ECF0B.00@D51MTA03.pok.ibm.com>
> Could any one point me to a detailed Example on using Entity and
> EntityReferences.

Entity nodes correspond to General Entity declarations in the DTD. If it's
a parsed or literal entity, the children of the Entity node will correspond
to its value. If it's an Unparsed Entity, retrieving its value is outside
the scope of the DOM.

     <!ENTITY Pub-Status "This is a pre-release of the specification.">

     becomes an Entity node with one Text child containing
     the string "This is a pre-release of the specification."

There's no public API for creating Entity nodes (we'll address that in DOM
Level 3), so they will only exist if (a) you parse a document whose DTD
defines them or (b) you use a nonstandard mechanism to create them.
Similarly, there's no API for editing existing Entity nodes.

EntityReference nodes correspond to Entity References in the instance
document. If there's an Entity node with the same name, the children of an
EntityReference node will be read-only clones of the children of that


     corresponds to an EntityReference node with one Text child containing
     the string "This is a pre-release of the specification."

HOWEVER: Parsers are also allowed to "flatten" references by leaving out
the EntityReference node, and just inserting the read-only entity value at
that point in the document. Sometimes this is more convenient for
applications, sometimes less convenient, depending on whether they need to
know that these nodes came from an entity, so the DOM permits both
approaches. The user-code equivalent would be to manually clone the
Entity's children and insert them at the appropriate place.

Does that help, or have I answered the wrong question?

Joe Kesselman  / IBM Research
Received on Thursday, 27 April 2000 19:06:05 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:07 UTC