# Experimental C++ Language Binding for DOM Level 3

[Back to Readme] [Go to C++ Language Binding for DOM Level 2]

This document contains the Experimental Apache Recommended C++ Language binding for the Document Object Model Level 3.0 Core, and for the subset of Document Object Model Level 3.0 Abstract Schemas and Load and Save. Both are W3C Working Draft of 09 April 2002.

The definitions are divided into Core, and Load and Save. The headers are also available in Xerces-C++ distribution.

Note:

1. Constructor and Destructors are implementation specific
2. String is represented by "XMLCh*" which is a pointer to unsigned 16 bit type holding utf-16 values, null terminated.

- typedef unsigned int XMLCh

3. XMLSize_t is an implementation-dependent unsigned integral type

- typedef size_t XMLSize_t

4. DOMObject is represented as void*
5. C++ Memory Management:

1. A member method "release()" is added for releasing any "orphaned" resources that were created through createXXXX factory method.
2. Memory for any returned object e.g.

- DOMImplementation* getDOMImplementation(const XMLCh* features)
- ... etc.
- are owned by implementation

## Change History

Date | Description
Xerces-C++ 2.0: July 23, 2002 | Created
Xerces-C++ 2.1: August 26, 2002 | Modified - add const modifier to DOMNode::lookupNamespacePrefix - add const modifier to DOMNode::lookupNamespaceURI - add const modifier to DOMNode::isDefaultNamespace

## A: Document Object Mode: Core

### DOMImplementationRegistry.hpp:

class DOMImplementationRegistry

{ |  |  |
| public: |  |
| static | DOMImplementation* | getDOMImplementation(const XMLCh* features);
| static | void | addSource(DOMImplementationSource* source);
}; |  |  |

### DOMException.hpp:

class DOMException

{ |  |  |
| public: |  |
| enum | ExceptionCode { |
|  | INDEX_SIZE_ERR | = 1,
|  | DOMSTRING_SIZE_ERR | = 2,
|  | HIERARCHY_REQUEST_ERR | = 3,
|  | WRONG_DOCUMENT_ERR | = 4,
|  | INVALID_CHARACTER_ERR | = 5,
|  | NO_DATA_ALLOWED_ERR | = 6,
|  | NO_MODIFICATION_ALLOWED_ERR | = 7,
|  | NOT_FOUND_ERR | = 8,
|  | NOT_SUPPORTED_ERR | = 9,
|  | INUSE_ATTRIBUTE_ERR | = 10,
|  | INVALID_STATE_ERR | = 11,
|  | SYNTAX_ERR | = 12,
|  | INVALID_MODIFICATION_ERR | = 13,
|  | NAMESPACE_ERR | = 14,
|  | INVALID_ACCESS_ERR | = 15
|  | VALIDATION_ERR | = 16
| }; |  |
| ExceptionCode | code; |
| const XMLCh* | msg; |
}; |  |  |

### DOMImplementationSource.hpp:

class DOMImplementationSource

{ |  |  |
| public: |  |
| virtual | DOMImplementation* | getDOMImplementation(const XMLCh* features) const = 0;
}; |  |  |

### DOMImplementation.hpp:

class DOMImplementation

{ |  |  |
| public: |  |
| virtual | bool | hasFeature(const XMLCh* feature, const XMLCh* version) = 0;
| virtual | DOMDocumentType* | createDocumentType(const XMLCh* qualifiedName, const XMLCh* publicId, const XMLCh* systemId) = 0;
| virtual | DOMDocument* | createDocument(const XMLCh* namespaceURI, const XMLCh* qualifiedName, DOMDocumentType* doctype) = 0;
| virtual | DOMImplementation* | getInterface(const XMLCh* feature) = 0;
}; |  |  |

### DOMDocumentFragment.hpp:

class DOMDocumentFragment : public DOMNode

{ |  |  |
}; |  |  |

### DOMDocument.hpp:

class DOMDocument : public DOMNode

