class Poco::XML::AbstractContainerNode

Overview

AbstractContainerNode is an implementation of Node that stores and manages child nodes. More…

#include <AbstractContainerNode.h>

class AbstractContainerNode: public Poco::XML::AbstractNode
{
public:
    // methods

    virtual
    Node*
    firstChild() const;

    virtual
    Node*
    lastChild() 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
    bool
    hasAttributes() const;

    virtual
    Node*
    getNodeByPath(const XMLString& path) const;

    virtual
    Node*
    getNodeByPathNS(
        const XMLString& path,
        const NSMap& nsMap
        ) const;

protected:
    // construction

    AbstractContainerNode(Document* pOwnerDocument);

    AbstractContainerNode(
        Document* pOwnerDocument,
        const AbstractContainerNode& node
        );

    // methods

    virtual
    void
    dispatchNodeRemovedFromDocument();

    virtual
    void
    dispatchNodeInsertedIntoDocument();

    bool
    hasAttributeValue(
        const XMLString& name,
        const XMLString& value,
        const NSMap* pNSMap
        ) const;

    static
    const Node*
    findNode(
        XMLString::const_iterator& it,
        const XMLString::const_iterator& end,
        const Node* pNode,
        const NSMap* pNSMap
        );

    static
    const Node*
    findElement(
        const XMLString& name,
        const Node* pNode,
        const NSMap* pNSMap
        );

    static
    const Node*
    findElement(
        int index,
        const Node* pNode,
        const NSMap* pNSMap
        );

    static
    const Node*
    findElement(
        const XMLString& attr,
        const XMLString& value,
        const Node* pNode,
        const NSMap* pNSMap
        );

    static
    const Attr*
    findAttribute(
        const XMLString& name,
        const Node* pNode,
        const NSMap* pNSMap
        );

    static
    bool
    namesAreEqual(
        const Node* pNode1,
        const Node* pNode2,
        const NSMap* pNSMap
        );

    static
    bool
    namesAreEqual(
        const Node* pNode,
        const XMLString& name,
        const NSMap* pNSMap
        );
};

// direct descendants

class Document;
class DocumentFragment;
class DocumentType;
class Element;
class Entity;

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;

    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;

    // 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);

Detailed Documentation

AbstractContainerNode is an implementation of Node that stores and manages child nodes.

Child nodes are organized in a single linked list.

Methods

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*
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
bool
hasAttributes() const

Returns whether this node (if it is an element) has any attributes.

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.