Different XML APIs and object models handle entity references fairly differently:
true
(default), then the parser will expand entity references and the resulting DOM tree simply contains the nodes resulting from this expansion. If this property is set to false
, then the parser will still expand entity references, but the resulting DOM tree will contain {@link EntityReference} nodes, the children of which representthe nodes resulting from this expansion. Note that since an entity declaration may contain markup, the children of an {@link EntityReference} node may have a type other than{@link Node#TEXT_NODE}. Application code not interested in entity references will generally set {@link DocumentBuilderFactory#setExpandEntityReferences(boolean) expandEntityReferences} totrue
in order to avoid the additional programming logic required to process {@link EntityReference} nodes.false
. Note that in SAX there is no corresponding configuration property. This makes sense because an application not interested in entity references can simply ignore the {@link LexicalHandler#startEntity(String)} and {@link LexicalHandler#endEntity(String)} events ornot register a {@link LexicalHandler} at all.
|
|
|
|