EntityReference (W3C DOM Core object)
var reference = document.createEntityReference('amp');
example above creates an entity reference called amp
which would be written in HTML as
& and decodes
as the entity
EntityReference interface inherits from
Node, and represents an unexpanded entity reference (eg.
EntityReference nodes may
appear in the DOM when an entity reference appears in the source document,
or when inserting new entity references.
themselves are readonly, so the
interface is used to create or modify them.
The DOM does not
require an implementation to expand external entities, hence the
replacement value of an entity reference may not be available; if it is
available it will appear in the
collection of the
Conversely, an implementation may choose to expand all entities before
building the DOM tree, in which case there will be no
EntityReference nodes in the document at all, only
Entity nodes. In practise, this is what happens in all
EntityReference nodes are
expanded before building or modifying the DOM tree, and therefore never
appear in a document.
So this interface is only testable in
browsers which fully implement the
createEntityReference method —
Internet Explorer in XML and
Safari. Since this method should only work in
XML (and should throw an exception in HTML) this is taken to mean that the
interface is fully supported, in both cases. However the method itself has
support caveats which are documented separately (see
There are no comments yet.