{ |  |  |
| public: |  |
| virtual | DOMElement* | createElement(const XMLCh* tagName) = 0;
| virtual | DOMDocumentFragment* | createDocumentFragment() = 0;
| virtual | DOMText* | createTextNode(const XMLCh* data) = 0;
| virtual | DOMComment* | createComment(const XMLCh* data) = 0;
| virtual | DOMCDATASection* | createCDATASection(const XMLCh* data) = 0;
| virtual | DOMProcessingInstruction* | createProcessingInstruction(const XMLCh* target, const XMLCh* data) = 0;
| virtual | DOMAttr* | createAttribute(const XMLCh* name) = 0;
| virtual | DOMEntityReference* | createEntityReference(const XMLCh* name) = 0;
| virtual | DOMDocumentType* | getDoctype() const = 0;
| virtual | DOMImplementation* | getImplementation() const = 0;
| virtual | DOMElement* | getDocumentElement() const = 0;
| virtual | DOMNodeList* | getElementsByTagName(const XMLCh* tagname) const = 0;
| virtual | DOMNode* | importNode(DOMNode* importedNode, bool deep) = 0;
| virtual | DOMElement* | createElementNS(const XMLCh* namespaceURI, const XMLCh* qualifiedName) = 0;
| virtual | DOMAttr* | createAttributeNS(const XMLCh* namespaceURI, const XMLCh* qualifiedName) = 0;
| virtual | DOMNodeList* | getElementsByTagNameNS(const XMLCh* namespaceURI, const XMLCh* localName) const = 0;
| virtual | DOMElement* | getElementById(const XMLCh* elementId) const = 0;
| virtual | const XMLCh* | getActualEncoding() const = 0;
| virtual | void | setActualEncoding(const XMLCh* actualEncoding) = 0;
| virtual | const XMLCh* | getEncoding() const = 0;
| virtual | void | setEncoding(const XMLCh* encoding) = 0;
| virtual | bool | getStandalone() const = 0;
| virtual | void | setStandalone(bool standalone) = 0;
| virtual | const XMLCh* | getVersion() const = 0;
| virtual | void | setVersion((const XMLCh* version) = 0;
| virtual | const XMLCh* | getDocumentURI() const = 0;
| virtual | void | setDocumentURI(const XMLCh* documentURI) = 0;
| virtual | bool | getStrictErrorChecking() const = 0;
| virtual | void | setStrictErrorChecking(bool strictErrorChecking) = 0;
| virtual | DOMErrorHandler* | getErrorHandler() const = 0;
| virtual | void | setErrorHandler(DOMErrorHandler* const handler) = 0;
| virtual | DOMNode* | renameNode(DOMNode* n, const XMLCh* namespaceURI, const XMLCh* name) = 0;
| virtual | DOMNode* | adoptNode(DOMNode* source) = 0;
| virtual | void | normalizeDocument() = 0;
| virtual | bool | canSetNormalizationFeature(const XMLCh* const name, bool state) const = 0;
| virtual | void | setNormalizationFeature(const XMLCh* const name, bool state) = 0;
| virtual | bool | getNormalizationFeature(const XMLCh* const name) const = 0;
}; |  |  |

### DOMNode.hpp:

class DOMNode

{ |  |  |
| public: |  |
| enum | NodeType { |
|  | ELEMENT_NODE | = 1,
|  | ATTRIBUTE_NODE | = 2,
|  | TEXT_NODE | = 3,
|  | CDATA_SECTION_NODE | = 4,
|  | ENTITY_REFERENCE_NODE | = 5,
|  | ENTITY_NODE | = 6,
|  | PROCESSING_INSTRUCTION_NODE | = 7,
|  | COMMENT_NODE | = 8,
|  | DOCUMENT_NODE | = 9,
|  | DOCUMENT_TYPE_NODE | = 10,
|  | DOCUMENT_FRAGMENT_NODE | = 11,
|  | NOTATION_NODE | = 12,
| }; |  |
| virtual | const XMLCh* | getNodeName() const = 0;
| virtual | const XMLCh* | getNodeValue() const = 0;
| virtual | short | getNodeType() const = 0;
| virtual | DOMNode* | getParentNode() const = 0;
| virtual | DOMNodeList* | getChildNodes() const = 0;
| virtual | DOMNode* | getFirstChild() const = 0;
| virtual | DOMNode* | getLastChild() const = 0;
| virtual | DOMNode* | getPreviousSibling() const = 0;
| virtual | DOMNode* | getNextSibling() const = 0;
| virtual | DOMNamedNodeMap* | getAttributes() const = 0;
| virtual | DOMDocument* | getOwnerDocument() const = 0;
| virtual | DOMNode* | cloneNode(bool deep) const = 0;
| virtual | DOMNode* | insertBefore(DOMNode* newChild, DOMNode* refChild) = 0;
| virtual | DOMNode* | replaceChild(DOMNode* newChild, DOMNode* oldChild) = 0;
| virtual | DOMNode* | removeChild(DOMNode* oldChild) = 0;
| virtual | DOMNode* | appendChild(DOMNode* newChild) = 0;
| virtual | bool | hasChildNodes() const = 0;
| virtual | void | setNodeValue(const XMLCh *nodeValue) = 0;
| virtual | void | normalize() = 0;
| virtual | bool | isSupported(const XMLCh* feature, const XMLCh* version) const = 0;
| virtual | const XMLCh* | getNamespaceURI() const = 0;
| virtual | const XMLCh* | getPrefix() const = 0;
| virtual | const XMLCh* | getLocalName() const = 0;
| virtual | void | setPrefix(const XMLCh* prefix) = 0;
| virtual | bool | hasAttributes() const = 0;
| virtual | bool | isSameNode(const DOMNode* other) = 0;
| virtual | bool | isEqualNode(const DOMNode* arg) = 0;
| virtual | void* | setUserData(const XMLCh* key, void* data, DOMUserDataHandler* handler) = 0;
| virtual | void* | getUserData(const XMLCh* key) const = 0;
| virtual | const XMLCh* | getBaseURI() const = 0;
| virtual | short | compareTreePosition(DOMNode* other) 0;
| virtual | const XMLCh* | getTextContent() const = 0;
| virtual | void | setTextContent(const XMLCh* textContent) = 0;
| virtual | const XMLCh* | lookupNamespacePrefix(const XMLCh* namespaceURI, bool useDefault) const = 0;
| virtual | bool | isDefaultNamespace(const XMLCh* namespaceURI) const = 0;
| virtual | const XMLCh* | lookupNamespaceURI(const XMLCh* prefix) const = 0;
| virtual | DOMNode* | getInterface(const XMLCh* feature) = 0;
}; |  |  |

//
// Called to indicate that this Node (and its associated children) is no longer in use
// and that the implementation may relinquish any resources associated with it and
// its associated children.
//
// If this is a document, any nodes it owns (created by DOMDocument::createXXXX())
// are also released.
//
// Access to a released object will lead to unexpected result.
//
// @exception DOMException
// INVALID_ACCESS_ERR: Raised if this Node has a parent and thus should not be released yet.
//
virtual void release() = 0;
};

