public class EntityReferenceImpl extends ParentNode implements EntityReference
An XML processor has the alternative of fully expanding Entities into the normal document tree. If it does so, no EntityReference nodes will appear.
Similarly, non-validating XML processors are not required to read or process entity declarations made in the external subset or declared in external parameter entities. Hence, some applications may not make the replacement value available for Parsed Entities of these types.
EntityReference behaves as a read-only node, and the children of the EntityReference (which reflect those of the Entity, and should also be read-only) give its replacement value, if any. They are supposed to automagically stay in synch if the DocumentType is updated with new values for the Entity.
The defined behavior makes efficient storage difficult for the DOM implementor. We can't just look aside to the Entity's definition in the DocumentType since those nodes have the wrong parent (unless we can come up with a clever "imaginary parent" mechanism). We must at least appear to clone those children... which raises the issue of keeping the reference synchronized with its parent. This leads me back to the "cached image of centrally defined data" solution, much as I dislike it.
For now I have decided, since REC-DOM-Level-1-19980818 doesn't cover this in much detail, that synchronization doesn't have to be considered while the user is deep in the tree. That is, if you're looking within one of the EntityReferennce's children and the Entity changes, you won't be informed; instead, you will continue to access the same object -- which may or may not still be part of the tree. This is the same behavior that obtains elsewhere in the DOM if the subtree you're looking at is deleted from its parent, so it's acceptable here. (If it really bothers folks, we could set things up so deleted subtrees are walked and marked invalid, but that's not part of the DOM's defined behavior.)
As a result, only the EntityReference itself has to be aware of changes in the Entity. And it can take advantage of the same structure-change-monitoring code I implemented to support DeepNodeList.
| Modifier and Type | Field and Description |
|---|---|
protected String |
name
Name of Entity referenced
|
firstChild, fNodeListCache, ownerDocumentnextSibling_, previousSibling_DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_IS_CONTAINED, DOCUMENT_POSITION_PRECEDING, FIRSTCHILD, HASSTRING, ID, NORMALIZED, OWNED, ownerNode_, READONLY, SPECIFIED, SYNCCHILDRENATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE| Constructor and Description |
|---|
EntityReferenceImpl(CoreDocumentImpl ownerDoc,
String name) |
| Modifier and Type | Method and Description |
|---|---|
Node |
cloneNode(boolean deep)
Returns a duplicate of a given node.
|
String |
getBaseURI()
The absolute base URI of this node or
null if undefined. |
protected String |
getEntityRefValue()
NON-DOM: compute string representation of the entity reference.
|
String |
getNodeName()
the name of this node.
|
short |
getNodeType()
A short integer indicating what type of node this is.
|
protected void |
synchronizeChildren()
Override this method in subclass to hook in efficient internal data
structure.
|
getChildNodes, getChildNodesUnoptimized, getFirstChild, getLastChild, getLength, getOwnerDocument, getTextContent, hasChildNodes, insertBefore, isEqualNode, item, removeChild, replaceChild, setOwnerDocument, setTextContentgetNextSibling, getParentNode, getPreviousSiblingaddEventListener, appendChild, changed, changes, compareDocumentPosition, dispatchEvent, getAttributes, getFeature, getLocalName, getNamespaceURI, getNodeNumber, getNodeValue, getPrefix, getUserData, hasAttributes, isDefaultNamespace, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, needsSyncChildren, normalize, removeEventListener, setNodeValue, setPrefix, setUserData, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitappendChild, compareDocumentPosition, getAttributes, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserDataprotected final String name
public EntityReferenceImpl(CoreDocumentImpl ownerDoc, String name)
public short getNodeType()
getNodeType in interface NodegetNodeType in class NodeImplpublic String getNodeName()
getNodeName in interface NodegetNodeName in class NodeImplpublic Node cloneNode(boolean deep)
Note: since we never have any children deep is meaningless here, ParentNode overrides this behavior. Returns a duplicate of a given node. You can consider this a generic "copy constructor" for nodes. The newly returned object should be completely independent of the source object's subtree, so changes in one after the clone has been made will not affect the other.
Note: since we never have any children deep is meaningless here, ParentNode overrides this behavior. Returns a duplicate of a given node. You can consider this a generic "copy constructor" for nodes. The newly returned object should be completely independent of the source object's subtree, so changes in one after the clone has been made will not affect the other.
Example: Cloning a Text node will copy both the node and the text it contains.
Example: Cloning something that has children -- Element or Attr, for example -- will _not_ clone those children unless a "deep clone" has been requested. A shallow clone of an Attr node will yield an empty Attr of the same name.
NOTE: Clones will always be read/write, even if the node being cloned is read-only, to permit applications using only the DOM API to obtain editable copies of locked portions of the tree. Clone node.
cloneNode in interface NodecloneNode in class ParentNode
Example: Cloning a Text node will copy both the node and the text it
contains.
Example: Cloning something that has children -- Element or Attr, for
example -- will _not_ clone those children unless a "deep clone" has
been requested. A shallow clone of an Attr node will yield an empty Attr
of the same name.
NOTE: Clones will always be read/write, even if the node being cloned is
read-only, to permit applications using only the DOM API to obtain
editable copies of locked portions of the tree.
public String getBaseURI()
null if undefined. This
value is computed according to . However, when the Document
supports the feature "HTML" , the base URI is computed using first the value
of the href attribute of the HTML BASE element if any, and the value of the
documentURI attribute from the Document interface
otherwise. Element, a Document or a a
ProcessingInstruction, this attribute represents the properties
[base URI] defined in . When the node is a Notation, an
Entity, or an EntityReference, this attribute
represents the properties [declaration base URI] in the . How will this be
affected by resolution of relative namespace URIs issue?It's not.Should this
only be on Document, Element, ProcessingInstruction, Entity, and Notation
nodes, according to the infoset? If not, what is it equal to on other nodes?
Null? An empty string? I think it should be the parent's.No.Should this be
read-only and computed or and actual read-write attribute?Read-only and
computed (F2F 19 Jun 2000 and teleconference 30 May 2001).If the base HTML
element is not yet attached to a document, does the insert change the
Document.baseURI? Yes. (F2F 26 Sep 2001)
Returns the absolute base URI of this node or null if the implementation
wasn't able to obtain an absolute URI. Note: If the URI is malformed, a null
is returned.getBaseURI in interface NodegetBaseURI in class NodeImplprotected String getEntityRefValue()
protected void synchronizeChildren()
synchronizeChildren in class ParentNodeCopyright © 2024 HtmlUnit. All rights reserved.