Library: XML
Package: DOM
Header: Poco/DOM/Document.h
Description
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.
Inheritance
Direct Base Classes: AbstractContainerNode, DocumentEvent
All Base Classes: AbstractContainerNode, AbstractNode, DOMObject, DocumentEvent, EventTarget, Node
Member Summary
Member Functions: autoReleasePool, collectGarbage, copyNode, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntity, createEntityReference, createEvent, createNotation, createProcessingInstruction, createTextNode, dispatchEvent, doctype, documentElement, events, eventsSuspended, getDoctype, getElementById, getElementByIdNS, getElementsByTagName, getElementsByTagNameNS, implementation, importNode, namePool, nodeName, nodeType, resumeEvents, setDoctype, suspendEvents
Inherited Functions: addEventListener, appendChild, attributes, autoRelease, bubbleEvent, captureEvent, childNodes, cloneNode, copyNode, createEvent, dispatchAttrModified, dispatchCharacterDataModified, dispatchEvent, dispatchNodeInserted, dispatchNodeInsertedIntoDocument, dispatchNodeRemoved, dispatchNodeRemovedFromDocument, dispatchSubtreeModified, duplicate, events, eventsSuspended, findAttribute, findElement, findNode, firstChild, getNodeByPath, getNodeByPathNS, getNodeValue, hasAttributeValue, hasAttributes, hasChildNodes, innerText, insertAfterNP, insertBefore, isSupported, lastChild, localName, namesAreEqual, namespaceURI, nextSibling, nodeName, nodeType, nodeValue, normalize, ownerDocument, parentNode, prefix, previousSibling, release, removeChild, removeEventListener, replaceChild, setNodeValue, setOwnerDocument
Types Aliases
AutoReleasePool
using AutoReleasePool = Poco::AutoReleasePool < DOMObject >;
Constructors
Document
explicit Document(
NamePool * pNamePool = 0
);
Creates a new document. If pNamePool == 0, the document creates its own name pool, otherwise it uses the given name pool. Sharing a name pool makes sense for documents containing instances of the same schema, thus reducing memory usage.
Document
explicit Document(
unsigned long namePoolSize
);
Creates a new document using a name pool with the given size, which should be a prime number (e.g., 251, 509, 1021, 4093).
Document
Document(
DocumentType * pDocumentType,
NamePool * pNamePool = 0
);
Creates a new document. If pNamePool == 0, the document creates its own name pool, otherwise it uses the given name pool. Sharing a name pool makes sense for documents containing instances of the same schema, thus reducing memory usage.
Document
Document(
DocumentType * pDocumentType,
unsigned long namePoolSize
);
Creates a new document using a name pool with the given size, which should be a prime number (e.g., 251, 509, 1021, 4093).
Destructor
~Document
~Document();
Member Functions
autoReleasePool
AutoReleasePool & autoReleasePool();
Returns a pointer to the documents Auto Release Pool.
collectGarbage
void collectGarbage();
Releases all objects in the Auto Release Pool.
createAttribute
Attr * createAttribute(
const XMLString & name
) const;
Creates an Attr of the given name. Note that the Attr instance can then be set on an Element using the setAttributeNode method.
createAttributeNS
Attr * createAttributeNS(
const XMLString & namespaceURI,
const XMLString & qualifiedName
) const;
Creates an attribute of the given qualified name and namespace URI.
createCDATASection
CDATASection * createCDATASection(
const XMLString & data
) const;
Creates a CDATASection node whose value is the specified string.
createComment
Comment * createComment(
const XMLString & data
) const;
Creates a comment node given the specified string.
createDocumentFragment
DocumentFragment * createDocumentFragment() const;
Creates an empty DocumentFragment object.
createElement
Element * createElement(
const XMLString & tagName
) const;
Creates an element of the type specified. Note that the instance returned implements the Element interface, so attributes can be specified directly on the returned object.
In addition, if there are known attributes with default values, Attr nodes representing them are automatically created and attached to the element.
createElementNS
Element * createElementNS(
const XMLString & namespaceURI,
const XMLString & qualifiedName
) const;
Creates an element of the given qualified name and namespace URI.
createEntity
Entity * createEntity(
const XMLString & name,
const XMLString & publicId,
const XMLString & systemId,
const XMLString & notationName
) const;
Creates an Entity with the given name, publicId, systemId and notationName.
This method is not part of the W3C Document Object Model.
createEntityReference
EntityReference * createEntityReference(
const XMLString & name
) const;
Creates an EntityReference object. In addition, if the referenced entity is known, the child list of the EntityReference node is made the same as that of the corresponding Entity node.
createEvent
Event * createEvent(
const XMLString & eventType
) const;
See also: Poco::XML::DocumentEvent::createEvent()
createNotation
Notation * createNotation(
const XMLString & name,
const XMLString & publicId,
const XMLString & systemId
) const;
Creates a Notation with the given name, publicId and systemId.
This method is not part of the W3C Document Object Model.
createProcessingInstruction
ProcessingInstruction * createProcessingInstruction(
const XMLString & target,
const XMLString & data
) const;
Creates a ProcessingInstruction node given the specified target and data strings.
createTextNode
Text * createTextNode(
const XMLString & data
) const;
Creates a text node given the specified string.
dispatchEvent
bool dispatchEvent(
Event * evt
);
See also: Poco::XML::AbstractNode::dispatchEvent()
doctype
const DocumentType * doctype() const;
The Document Type Declaration (see DocumentType) associated with this document. For HTML documents as well as XML documents without a document type declaration this returns null. The DOM Level 1 does not support editing the Document Type Declaration. docType cannot be altered in any way, including through the use of methods inherited from the Node interface, such as insertNode or removeNode.
documentElement
Element * documentElement() const;
This is a convenience attribute that allows direct access to the child node that is the root element of the document. For HTML documents, this is the element with the tagName "HTML".
events
bool events() const;
Returns true if events are not suspended.
See also: Poco::XML::AbstractNode::events()
eventsSuspended
bool eventsSuspended() const;
Returns true if events are suspended.
getElementById
Element * getElementById(
const XMLString & elementId
) const;
Returns the Element whose ID is given by elementId. If no such element exists, returns null. Behavior is not defined if more than one element has this ID.
Note: The DOM implementation must have information that says which attributes are of type ID. Attributes with the name "ID" are not of type ID unless so defined. Implementations that do not know whether attributes are of type ID or not are expected to return null. This implementation therefore returns null.
See also the non-standard two argument variant of getElementById() and getElementByIdNS().
getElementById
Element * getElementById(
const XMLString & elementId,
const XMLString & idAttribute
) const;
Returns the first Element whose ID attribute (given in idAttribute) has the given elementId. If no such element exists, returns null.
This method is an extension to the W3C Document Object Model.
getElementByIdNS
Element * getElementByIdNS(
const XMLString & elementId,
const XMLString & idAttributeURI,
const XMLString & idAttributeLocalName
) const;
Returns the first Element whose ID attribute (given in idAttributeURI and idAttributeLocalName) has the given elementId. If no such element exists, returns null.
This method is an extension to the W3C Document Object Model.
getElementsByTagName
NodeList * getElementsByTagName(
const XMLString & name
) const;
Returns a NodeList of all Elements with a given tag name in the order in which they would be encountered in a preorder traversal of the document tree.
The returned NodeList must be released with a call to release() when no longer needed.
getElementsByTagNameNS
NodeList * getElementsByTagNameNS(
const XMLString & namespaceURI,
const XMLString & localName
) const;
Returns a NodeList of all the Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of the Document tree.
implementation
const DOMImplementation & implementation() const;
The DOMImplementation object that handles this document. A DOM application may use objects from multiple implementations.
importNode
Node * importNode(
Node * importedNode,
bool deep
);
Imports a node from another document to this document. The returned node has no parent; (parentNode is null). The source node is not altered or removed from the original document; this method creates a new copy of the source node. For all nodes, importing a node creates a node object owned by the importing document, with attribute values identical to the source node's nodeName and nodeType, plus the attributes related to namespaces (prefix, localName, and namespaceURI). As in the cloneNode operation on a Node, the source node is not altered. Additional information is copied as appropriate to the nodeType, attempting to mirror the behavior expected if a fragment of XML or HTML source was copied from one document to another, recognizing that the two documents may have different DTDs in the XML case.
namePool
NamePool & namePool();
Returns a pointer to the documents Name Pool.
nodeName
const XMLString & nodeName() const;
See also: Poco::XML::AbstractNode::nodeName()
nodeType
unsigned short nodeType() const;
See also: Poco::XML::Node::nodeType()
resumeEvents
void resumeEvents();
Resumes all events suspended with suspendEvent();
suspendEvents
void suspendEvents();
Suspends all events until resumeEvents() is called.
copyNode
Node * copyNode(
bool deep,
Document * pOwnerDocument
) const;
See also: Poco::XML::AbstractNode::copyNode()
getDoctype
DocumentType * getDoctype();
setDoctype
void setDoctype(
DocumentType * pDoctype
);