### DOMNodeList.hpp:

class DOMNodeList

{ |  |  |
| public: |  |
| virtual | DOMNode* | item(XMLSize_t index) const = 0;
| virtual | XMLSize_t | getLength() const = 0;
}; |  |  |

### DOMNamedNodeMap.hpp:

class DOMNamedNodeMap

{ |  |  |
| public: |  |
| virtual | DOMNode* | setNamedItem(DOMNode* arg) = 0;
| virtual | DOMNode* | item(XMLSize_t index) const = 0;
| virtual | DOMNode* | getNamedItem(const XMLCh* name) const = 0;
| virtual | XMLSize_t | getLength() const = 0;
| virtual | DOMNode* | removeNamedItem(const XMLCh* name) = 0;
| virtual | DOMNode* | getNamedItemNS(const XMLCh* namespaceURI, const XMLCh* localName) const = 0;
| virtual | DOMNode* | setNamedItemNS(DOMNode* arg) = 0;
| virtual | DOMNode* | removeNamedItemNS(const XMLCh* namespaceURI, const XMLCh* localName) = 0;
}; |  |  |

### DOMCharacterData.hpp:

class DOMCharacterData : public DOMNode

{ |  |  |
| public: |  |
| virtual | const XMLCh* | getData() const = 0;
| virtual | XMLSize_t | getLength() const = 0;
| virtual | const XMLCh* | substringData(XMLSize_t offset, XMLSize_t count) const = 0;
| virtual | void | appendData(const XMLCh* arg) = 0;
| virtual | void | insertData(XMLSize_t offset, const XMLCh* arg) = 0;
| virtual | void | deleteData(XMLSize_t offset, XMLSize_t count) = 0;
| virtual | void | replaceData(XMLSize_t offset, XMLSize_t count, const XMLCh* arg) = 0;
| virtual | void | setData(const XMLCh* data) = 0;
}; |  |  |

