Datasheet

33
Xerces
Element
c
Text
[If]text in c but
Entity
Reference
Text
[If]
Element
d
Text
insert this here
Text
[If]
If you look closely at the diagram, you see that the part of the DOM tree for element c has been omitted.
Here’s the rest of it, starting at the Element node for c.
Xerces created an EntityReference node as a child of the Element node (and in the correct order among
its siblings). That EntityReference node then has a child Text node that includes the text expanded
from the entity. This is useful if you want to know that a particular node was an entity reference in
the original document. However, it turns out to be inconvenient if you don’t care whether some text
originated as an entity, because your code has to check for the possibility of EntityReference nodes
as it traverses the tree. If you don’t care about the origin of the text, then you can set the feature
http://apache.org/xml/features/dom/create-entity-ref-nodes to false, and Xerces won’t insert the
EntityReference nodes. Instead, it will put the Text node where the EntityReference node would have
appeared, thus simplifying your application code.
01 543555 Ch01.qxd 11/5/03 9:40 AM Page 33