Package org.apache.axiom.om
Interface OMEntityReference
- All Superinterfaces:
OMInformationItem
,OMNode
,OMSerializable
Represents an unexpanded entity reference in an XML document.
Different XML APIs and object models handle entity references fairly differently:
- In DOM, the way entity references in an XML document are processed depends on the setting for
expandEntityReferences
. If this property is set totrue
(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 tofalse
, then the parser will still expand entity references, but the resulting DOM tree will containEntityReference
nodes, the children of which represent the nodes resulting from this expansion. Note that since an entity declaration may contain markup, the children of anEntityReference
node may have a type other thanNode.TEXT_NODE
. Application code not interested in entity references will generally setexpandEntityReferences
totrue
in order to avoid the additional programming logic required to processEntityReference
nodes. - In SAX, the parser will always expand entity references and report the events resulting from
this expansion to the
ContentHandler
. In addition to that, if aLexicalHandler
is registered, then the parser will report the start and end of the expansion usingLexicalHandler.startEntity(String)
andLexicalHandler.endEntity(String)
. This means that the processing of entity references in SAX is similar to DOM withexpandEntityReferences
set tofalse
. Note that in SAX there is no corresponding configuration property. This makes sense because an application not interested in entity references can simply ignore theLexicalHandler.startEntity(String)
andLexicalHandler.endEntity(String)
events or not register aLexicalHandler
at all. - In StAX, the way entity references are processed depends on the setting for the
XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES
property. If this property is set to true (default), then the parser will expand entity references and report only the events resulting from that expansion. If the property is set to false, then the parser no longer expands entity references. Instead, it will report each entity reference using a singleXMLStreamConstants.ENTITY_REFERENCE
event.XMLStreamReader.getText()
can then be used to get the replacement value for the entity. Note that this replacement value may contain unparsed markup. One can see that the way StAX reports entity references is significantly different than DOM or SAX.
-
Field Summary
Fields inherited from interface org.apache.axiom.om.OMNode
CDATA_SECTION_NODE, COMMENT_NODE, DTD_NODE, ELEMENT_NODE, ENTITY_REFERENCE_NODE, PI_NODE, SPACE_NODE, TEXT_NODE
-
Method Summary
Modifier and TypeMethodDescriptiongetName()
Get the name of the referenced entity.Get the replacement value for this entity reference.Methods inherited from interface org.apache.axiom.om.OMInformationItem
clone, getOMFactory
Methods inherited from interface org.apache.axiom.om.OMNode
buildWithAttachments, detach, discard, getNextOMSibling, getParent, getPreviousOMSibling, getType, insertSiblingAfter, insertSiblingBefore
Methods inherited from interface org.apache.axiom.om.OMSerializable
build, close, isComplete, serialize, serialize, serializeAndConsume
-
Method Details
-
getName
String getName()Get the name of the referenced entity.- Returns:
- the name of the entity
-
getReplacementText
String getReplacementText()Get the replacement value for this entity reference. Note that the replacement value is a simple string and may therefore contain unparsed markup.- Returns:
- the replacement value, or
null
if the replacement value is not available
-