java.lang.Object | |||||
↳ | org.apache.xerces.dom.NodeImpl | ||||
↳ | org.apache.xerces.dom.ChildNode | ||||
↳ | org.apache.xerces.dom.ParentNode | ||||
↳ | org.apache.xerces.dom.CoreDocumentImpl | ||||
↳ | org.apache.xerces.dom.DocumentImpl |
Known Direct Subclasses |
The Document interface represents the entire HTML or XML document. Conceptually, it is the root of the document tree, and provides the primary access to the document's data.
Since elements, text nodes, comments, processing instructions, etc. cannot exist outside the context of a Document, the Document interface also contains the factory methods needed to create these objects. The Node objects created have a ownerDocument attribute which associates them with the Document within whose context they were created.
The DocumentImpl class also implements the DOM Level 2 DocumentTraversal interface. This interface is comprised of factory methods needed to create NodeIterators and TreeWalkers. The process of creating NodeIterator objects also adds these references to this document. After finishing with an iterator it is important to remove the object using the remove methods in this implementation. This allows the release of the references from the iterator objects to the DOM Nodes.
Note: When any node in the document is serialized, the entire document is serialized along with it.@xerces.internal
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.xerces.dom.NodeImpl
| |||||||||||
From interface
org.w3c.dom.Node
|
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
eventListeners | Table for event listeners registered to this document nodes. | ||||||||||
iterators | Iterators | ||||||||||
mutationEvents | Bypass mutation events firing. | ||||||||||
ranges | Ranges |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.xerces.dom.CoreDocumentImpl
| |||||||||||
From class
org.apache.xerces.dom.ParentNode
| |||||||||||
From class
org.apache.xerces.dom.ChildNode
| |||||||||||
From class
org.apache.xerces.dom.NodeImpl
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
NON-DOM: Actually creating a Document is outside the DOM's spec,
since it has to operate in terms of a particular implementation.
| |||||||||||
Constructor.
| |||||||||||
For DOM2 support.
| |||||||||||
For DOM2 support.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Deep-clone a document, including fixing ownerDoc for the cloned
children.
| |||||||||||
Introduced in DOM Level 2.
| |||||||||||
Create and return a NodeIterator.
| |||||||||||
NON-DOM extension:
Create and return a NodeIterator.
| |||||||||||
NON-DOM extension:
Create and return a TreeWalker.
| |||||||||||
Create and return a TreeWalker.
| |||||||||||
Retrieve information describing the abilities of this particular
DOM implementation.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Introduced in DOM Level 2.
| |||||||||||
NON-DOM INTERNAL: Generate the "aggregated" post-mutation events
DOMAttrModified and DOMSubtreeModified.
| |||||||||||
NON-DOM INTERNAL: Convenience wrapper for calling
dispatchAggregateEvents when the context was established
by
savedEnclosingAttr . | |||||||||||
Introduced in DOM Level 2.
| |||||||||||
NON-DOM INTERNAL: DOMNodeInsertedIntoDocument and ...RemovedFrom...
| |||||||||||
Dispatches event to the target node's descendents recursively
| |||||||||||
Retreive event listener registered on a given node
| |||||||||||
Introduced in DOM Level 2.
| |||||||||||
NON-DOM INTERNAL: Pre-mutation context check, in
preparation for later generating DOMAttrModified events.
| |||||||||||
Store event listener registered on a given node
This is another place where we could use weak references! Indeed, the
node here won't be GC'ed as long as some listener is registered on it,
since the eventsListeners table will have a reference to the node.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.xerces.dom.CoreDocumentImpl
| |||||||||||
From class
org.apache.xerces.dom.ParentNode
| |||||||||||
From class
org.apache.xerces.dom.ChildNode
| |||||||||||
From class
org.apache.xerces.dom.NodeImpl
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.w3c.dom.Document
| |||||||||||
From interface
org.w3c.dom.Node
| |||||||||||
From interface
org.w3c.dom.NodeList
| |||||||||||
From interface
org.w3c.dom.events.DocumentEvent
| |||||||||||
From interface
org.w3c.dom.events.EventTarget
| |||||||||||
From interface
org.w3c.dom.ranges.DocumentRange
| |||||||||||
From interface
org.w3c.dom.traversal.DocumentTraversal
|
Bypass mutation events firing.
NON-DOM: Actually creating a Document is outside the DOM's spec, since it has to operate in terms of a particular implementation.
Constructor.
For DOM2 support. The createDocument factory method is in DOMImplementation.
For DOM2 support.
Deep-clone a document, including fixing ownerDoc for the cloned children. Note that this requires bypassing the WRONG_DOCUMENT_ERR protection. I've chosen to implement it by calling importNode which is DOM Level 2.
deep | boolean, iff true replicate children |
---|
Introduced in DOM Level 2. Optional.
Create and return Event objects.
type | The eventType parameter specifies the type of Event interface to be created. If the Event interface specified is supported by the implementation this method will return a new Event of the interface type requested. If the Event is to be dispatched via the dispatchEvent method the appropriate event init method must be called after creation in order to initialize the Event's values. As an example, a user wishing to synthesize some kind of Event would call createEvent with the parameter "Events". The initEvent method could then be called on the newly created Event to set the specific type of Event to be dispatched and set its context information. |
---|
DOMException | NOT_SUPPORTED_ERR: Raised if the implementation does not support the type of Event interface requested |
---|
Create and return a NodeIterator. The NodeIterator is added to a list of NodeIterators so that it can be removed to free up the DOM Nodes it references.
root | The root of the iterator. |
---|---|
whatToShow | The whatToShow mask. |
filter | The NodeFilter installed. Null means no filter. |
entityReferenceExpansion | true to expand the contents of EntityReference nodes |
NON-DOM extension: Create and return a NodeIterator. The NodeIterator is added to a list of NodeIterators so that it can be removed to free up the DOM Nodes it references.
root | The root of the iterator. |
---|---|
whatToShow | The whatToShow mask. |
filter | The NodeFilter installed. Null means no filter. |
NON-DOM extension: Create and return a TreeWalker.
root | The root of the iterator. |
---|---|
whatToShow | The whatToShow mask. |
filter | The NodeFilter installed. Null means no filter. |
Create and return a TreeWalker.
root | The root of the iterator. |
---|---|
whatToShow | The whatToShow mask. |
filter | The NodeFilter installed. Null means no filter. |
entityReferenceExpansion | true to expand the contents of EntityReference nodes |
Retrieve information describing the abilities of this particular DOM implementation. Intended to support applications that may be using DOMs retrieved from several different sources, potentially with different underlying representations.
Introduced in DOM Level 2.
Register an event listener with this Node. A listener may be independently registered as both Capturing and Bubbling, but may only be registered once per role; redundant registrations are ignored.
node | node to add listener to |
---|---|
type | Event name (NOT event group!) to listen for. |
listener | Who gets called when event is dispatched |
useCapture | True iff listener is registered on capturing phase rather than at-target or bubbling |
NON-DOM INTERNAL: Generate the "aggregated" post-mutation events DOMAttrModified and DOMSubtreeModified. Both of these should be issued only once for each user-requested mutation operation, even if that involves multiple changes to the DOM. For example, if a DOM operation makes multiple changes to a single Attr before returning, it would be nice to generate only one DOMAttrModified, and multiple changes over larger scope but within a recognizable single subtree might want to generate only one DOMSubtreeModified, sent to their lowest common ancestor.
To manage this, use the "internal" versions of insert and remove with MUTATION_LOCAL, then make an explicit call to this routine at the higher level. Some examples now exist in our code.
node | The node to dispatch to |
---|---|
enclosingAttr | The Attr node (if any) whose value has been changed as a result of the DOM operation. Null if none such. |
oldvalue | The String value previously held by the enclosingAttr. Ignored if none such. |
change | Type of modification to the attr. See MutationEvent.attrChange |
NON-DOM INTERNAL: Convenience wrapper for calling
dispatchAggregateEvents when the context was established
by savedEnclosingAttr
.
node | node to dispatch to |
---|---|
ea | description of Attr affected by current operation |
Introduced in DOM Level 2.
Distribution engine for DOM Level 2 Events.
Event propagation runs as follows:
Note that registration of handlers during processing of an event does not take effect during this phase of this event; they will not be called until the next time this node is visited by dispatchEvent. On the other hand, removals take effect immediately.
If an event handler itself causes events to be dispatched, they are processed synchronously, before processing resumes on the event which triggered them. Please be aware that this may result in events arriving at listeners "out of order" relative to the actual sequence of requests.
Note that our implementation resets the event's stop/prevent flags when dispatch begins. I believe the DOM's intent is that event objects be redispatchable, though it isn't stated in those terms.
node | node to dispatch to |
---|---|
event | the event object to be dispatched to registered EventListeners |
preventDefault()
method was invoked by an EventListener; otherwise false.
NON-DOM INTERNAL: DOMNodeInsertedIntoDocument and ...RemovedFrom... are dispatched to an entire subtree. This is the distribution code therefor. They DO NOT bubble, thanks be, but may be captured.
Similar to code in dispatchingEventToSubtree however this method is only used on the target node and does not start a dispatching chain on the sibling of the target node as this is not part of the subtree ***** At the moment I'm being sloppy and using the normal capture dispatcher on every node. This could be optimized hugely by writing a capture engine that tracks our position in the tree to update the capture chain without repeated chases up to root.
n | target node (that was directly inserted or removed) |
---|---|
e | event to be sent to that node and its subtree |
Dispatches event to the target node's descendents recursively
n | node to dispatch to |
---|---|
e | event to be sent to that node and its subtree |
Introduced in DOM Level 2.
Deregister an event listener previously registered with this Node. A listener must be independently removed from the Capturing and Bubbling roles. Redundant removals (of listeners not currently registered for this role) are ignored.
node | node to remove listener from |
---|---|
type | Event name (NOT event group!) to listen for. |
listener | Who gets called when event is dispatched |
useCapture | True iff listener is registered on capturing phase rather than at-target or bubbling |
NON-DOM INTERNAL: Pre-mutation context check, in preparation for later generating DOMAttrModified events. Determines whether this node is within an Attr
node | node to get enclosing attribute for |
---|
Store event listener registered on a given node This is another place where we could use weak references! Indeed, the node here won't be GC'ed as long as some listener is registered on it, since the eventsListeners table will have a reference to the node.