The DOMDocument
interface represents the entire XML document.
More...
#include <DOMDocument.hpp>
Public Member Functions | |
Destructor | |
virtual | ~DOMDocument () |
Destructor. | |
Functions introduced in DOM Level 1 | |
virtual DOMElement * | createElement (const XMLCh *tagName)=0 |
Creates an element of the type specified. | |
virtual DOMDocumentFragment * | createDocumentFragment ()=0 |
Creates an empty DOMDocumentFragment object. | |
virtual DOMText * | createTextNode (const XMLCh *data)=0 |
Creates a DOMText node given the specified string. | |
virtual DOMComment * | createComment (const XMLCh *data)=0 |
Creates a DOMComment node given the specified string. | |
virtual DOMCDATASection * | createCDATASection (const XMLCh *data)=0 |
Creates a DOMCDATASection node whose value is the specified string. | |
virtual DOMProcessingInstruction * | createProcessingInstruction (const XMLCh *target, const XMLCh *data)=0 |
Creates a DOMProcessingInstruction node given the specified name and data strings. | |
virtual DOMAttr * | createAttribute (const XMLCh *name)=0 |
Creates an DOMAttr of the given name. | |
virtual DOMEntityReference * | createEntityReference (const XMLCh *name)=0 |
Creates an DOMEntityReference object. | |
virtual DOMDocumentType * | getDoctype () const =0 |
The Document Type Declaration (see DOMDocumentType ) associated with this document. | |
virtual DOMImplementation * | getImplementation () const =0 |
The DOMImplementation object that handles this document. | |
virtual DOMElement * | getDocumentElement () const =0 |
This is a convenience attribute that allows direct access to the child node that is the root element of the document. | |
virtual DOMNodeList * | getElementsByTagName (const XMLCh *tagname) const =0 |
Returns a DOMNodeList of all the DOMElement(s) with a given tag name in the order in which they are encountered in a preorder traversal of the DOMDocument tree. | |
Functions introduced in DOM Level 2. | |
virtual DOMNode * | importNode (const DOMNode *importedNode, bool deep)=0 |
Imports a node from another document to this document. | |
virtual DOMElement * | createElementNS (const XMLCh *namespaceURI, const XMLCh *qualifiedName)=0 |
Creates an element of the given qualified name and namespace URI. | |
virtual DOMAttr * | createAttributeNS (const XMLCh *namespaceURI, const XMLCh *qualifiedName)=0 |
Creates an attribute of the given qualified name and namespace URI. | |
virtual DOMNodeList * | getElementsByTagNameNS (const XMLCh *namespaceURI, const XMLCh *localName) const =0 |
Returns a DOMNodeList of all the DOMElement(s) with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of the DOMDocument tree. | |
virtual DOMElement * | getElementById (const XMLCh *elementId) const =0 |
Returns the DOMElement whose ID is given by elementId . | |
Functions introduced in DOM Level 3. | |
virtual const XMLCh * | getInputEncoding () const =0 |
An attribute specifying the encoding used for this document at the time of the parsing. | |
virtual const XMLCh * | getXmlEncoding () const =0 |
An attribute specifying, as part of the XML declaration, the encoding of this document. | |
virtual bool | getXmlStandalone () const =0 |
An attribute specifying, as part of the XML declaration, whether this document is standalone. | |
virtual void | setXmlStandalone (bool standalone)=0 |
An attribute specifying, as part of the XML declaration, whether this document is standalone. | |
virtual const XMLCh * | getXmlVersion () const =0 |
An attribute specifying, as part of the XML declaration, the version number of this document. | |
virtual void | setXmlVersion (const XMLCh *version)=0 |
An attribute specifying, as part of the XML declaration, the version number of this document. | |
virtual const XMLCh * | getDocumentURI () const =0 |
The location of the document or null if undefined. | |
virtual void | setDocumentURI (const XMLCh *documentURI)=0 |
The location of the document or null if undefined. | |
virtual bool | getStrictErrorChecking () const =0 |
An attribute specifying whether errors checking is enforced or not. | |
virtual void | setStrictErrorChecking (bool strictErrorChecking)=0 |
An attribute specifying whether errors checking is enforced or not. | |
virtual DOMNode * | renameNode (DOMNode *n, const XMLCh *namespaceURI, const XMLCh *qualifiedName)=0 |
Rename an existing node. | |
virtual DOMNode * | adoptNode (DOMNode *source)=0 |
Changes the ownerDocument of a node, its children, as well as the attached attribute nodes if there are any. | |
virtual void | normalizeDocument ()=0 |
This method acts as if the document was going through a save and load cycle, putting the document in a "normal" form. | |
virtual DOMConfiguration * | getDOMConfig () const =0 |
The configuration used when DOMDocument::normalizeDocument is invoked. | |
Non-standard extension | |
virtual DOMEntity * | createEntity (const XMLCh *name)=0 |
Non-standard extension. | |
virtual DOMDocumentType * | createDocumentType (const XMLCh *name)=0 |
Non-standard extension. | |
virtual DOMDocumentType * | createDocumentType (const XMLCh *qName, const XMLCh *, const XMLCh *) |
virtual DOMNotation * | createNotation (const XMLCh *name)=0 |
Non-standard extension. | |
virtual DOMElement * | createElementNS (const XMLCh *namespaceURI, const XMLCh *qualifiedName, const XMLFileLoc lineNum, const XMLFileLoc columnNum)=0 |
Non-standard extension. | |
Protected Member Functions | |
Hidden constructors | |
DOMDocument () |
The DOMDocument
interface represents the entire 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 DOMDocument
, the DOMDocument
interface also contains the factory methods needed to create these objects. The DOMNode
objects created have a ownerDocument
attribute which associates them with the DOMDocument
within whose context they were created.
See also the Document Object Model (DOM) Level 2 Core Specification.
xercesc::DOMDocument::DOMDocument | ( | ) | [inline, protected] |
virtual xercesc::DOMDocument::~DOMDocument | ( | ) | [inline, virtual] |
Destructor.
Changes the ownerDocument
of a node, its children, as well as the attached attribute nodes if there are any.
If the node has a parent it is first removed from its parent child list. This effectively allows moving a subtree from one document to another. The following list describes the specifics for each type of node.
ownerElement
attribute is set to null
and the specified
flag is set to true
on the adopted DOMAttr
. The descendants of the source DOMAttr
are recursively adopted. DOMDocument
nodes cannot be adopted. DOMDocumentType
nodes cannot be adopted. DOMAttr
nodes. Default attributes are discarded, though if the document being adopted into defines default attributes for this element name, those are assigned. The descendants of the source element are recursively adopted. DOMEntity
nodes cannot be adopted. DOMEntityReference
node itself is adopted, the descendants are discarded, since the source and destination documents might have defined the entity differently. If the document being imported into provides a definition for this entity name, its value is assigned. DOMNotation
nodes cannot be adopted. source | The node to move into this document. |
null
if this operation fails, such as when the source node comes from a different implementation. DOMException | NOT_SUPPORTED_ERR: Raised if the source node is of type DOCUMENT , DOCUMENT_TYPE . NO_MODIFICATION_ALLOWED_ERR: Raised when the source node is readonly. |
virtual DOMAttr* xercesc::DOMDocument::createAttribute | ( | const XMLCh * | name | ) | [pure virtual] |
Creates an DOMAttr
of the given name.
Note that the DOMAttr
instance can then be set on an DOMElement
using the setAttributeNode
method.
To create an attribute with a qualified name and namespace URI, use the createAttributeNS
method.
name | The name of the attribute. |
DOMAttr
object with the nodeName
attribute set to name
, and localName
, prefix
, and namespaceURI
set to null
. The value of the attribute is the empty string. DOMException | INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character. |
virtual DOMAttr* xercesc::DOMDocument::createAttributeNS | ( | const XMLCh * | namespaceURI, | |
const XMLCh * | qualifiedName | |||
) | [pure virtual] |
Creates an attribute of the given qualified name and namespace URI.
namespaceURI | The namespace URI of the attribute to create. | |
qualifiedName | The qualified name of the attribute to instantiate. |
DOMAttr
object with the following attributes:
|
|
| qualifiedName |
|
|
| prefix, extracted from |
| local name, extracted from |
|
|
| the empty string |
DOMException | INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character, per the XML 1.0 specification . NAMESPACE_ERR: Raised if the qualifiedName is malformed per the Namespaces in XML specification, if the qualifiedName has a prefix and the namespaceURI is null , if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from "
http://www.w3.org/XML/1998/namespace", or if the qualifiedName , or its prefix, is "xmlns" and the namespaceURI is different from "
http://www.w3.org/2000/xmlns/". NOT_SUPPORTED_ERR: Always thrown if the current document does not support the "XML" feature, since namespaces were defined by XML. |
virtual DOMCDATASection* xercesc::DOMDocument::createCDATASection | ( | const XMLCh * | data | ) | [pure virtual] |
Creates a DOMCDATASection
node whose value is the specified string.
data | The data for the DOMCDATASection contents. |
DOMCDATASection
object. virtual DOMComment* xercesc::DOMDocument::createComment | ( | const XMLCh * | data | ) | [pure virtual] |
Creates a DOMComment
node given the specified string.
data | The data for the node. |
DOMComment
object. virtual DOMDocumentFragment* xercesc::DOMDocument::createDocumentFragment | ( | ) | [pure virtual] |
Creates an empty DOMDocumentFragment
object.
DOMDocumentFragment
. virtual DOMDocumentType* xercesc::DOMDocument::createDocumentType | ( | const XMLCh * | qName, | |
const XMLCh * | , | |||
const XMLCh * | ||||
) | [inline, virtual] |
virtual DOMDocumentType* xercesc::DOMDocument::createDocumentType | ( | const XMLCh * | name | ) | [pure virtual] |
Non-standard extension.
Create a DOMDocumentType node.
DOMDocumentType
that references the newly created DOMDocumentType node. virtual DOMElement* xercesc::DOMDocument::createElement | ( | const XMLCh * | tagName | ) | [pure virtual] |
Creates an element of the type specified.
Note that the instance returned implements the DOMElement
interface, so attributes can be specified directly on the returned object.
In addition, if there are known attributes with default values, DOMAttr
nodes representing them are automatically created and attached to the element.
To create an element with a qualified name and namespace URI, use the createElementNS
method.
tagName | The name of the element type to instantiate. For XML, this is case-sensitive. |
DOMElement
object with the nodeName
attribute set to tagName
, and localName
, prefix
, and namespaceURI
set to null
. DOMException | INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character. |
virtual DOMElement* xercesc::DOMDocument::createElementNS | ( | const XMLCh * | namespaceURI, | |
const XMLCh * | qualifiedName, | |||
const XMLFileLoc | lineNum, | |||
const XMLFileLoc | columnNum | |||
) | [pure virtual] |
Non-standard extension.
Creates an element of the given qualified name and namespace URI, and also stores line/column number info. Used by internally XSDXercesDOMParser during schema traversal.
virtual DOMElement* xercesc::DOMDocument::createElementNS | ( | const XMLCh * | namespaceURI, | |
const XMLCh * | qualifiedName | |||
) | [pure virtual] |
Creates an element of the given qualified name and namespace URI.
namespaceURI | The namespace URI of the element to create. | |
qualifiedName | The qualified name of the element type to instantiate. |
DOMElement
object with the following attributes:
|
|
|
|
|
|
| prefix, extracted from |
| local name, extracted from |
|
|
DOMException | INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character, per the XML 1.0 specification . NAMESPACE_ERR: Raised if the qualifiedName is malformed per the Namespaces in XML specification, if the qualifiedName has a prefix and the namespaceURI is null , or if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from "
http://www.w3.org/XML/1998/namespace" . NOT_SUPPORTED_ERR: Always thrown if the current document does not support the "XML" feature, since namespaces were defined by XML. |
virtual DOMEntity* xercesc::DOMDocument::createEntity | ( | const XMLCh * | name | ) | [pure virtual] |
Non-standard extension.
Create a new entity.
name | The name of the entity to instantiate |
virtual DOMEntityReference* xercesc::DOMDocument::createEntityReference | ( | const XMLCh * | name | ) | [pure virtual] |
Creates an DOMEntityReference
object.
In addition, if the referenced entity is known, the child list of the DOMEntityReference
node is made the same as that of the corresponding DOMEntity
node.If any descendant of the DOMEntity
node has an unbound namespace prefix, the corresponding descendant of the created DOMEntityReference
node is also unbound; (its namespaceURI
is null
). The DOM Level 2 does not support any mechanism to resolve namespace prefixes.
name | The name of the entity to reference. |
DOMEntityReference
object. DOMException | INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character. |
virtual DOMNotation* xercesc::DOMDocument::createNotation | ( | const XMLCh * | name | ) | [pure virtual] |
Non-standard extension.
Create a Notation.
name | The name of the notation to instantiate |
DOMNotation
that references the newly created DOMNotation node. virtual DOMProcessingInstruction* xercesc::DOMDocument::createProcessingInstruction | ( | const XMLCh * | target, | |
const XMLCh * | data | |||
) | [pure virtual] |
Creates a DOMProcessingInstruction
node given the specified name and data strings.
target | The target part of the processing instruction. | |
data | The data for the node. |
DOMProcessingInstruction
object. DOMException | INVALID_CHARACTER_ERR: Raised if the specified target contains an illegal character. |
virtual DOMText* xercesc::DOMDocument::createTextNode | ( | const XMLCh * | data | ) | [pure virtual] |
Creates a DOMText
node given the specified string.
data | The data for the node. |
DOMText
object. virtual DOMDocumentType* xercesc::DOMDocument::getDoctype | ( | ) | const [pure virtual] |
The Document Type Declaration (see DOMDocumentType
) associated with this document.
For XML documents without a document type declaration this returns null
. The DOM Level 2 does not support editing the Document Type Declaration. docType
cannot be altered in any way, including through the use of methods inherited from the DOMNode
interface, such as insertNode
or removeNode
.
virtual DOMElement* xercesc::DOMDocument::getDocumentElement | ( | ) | const [pure virtual] |
This is a convenience attribute that allows direct access to the child node that is the root element of the document.
virtual const XMLCh* xercesc::DOMDocument::getDocumentURI | ( | ) | const [pure virtual] |
The location of the document or null
if undefined.
Beware that when the DOMDocument
supports the feature "HTML" , the href attribute of the HTML BASE element takes precedence over this attribute.
virtual DOMConfiguration* xercesc::DOMDocument::getDOMConfig | ( | ) | const [pure virtual] |
The configuration used when DOMDocument::normalizeDocument is invoked.
DOMConfiguration
from this DOMDocument
virtual DOMElement* xercesc::DOMDocument::getElementById | ( | const XMLCh * | elementId | ) | const [pure virtual] |
Returns the DOMElement
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
. 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
.
elementId | The unique id value for an element. |
virtual DOMNodeList* xercesc::DOMDocument::getElementsByTagName | ( | const XMLCh * | tagname | ) | const [pure virtual] |
Returns a DOMNodeList
of all the DOMElement(s)
with a given tag name in the order in which they are encountered in a preorder traversal of the DOMDocument
tree.
The returned node list is "live", in that changes to the document tree made after a nodelist was initially returned will be immediately reflected in the node list.
tagname | The name of the tag to match on. The special value "*" matches all tags. |
DOMNodeList
object containing all the matched DOMElement(s)
. virtual DOMNodeList* xercesc::DOMDocument::getElementsByTagNameNS | ( | const XMLCh * | namespaceURI, | |
const XMLCh * | localName | |||
) | const [pure virtual] |
Returns a DOMNodeList
of all the DOMElement(s)
with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of the DOMDocument
tree.
namespaceURI | The namespace URI of the elements to match on. The special value "*" matches all namespaces. | |
localName | The local name of the elements to match on. The special value "*" matches all local names. |
DOMNodeList
object containing all the matched DOMElement(s)
. virtual DOMImplementation* xercesc::DOMDocument::getImplementation | ( | ) | const [pure virtual] |
The DOMImplementation
object that handles this document.
A DOM application may use objects from multiple implementations.
virtual const XMLCh* xercesc::DOMDocument::getInputEncoding | ( | ) | const [pure virtual] |
An attribute specifying the encoding used for this document at the time of the parsing.
This is null
when it is not known, such as when the DOMDocument was created in memory.
virtual bool xercesc::DOMDocument::getStrictErrorChecking | ( | ) | const [pure virtual] |
An attribute specifying whether errors checking is enforced or not.
When set to false
, the implementation is free to not test every possible error case normally defined on DOM operations, and not raise any DOMException
. In case of error, the behavior is undefined. This attribute is true
by defaults.
virtual const XMLCh* xercesc::DOMDocument::getXmlEncoding | ( | ) | const [pure virtual] |
An attribute specifying, as part of the XML declaration, the encoding of this document.
This is null
when unspecified or when it is not known, such as when the DOMDocument was created in memory.
virtual bool xercesc::DOMDocument::getXmlStandalone | ( | ) | const [pure virtual] |
An attribute specifying, as part of the XML declaration, whether this document is standalone.
This is false
when unspecified.
virtual const XMLCh* xercesc::DOMDocument::getXmlVersion | ( | ) | const [pure virtual] |
An attribute specifying, as part of the XML declaration, the version number of this document.
This is null
when unspecified.
This attribute represents the property [version] defined in .
virtual DOMNode* xercesc::DOMDocument::importNode | ( | const DOMNode * | importedNode, | |
bool | deep | |||
) | [pure virtual] |
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 DOMNode
, 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 source was copied from one document to another, recognizing that the two documents may have different DTDs in the XML case. The following list describes the specifics for each type of node.
ownerElement
attribute is set to null
and the specified
flag is set to true
on the generated DOMAttr
. The descendants of the source DOMAttr
are recursively imported and the resulting nodes reassembled to form the corresponding subtree. Note that the deep
parameter has no effect on DOMAttr
nodes; they always carry their children with them when imported. deep
option was set to true
, the descendants of the source element are recursively imported and the resulting nodes reassembled to form the corresponding subtree. Otherwise, this simply generates an empty DOMDocumentFragment
. DOMDocument
nodes cannot be imported. DOMDocumentType
nodes cannot be imported. DOMAttr
nodes are attached to the generated DOMElement
. Default attributes are not copied, though if the document being imported into defines default attributes for this element name, those are assigned. If the importNode
deep
parameter was set to true
, the descendants of the source element are recursively imported and the resulting nodes reassembled to form the corresponding subtree. DOMEntity
nodes can be imported, however in the current release of the DOM the DOMDocumentType
is readonly. Ability to add these imported nodes to a DOMDocumentType
will be considered for addition to a future release of the DOM.On import, the publicId
, systemId
, and notationName
attributes are copied. If a deep
import is requested, the descendants of the the source DOMEntity
are recursively imported and the resulting nodes reassembled to form the corresponding subtree. DOMEntityReference
itself is copied, even if a deep
import is requested, since the source and destination documents might have defined the entity differently. If the document being imported into provides a definition for this entity name, its value is assigned. DOMNotation
nodes can be imported, however in the current release of the DOM the DOMDocumentType
is readonly. Ability to add these imported nodes to a DOMDocumentType
will be considered for addition to a future release of the DOM.On import, the publicId
and systemId
attributes are copied. Note that the deep
parameter has no effect on DOMNotation
nodes since they never have any children. target
and data
values from those of the source node. DOMCharacterData
copy their data
and length
attributes from those of the source node. importedNode | The node to import. | |
deep | If true , recursively import the subtree under the specified node; if false , import only the node itself, as explained above. This has no effect on DOMAttr , DOMEntityReference , and DOMNotation nodes. |
DOMDocument
. DOMException | NOT_SUPPORTED_ERR: Raised if the type of node being imported is not supported. |
virtual void xercesc::DOMDocument::normalizeDocument | ( | ) | [pure virtual] |
This method acts as if the document was going through a save and load cycle, putting the document in a "normal" form.
The actual result depends on the features being set. See DOMConfiguration
for details.
Noticeably this method normalizes DOMText
nodes, makes the document "namespace wellformed", according to the algorithm described below in pseudo code, by adding missing namespace declaration attributes and adding or changing namespace prefixes, updates the replacement tree of DOMEntityReference
nodes, normalizes attribute values, etc.
Mutation events, when supported, are generated to reflect the changes occuring on the document. Note that this is a partial implementation. Not all the required features are implemented. Currently DOMAttr
and DOMText
nodes are normalized. Features to remove DOMComment
and DOMCDATASection
work.
virtual DOMNode* xercesc::DOMDocument::renameNode | ( | DOMNode * | n, | |
const XMLCh * | namespaceURI, | |||
const XMLCh * | qualifiedName | |||
) | [pure virtual] |
Rename an existing node.
When possible this simply changes the name of the given node, otherwise this creates a new node with the specified name and replaces the existing node with the new node as described below. This only applies to nodes of type ELEMENT_NODE
and ATTRIBUTE_NODE
.
When a new node is created, the following operations are performed: the new node is created, any registered event listener is registered on the new node, any user data attached to the old node is removed from that node, the old node is removed from its parent if it has one, the children are moved to the new node, if the renamed node is an DOMElement
its attributes are moved to the new node, the new node is inserted at the position the old node used to have in its parent's child nodes list if it has one, the user data that was attached to the old node is attach to the new node, the user data event NODE_RENAMED
is fired.
When the node being renamed is an DOMAttr
that is attached to an DOMElement
, the node is first removed from the DOMElement
attributes map. Then, once renamed, either by modifying the existing node or creating a new one as described above, it is put back.
n | The node to rename. | |
namespaceURI | The new namespaceURI. | |
qualifiedName | The new qualified name. |
DOMException | NOT_SUPPORTED_ERR: Raised when the type of the specified node is neither ELEMENT_NODE nor ATTRIBUTE_NODE . WRONG_DOCUMENT_ERR: Raised when the specified node was created from a different document than this document. NAMESPACE_ERR: Raised if the qualifiedName is malformed per the Namespaces in XML specification, if the qualifiedName has a prefix and the namespaceURI is null , or if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from "
http://www.w3.org/XML/1998/namespace" . Also raised, when the node being renamed is an attribute, if the qualifiedName , or its prefix, is "xmlns" and the namespaceURI is different from "http://www.w3.org/2000/xmlns/". |
virtual void xercesc::DOMDocument::setDocumentURI | ( | const XMLCh * | documentURI | ) | [pure virtual] |
The location of the document or null
if undefined.
Beware that when the DOMDocument
supports the feature "HTML" , the href attribute of the HTML BASE element takes precedence over this attribute.
virtual void xercesc::DOMDocument::setStrictErrorChecking | ( | bool | strictErrorChecking | ) | [pure virtual] |
An attribute specifying whether errors checking is enforced or not.
When set to false
, the implementation is free to not test every possible error case normally defined on DOM operations, and not raise any DOMException
. In case of error, the behavior is undefined. This attribute is true
by defaults.
virtual void xercesc::DOMDocument::setXmlStandalone | ( | bool | standalone | ) | [pure virtual] |
An attribute specifying, as part of the XML declaration, whether this document is standalone.
This attribute represents the property [standalone] defined in .
virtual void xercesc::DOMDocument::setXmlVersion | ( | const XMLCh * | version | ) | [pure virtual] |
An attribute specifying, as part of the XML declaration, the version number of this document.
This is null
when unspecified.
This attribute represents the property [version] defined in .