### DOMAttr.hpp:

class DOMAttr : public DOMNode

{ |  |  |
| public: |  |
| virtual | const XMLCh* | getName() const = 0;
| virtual | bool | getSpecified() const = 0;
| virtual | const XMLCh* | getValue() const = 0;
| virtual | void | setValue(const XMLCh* value) = 0;
| virtual | DOMElement* | getOwnerElement() const = 0;
}; |  |  |

### DOMElement.hpp:

class DOMElement : public DOMNode

{ |  |  |
| public: |  |
| virtual | const XMLCh* | getTagName() const = 0;
| virtual | const XMLCh* | getAttribute(const XMLCh* name) const = 0;
| virtual | DOMAttr* | getAttributeNode(const XMLCh* name) const = 0;
| virtual | DOMNodeList* | getElementsByTagName(const XMLCh* name) const = 0;
| virtual | void | setAttribute(const XMLCh* name, const XMLCh* value) = 0;
| virtual | DOMAttr* | setAttributeNode(DOMAttr *newAttr) = 0;
| virtual | DOMAttr* | removeAttributeNode(DOMAttr* oldAttr) = 0;
| virtual | void | removeAttribute(const XMLCh* name) = 0;
| virtual | const XMLCh* | getAttributeNS(const XMLCh* namespaceURI, const XMLCh* localName) const = 0;
| virtual | void | setAttributeNS(const XMLCh* namespaceURI, const XMLCh* qualifiedName, const XMLCh* value) = 0;
| virtual | void | removeAttributeNS(const XMLCh* namespaceURI, const XMLCh* localName) = 0;
| virtual | DOMAttr* | getAttributeNodeNS(const XMLCh* namespaceURI, const XMLCh* localName) const = 0;
| virtual | DOMAttr* | setAttributeNodeNS(DOMAttr* newAttr) = 0;
| virtual | DOMNodeList* | getElementsByTagNameNS(const XMLCh* namespaceURI, const XMLCh* localName) const = 0;
| virtual | bool | hasAttribute(const XMLCh* name) const = 0;
| virtual | bool | hasAttributeNS(const XMLCh* namespaceURI, const XMLCh* localName) const = 0;
}; |  |  |

### DOMText.hpp:

class DOMText : DOMCharacterData

{ |  |  |
| public: |  |
| virtual | DOMText* | splitText(XMLSize_t offset) = 0;
| virtual | bool | getIsWhitespaceInElementContent() const = 0;
| virtual | const XMLCh* | getWholeText() = 0;
| virtual | DOMText* | replaceWholeText(const XMLCh* content) = 0;
}; |  |  |

### DOMComment.hpp:

class DOMComment : DOMCharacterData

{ |  |  |
}; |  |  |

### DOMUserDataHandler.hpp:

class DOMUserDataHandler

{ |  |  |
| public: |  |
| enum | DOMOperationType { |
|  | NODE_CLONED | = 1,
|  | NODE_IMPORTED | = 2,
|  | NODE_DELETED | = 3,
|  | NODE_RENAMED | = 4
| }; |  |
| virtual | void | handle(DOMOperationType operation, const XMLCh* const key, void* data, const DOMNode* src, const DOMNode* dst) = 0;
}; |  |  |

### DOMError.hpp:

class DOMError

{ |  |  |
| public: |  |
| enum | ErrorSeverity { |
|  | DOM_SEVERITY_WARNING | = 0,
|  | DOM_SEVERITY_ERROR | = 1,
|  | DOM_SEVERITY_FATAL_ERROR | = 2
| }; |  |
| virtual | short | getSeverity() const = 0;
| virtual | const XMLCh* | getMessage() const = 0;
| virtual | DOMLocator* | getLocation() const = 0;
| virtual | void* | getRelatedException() const = 0;
| virtual | void | setSeverity(const short severity) = 0;
| virtual | void | setMessage(const XMLCh* const message) = 0;
| virtual | void | setLocation(DOMLocator* const location) = 0
| virtual | void | setRelatedException(void* exception) const = 0;
}; |  |  |

