class Poco::XML::AbstractNode
Overview
AbstractNode provides a basic implementation of the Node interface for all types of nodes that do not contain other nodes. More…
#include <AbstractNode.h> class AbstractNode: public Poco::XML::Node { public: // methods virtual const XMLString& nodeName() const; virtual const XMLString& getNodeValue() const; virtual void setNodeValue(const XMLString& value); virtual Node* parentNode() const; virtual NodeList* childNodes() const; virtual Node* firstChild() const; virtual Node* lastChild() const; virtual Node* previousSibling() const; virtual Node* nextSibling() const; virtual NamedNodeMap* attributes() const; virtual Document* ownerDocument() const; virtual Node* insertBefore( Node* newChild, Node* refChild ); virtual Node* replaceChild( Node* newChild, Node* oldChild ); virtual Node* removeChild(Node* oldChild); virtual Node* appendChild(Node* newChild); virtual bool hasChildNodes() const; virtual Node* cloneNode(bool deep) const; virtual void normalize(); virtual bool isSupported( const XMLString& feature, const XMLString& version ) const; virtual const XMLString& namespaceURI() const; virtual XMLString prefix() const; virtual const XMLString& localName() const; virtual bool hasAttributes() const; virtual void addEventListener( const XMLString& type, EventListener* listener, bool useCapture ); virtual void removeEventListener( const XMLString& type, EventListener* listener, bool useCapture ); virtual bool dispatchEvent(Event* evt); virtual XMLString innerText() const; virtual Node* getNodeByPath(const XMLString& path) const; virtual Node* getNodeByPathNS( const XMLString& path, const NSMap& nsMap ) const; virtual void autoRelease(); protected: // fields static const XMLString EMPTY_STRING; // construction AbstractNode(Document* pOwnerDocument); AbstractNode( Document* pOwnerDocument, const AbstractNode& node ); // methods virtual Node* copyNode( bool deep, Document* pOwnerDocument ) const = 0; virtual bool events() const; virtual bool eventsSuspended() const; void captureEvent(Event* evt); void bubbleEvent(Event* evt); void dispatchSubtreeModified(); void dispatchNodeInserted(); void dispatchNodeRemoved(); virtual void dispatchNodeRemovedFromDocument(); virtual void dispatchNodeInsertedIntoDocument(); void dispatchAttrModified( Attr* pAttr, MutationEvent::AttrChangeType changeType, const XMLString& prevValue, const XMLString& newValue ); void dispatchCharacterDataModified( const XMLString& prevValue, const XMLString& newValue ); void setOwnerDocument(Document* pOwnerDocument); }; // direct descendants class AbstractContainerNode; class Attr; class CharacterData; class EntityReference; class Notation; class ProcessingInstruction;
Inherited Members
public: // typedefs typedef Poco::XML::NamespaceSupport NSMap; // enums enum { ELEMENT_NODE = 1, ATTRIBUTE_NODE, TEXT_NODE, CDATA_SECTION_NODE, ENTITY_REFERENCE_NODE, ENTITY_NODE, PROCESSING_INSTRUCTION_NODE, COMMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, DOCUMENT_FRAGMENT_NODE, NOTATION_NODE, }; // methods void duplicate() const; void release() const; virtual void autoRelease() = 0; virtual void addEventListener( const XMLString& type, EventListener* listener, bool useCapture ) = 0; virtual void removeEventListener( const XMLString& type, EventListener* listener, bool useCapture ) = 0; virtual bool dispatchEvent(Event* evt) = 0; virtual const XMLString& nodeName() const = 0; const XMLString& nodeValue() const; virtual const XMLString& getNodeValue() const = 0; virtual void setNodeValue(const XMLString& value) = 0; virtual unsigned short nodeType() const = 0; virtual Node* parentNode() const = 0; virtual NodeList* childNodes() const = 0; virtual Node* firstChild() const = 0; virtual Node* lastChild() const = 0; virtual Node* previousSibling() const = 0; virtual Node* nextSibling() const = 0; virtual NamedNodeMap* attributes() const = 0; virtual Document* ownerDocument() const = 0; virtual Node* insertBefore( Node* newChild, Node* refChild ) = 0; virtual Node* replaceChild( Node* newChild, Node* oldChild ) = 0; virtual Node* removeChild(Node* oldChild) = 0; virtual Node* appendChild(Node* newChild) = 0; virtual bool hasChildNodes() const = 0; virtual Node* cloneNode(bool deep) const = 0; virtual void normalize() = 0; virtual bool isSupported( const XMLString& feature, const XMLString& version ) const = 0; virtual const XMLString& namespaceURI() const = 0; virtual XMLString prefix() const = 0; virtual const XMLString& localName() const = 0; virtual bool hasAttributes() const = 0; virtual XMLString innerText() const = 0; virtual Node* getNodeByPath(const XMLString& path) const = 0; virtual Node* getNodeByPathNS( const XMLString& path, const NSMap& nsMap ) const = 0;
Detailed Documentation
AbstractNode provides a basic implementation of the Node interface for all types of nodes that do not contain other nodes.
Methods
virtual const XMLString& nodeName() const
Returns the name of this node, depending on its type.
virtual const XMLString& getNodeValue() const
Returns the value of this node, depending on its type.
virtual void setNodeValue(const XMLString& value)
Sets the value of this node.
Throws an exception if the node is read-only.
virtual Node* parentNode() const
The parent of this node.
All nodes, except Attr, Document, DocumentFragment, Entity, and Notation may have a parent. However, if a node has just been created and not yet added to the tree, or if it has been removed from the tree, this is null.
virtual NodeList* childNodes() const
Returns a NodeList containing all children of this node.
The returned NodeList must be released with a call to release() when no longer needed.
virtual Node* firstChild() const
Returns the first child of this node.
If there is no such node, this returns null.
virtual Node* lastChild() const
Returns the last child of this node.
If there is no such node, this returns null.
virtual Node* previousSibling() const
Returns the node immediately preceding this node.
If there is no such node, this returns null.
virtual Node* nextSibling() const
Returns the node immediately following this node.
If there is no such node, this returns null.
virtual NamedNodeMap* attributes() const
Returns a NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.
The returned NamedNodeMap must be released with a call to release() when no longer needed.
virtual Document* ownerDocument() const
Returns the Document object associated with this node.
This is also the Document object used to create new nodes. When this node is a Document, this is null.
virtual Node* insertBefore( Node* newChild, Node* refChild )
Inserts the node newChild before the existing child node refChild.
If refChild is null, insert newChild at the end of the list of children. If newChild is a DocumentFragment object, all of its children are inserted in the same order, before refChild. If the newChild is already in the tree, it is first removed.
virtual Node* replaceChild( Node* newChild, Node* oldChild )
Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node.
If newChild is a DocumentFragment object, oldChild is replaced by all of the DocumentFragment children, which are inserted in the same order. If the newChild is already in the tree, it is first removed.
virtual Node* removeChild(Node* oldChild)
Removes the child node indicated by oldChild from the list of children and returns it.
virtual Node* appendChild(Node* newChild)
Appends the node newChild to the end of the list of children of this node.
If newChild is already in the tree, it is first removed.
virtual bool hasChildNodes() const
This is a convenience method to allow easy determination of whether a node has any children.
Returns true if the node has any children, false otherwise.
virtual Node* cloneNode(bool deep) const
Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes.
The duplicate node has no parent; (parentNode is null.). Cloning an Element copies all attributes and their values, including those generated by the XML processor to represent defaulted attributes, but this method does not copy any text it contains unless it is a deep clone, since the text is contained in a child Text node. Cloning an Attribute directly, as opposed to be cloned as part of an Element cloning operation, returns a specified attribute (specified is true). Cloning any other type of node simply returns a copy of this node. Note that cloning an immutable subtree results in a mutable copy, but the children of an EntityReference clone are readonly. In addition, clones of unspecified Attr nodes are specified. And, cloning Document, DocumentType, Entity, and Notation nodes is implementation dependent.
virtual void normalize()
Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a “normal” form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes.
This can be used to ensure that the DOM view of a document is the same as if it were saved and re-loaded, and is useful when operations (such as XPointer lookups) that depend on a particular document tree structure are to be used.
Note: In cases where the document contains CDATASections, the normalize operation alone may not be sufficient, since XPointers do not differentiate between Text nodes and CDATASection nodes.
virtual bool isSupported( const XMLString& feature, const XMLString& version ) const
Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.
virtual const XMLString& namespaceURI() const
Returns the namespace URI of the node.
This is not a computed value that is the result of a namespace lookup based on an examination of the namespace declarations in scope. It is merely the namespace URI given at creation time.
For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always the empty string.
virtual XMLString prefix() const
Returns the namespace prefix from the qualified name of the node.
virtual const XMLString& localName() const
Returns the local name of the node.
virtual bool hasAttributes() const
Returns whether this node (if it is an element) has any attributes.
virtual void addEventListener( const XMLString& type, EventListener* listener, bool useCapture )
This method allows the registration of event listeners on the event target.
If an EventListener is added to an EventTarget while it is processing an event, it will not be triggered by the current actions but may be triggered during a later stage of event flow, such as the bubbling phase. If multiple identical EventListeners are registered on the same EventTarget with the same parameters the duplicate instances are discarded. They do not cause the EventListener to be called twice and since they are discarded they do not need to be removed with the removeEventListener method.
virtual void removeEventListener( const XMLString& type, EventListener* listener, bool useCapture )
This method allows the removal of event listeners from the event target.
If an EventListener is removed from an EventTarget while it is processing an event, it will not be triggered by the current actions. EventListeners can never be invoked after being removed. Calling removeEventListener with arguments which do not identify any currently registered EventListener on the EventTarget has no effect.
virtual bool dispatchEvent(Event* evt)
This method allows the dispatch of events into the implementations event model.
Events dispatched in this manner will have the same capturing and bubbling behavior as events dispatched directly by the implementation. The target of the event is the EventTarget on which dispatchEvent is called.
virtual XMLString innerText() const
Returns a string containing the concatenated values of the node and all its child nodes.
This method is not part of the W3C Document Object Model.
virtual Node* getNodeByPath(const XMLString& path) const
Searches a node (element or attribute) based on a simplified XPath expression.
Only simple XPath expressions are supported. These are the slash notation for specifying paths to elements, and the square bracket expression for finding elements by their index, by attribute value, or finding attributes by names.
The slash at the beginning is optional, the evaluation always starts at this element. A double-slash at the beginning recursively searches the entire subtree for the first element.
Examples:
elem1/elem2/elem3 /elem1/elem2/elem3 /elem1/elem2[1] /elem1/elem2[@attr1] /elem1/elem2[@attr1='value'] //elem2[@attr1='value'] //[@attr1='value']
This method is an extension to the W3C Document Object Model.
virtual Node* getNodeByPathNS( const XMLString& path, const NSMap& nsMap ) const
Searches a node (element or attribute) based on a simplified XPath expression.
The given NSMap must contain mappings from namespace prefixes to namespace URIs for all namespace prefixes used in the path expression.
Only simple XPath expressions are supported. These are the slash notation for specifying paths to elements, and the square bracket expression for finding elements by their index, by attribute value, or finding attributes by names.
The slash at the beginning is optional, the evaluation always starts at this element. A double-slash at the beginning recursively searches the entire subtree for the first element.
Examples:
/ns1:elem1/ns2:elem2/ns2:elem3 /ns1:elem1/ns2:elem2[1] /ns1:elem1/ns2:elem2[@attr1] /ns1:elem1/ns2:elem2[@attr1='value'] //ns2:elem2[@ns1:attr1='value'] //[@ns1:attr1='value']
This method is an extension to the W3C Document Object Model.
virtual void autoRelease()
Adds the object to an appropriate AutoReleasePool, which is usually the AutoReleasePool managed by the Document to which this object belongs.