### DOMErrorHandler.hpp:

class DOMErrorHandler

{ |  |  |
| public: |  |
| virtual | bool | handleError(const DOMError& domError) = 0;
}; |  |  |

### DOMLocator.hpp:

class DOMLocator

{ |  |  |
| public: |  |
| virtual | XMLSSize_t | getLineNumber() const = 0;
| virtual | XMLSSize_t | getColumnNumber() const = 0;
| virtual | XMLSSize_t | getOffset() const = 0;
| virtual | DOMNode* | getErrorNode() const = 0;
| virtual | const XMLCh* | getURI() const = 0;
| virtual | void | setLineNumber(const XMLSSize_t lineNumber) = 0;
| virtual | void | setColumnNumber(const XMLSSize_t columnNumber) = 0;
| virtual | void | setOffset(const XMLSSize_t offset) = 0;
| virtual | void | setErrorNode(DOMNode* const errorNode) = 0;
| virtual | void | setURI(const XMLCh* const uri) = 0
}; |  |  |

### DOMCDATASection.hpp:

class DOMCDATASection : DOMText

{ |  |  |
}; |  |  |

### DOMDocumentType.hpp:

class DOMDocumentType : DOMNode

{ |  |  |
| public: |  |
| virtual | const XMLCh* | getName() const = 0;
| virtual | DOMNamedNodeMap* | getEntities() const = 0;
| virtual | DOMNamedNodeMap* | getNotations() const = 0;
| virtual | const XMLCh* | getPublicId() const = 0;
| virtual | const XMLCh* | getSystemId() const = 0;
| virtual | const XMLCh* | getInternalSubset() const = 0;
}; |  |  |

### DOMNotation.hpp:

class DOMNotation : DOMNode

{ |  |  |
| public: |  |
| virtual | const XMLCh* | getPublicId() const = 0;
| virtual | const XMLCh* | getSystemId() const = 0;
}; |  |  |

### DOMEntity.hpp:

class DOMEntity : DOMNode

{ |  |  |
| public: |  |
| virtual | const XMLCh* | getPublicId() const = 0;
| virtual | const XMLCh* | getSystemId() const = 0;
| virtual | const XMLCh* | getNotationName() const = 0;
| virtual | const XMLCh* | getActualEncoding() const = 0;
| virtual | void | setActualEncoding(const XMLCh* actualEncoding) = 0;
| virtual | const XMLCh* | getEncoding() const = 0;
| virtual | void | setEncoding(const XMLCh* encoding) = 0;
| virtual | const XMLCh* | getVersion() const = 0;
| virtual | void | setVersion((const XMLCh* version) = 0;
}; |  |  |

### DOMEntityReference.hpp:

class DOMEntityReference : DOMNode

{ |  |  |
}; |  |  |

### DOMProcessingInstruction.hpp:

class DOMProcessingInstruction : DOMNode

{ |  |  |
| public: |  |
| virtual | const XMLCh* | getTarget() const = 0;
| virtual | const XMLCh* | getData() const = 0;
| virtual | void* | setData(const XMLCh* data) = 0;
}; |  |  |

## B: Document Object Mode: Load and Save

### DOMImplementationLS.hpp:

class DOMImplementationLS

{ |  |  |
| public: |  |
| enum | { |
|  | MODE_SYNCHRONOUS | =1,
|  | MODE_SYNCHRONOUS | =2
| }; |  |
| virtual | DOMBuilder* | createDOMBuilder(const short mode, const XMLCh* const schemaType) = 0;
| virtual | DOMWriter* | createDOMWriter() = 0;
| virtual | DOMInputSource* | createDOMInputSource() = 0;
}; |  |  |

### DOMInputSource.hpp:

// the byteStream, characterStream and stringData in this class are implementation specific
class DOMInputSource

{ |  |  |
| public: |  |
| virtual | const XMLCh* | getEncoding() const = 0;
| virtual | const XMLCh* | getPublicId() const = 0;
| virtual | const XMLCh* | getSystemId() const = 0;
| virtual | const XMLCh* | getBaseURI() const = 0;
| virtual | const XMLCh* | setEncoding() const = 0;
| virtual | const XMLCh* | setPublicId() const = 0;
| virtual | const XMLCh* | setSystemId() const = 0;
| virtual | const XMLCh* | setBaseURI() const = 0;

//
// Called to indicate that this DOMInputSource is no longer in use
// and that the implementation may relinquish any resources associated with it.
//
// Access to a released object will lead to unexpected result.
//
virtual void release() = 0;
};

### DOMEntityResolver.hpp:

class DOMEntityResolver

{ |  |  |
| public: |  |
| virtual | DOMInputSource* | resolverEntity(const XMLCh* const publicId, const XMLCh* const systemId const XMLCh* const baseURI) = 0;
}; |  |  |

### DOMBuilder.hpp:

class DOMBuilder

{ |  |  |
| public: |  |
| enum | ActionType { |
|  | ACTION_REPLACE | = 1,
|  | ACTION_APPEND_AS_CHILDREN | = 2,
|  | ACTION_INSERT_AFTER | = 3,
|  | ACTION_INSERT_BEFORE | =4
| }; |  |
| virtual | DOMErrorHandler* | getErrorHandler() = 0;
| virtual | const DOMErrorHandler* | getErrorHandler() const = 0;
| virtual | DOMEntityResolver* | getEntityResolver() = 0;
| virtual | const DOMEntityResolver* | getEntityResolver() const = 0;
| virtual | DOMBuilderFilter* | getFilter() = 0;
| virtual | const DOMBuilderFilter* | getFilter() const = 0;
| virtual | void | setErrorHandler(DOMErrorHandler* const handler) = 0;
| virtual | void | setEntityResolver(DOMEntityResolver* const handler) = 0;
| virtual | void | setFilter(DOMBuilderFilter* const filter) = 0;
| virtual | void | setFeature(const XMLCh* const name, const bool state) = 0;
| virtual | bool | getFeature(const XMLCh* const name) const = 0;
| virtual | bool | canSetFeature(const XMLCh* const name, const bool state) const = 0;
| virtual | DOMDocument* | parse(const DOMInputSource& source) = 0;
| virtual | DOMDocument* | parseURI(const XMLCh* const systemId) = 0;
| virtual | void | parseWithContext(const DOMInputSource& source, DOMNode* const contextNode, const short action) = 0;

//
// Called to indicate that this DOMBuilder is no longer in use
// and that the implementation may relinquish any resources associated with it.
//
// Access to a released object will lead to unexpected result.
//
virtual void release() = 0;
};

### DOMWriter.hpp:

// The XMLFormatTarget is implementation specific
class DOMWriter

{ |  |  |
| public: |  |
| virtual | bool | canSetFeature(const XMLCh* const featName, bool state) const = 0;
| virtual | void | setFeature(const XMLCh* const featName, bool state) = 0;
| virtual | bool | getFeature(const XMLCh* const featName) const = 0;
| virtual | void | setEncoding(const XMLCh* const encoding) = 0;
| virtual | void | setNewLine(const XMLCh* const newLine) = 0;
| virtual | void | setErrorHandler(DOMErrorHandler* errorHandler) = 0;
| virtual | void | setFilter(DOMWriterFilter* filter) = 0;
| virtual | const XMLCh* | getEncoding() const = 0;
| virtual | const XMLCh* | getNewLine() const = 0;
| virtual | DOMErrorHandler* | getErrorHandler() const = 0;
| virtual | DOMWriterFilter* | getFilter() const = 0;
| virtual | bool | writeToNode(XMLFormatTarget* const destination, const DOMNode& nodeToWrite) = 0;
| virtual | XMLCh* | writeToString(const DOMNode& nodeToWrite) = 0;

//
// Called to indicate that this DOMWriter is no longer in use
// and that the implementation may relinquish any resources associated with it.
//
// Access to a released object will lead to unexpected result.
//
virtual void release() = 0;
};

### DOMWriterFilter.hpp:

class DOMWriterFilter : DOMNodeFilter

{ |  |  |
| public: |  |
| virtual | unsigned long | getWhatToShow() const = 0;
| virtual | void | setWhatToShow(unsigned long toShow) = 0;
}; |  |  |

Copyright © 2001 The Apache Software Foundation. All Rights Reserved.