📄 domdocument.hpp
字号:
#ifndef DOMDocument_HEADER_GUARD_#define DOMDocument_HEADER_GUARD_/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *//* * $Id: DOMDocument.hpp 568078 2007-08-21 11:43:25Z amassari $*/#include <xercesc/util/XercesDefs.hpp>#include <xercesc/dom/DOMNode.hpp>#include <xercesc/dom/DOMDocumentRange.hpp>#include <xercesc/dom/DOMDocumentTraversal.hpp>#include <xercesc/dom/DOMXPathEvaluator.hpp>XERCES_CPP_NAMESPACE_BEGINclass DOMConfiguration;class DOMDocumentType;class DOMElement;class DOMDocumentFragment;class DOMComment;class DOMCDATASection;class DOMProcessingInstruction;class DOMAttr;class DOMEntity;class DOMEntityReference;class DOMImplementation;class DOMNodeFilter;class DOMNodeList;class DOMNotation;class DOMText;class DOMNode;/** * The <code>DOMDocument</code> 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. * <p>Since elements, text nodes, comments, processing instructions, etc. * cannot exist outside the context of a <code>DOMDocument</code>, the * <code>DOMDocument</code> interface also contains the factory methods needed * to create these objects. The <code>DOMNode</code> objects created have a * <code>ownerDocument</code> attribute which associates them with the * <code>DOMDocument</code> within whose context they were created. * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113'>Document Object Model (DOM) Level 2 Core Specification</a>. */class CDOM_EXPORT DOMDocument: public DOMDocumentRange, public DOMXPathEvaluator, public DOMDocumentTraversal, public DOMNode {protected: // ----------------------------------------------------------------------- // Hidden constructors // ----------------------------------------------------------------------- /** @name Hidden constructors */ //@{ DOMDocument() {}; //@}private: // ----------------------------------------------------------------------- // Unimplemented constructors and operators // ----------------------------------------------------------------------- /** @name Unimplemented constructors and operators */ //@{ DOMDocument(const DOMDocument &); DOMDocument & operator = (const DOMDocument &); //@}public: // ----------------------------------------------------------------------- // All constructors are hidden, just the destructor is available // ----------------------------------------------------------------------- /** @name Destructor */ //@{ /** * Destructor * */ virtual ~DOMDocument() {}; //@} // ----------------------------------------------------------------------- // Virtual DOMDocument interface // ----------------------------------------------------------------------- /** @name Functions introduced in DOM Level 1 */ //@{ /** * Creates an element of the type specified. Note that the instance * returned implements the <code>DOMElement</code> interface, so attributes * can be specified directly on the returned object. * <br>In addition, if there are known attributes with default values, * <code>DOMAttr</code> nodes representing them are automatically created * and attached to the element. * <br>To create an element with a qualified name and namespace URI, use * the <code>createElementNS</code> method. * @param tagName The name of the element type to instantiate. For XML, * this is case-sensitive. * @return A new <code>DOMElement</code> object with the * <code>nodeName</code> attribute set to <code>tagName</code>, and * <code>localName</code>, <code>prefix</code>, and * <code>namespaceURI</code> set to <code>null</code>. * @exception DOMException * INVALID_CHARACTER_ERR: Raised if the specified name contains an * illegal character. * @since DOM Level 1 */ virtual DOMElement *createElement(const XMLCh *tagName) = 0; /** * Creates an empty <code>DOMDocumentFragment</code> object. * @return A new <code>DOMDocumentFragment</code>. * @since DOM Level 1 */ virtual DOMDocumentFragment *createDocumentFragment() = 0; /** * Creates a <code>DOMText</code> node given the specified string. * @param data The data for the node. * @return The new <code>DOMText</code> object. * @since DOM Level 1 */ virtual DOMText *createTextNode(const XMLCh *data) = 0; /** * Creates a <code>DOMComment</code> node given the specified string. * @param data The data for the node. * @return The new <code>DOMComment</code> object. * @since DOM Level 1 */ virtual DOMComment *createComment(const XMLCh *data) = 0; /** * Creates a <code>DOMCDATASection</code> node whose value is the specified * string. * @param data The data for the <code>DOMCDATASection</code> contents. * @return The new <code>DOMCDATASection</code> object. * @since DOM Level 1 */ virtual DOMCDATASection *createCDATASection(const XMLCh *data) = 0; /** * Creates a <code>DOMProcessingInstruction</code> node given the specified * name and data strings. * @param target The target part of the processing instruction. * @param data The data for the node. * @return The new <code>DOMProcessingInstruction</code> object. * @exception DOMException * INVALID_CHARACTER_ERR: Raised if the specified target contains an * illegal character. * @since DOM Level 1 */ virtual DOMProcessingInstruction *createProcessingInstruction(const XMLCh *target, const XMLCh *data) = 0; /** * Creates an <code>DOMAttr</code> of the given name. Note that the * <code>DOMAttr</code> instance can then be set on an <code>DOMElement</code> * using the <code>setAttributeNode</code> method. * <br>To create an attribute with a qualified name and namespace URI, use * the <code>createAttributeNS</code> method. * @param name The name of the attribute. * @return A new <code>DOMAttr</code> object with the <code>nodeName</code> * attribute set to <code>name</code>, and <code>localName</code>, * <code>prefix</code>, and <code>namespaceURI</code> set to * <code>null</code>. The value of the attribute is the empty string. * @exception DOMException * INVALID_CHARACTER_ERR: Raised if the specified name contains an * illegal character. * @since DOM Level 1 */ virtual DOMAttr *createAttribute(const XMLCh *name) = 0; /** * Creates an <code>DOMEntityReference</code> object. In addition, if the * referenced entity is known, the child list of the * <code>DOMEntityReference</code> node is made the same as that of the * corresponding <code>DOMEntity</code> node.If any descendant of the * <code>DOMEntity</code> node has an unbound namespace prefix, the * corresponding descendant of the created <code>DOMEntityReference</code> * node is also unbound; (its <code>namespaceURI</code> is * <code>null</code>). The DOM Level 2 does not support any mechanism to * resolve namespace prefixes. * @param name The name of the entity to reference. * @return The new <code>DOMEntityReference</code> object. * @exception DOMException * INVALID_CHARACTER_ERR: Raised if the specified name contains an * illegal character. * @since DOM Level 1 */ virtual DOMEntityReference *createEntityReference(const XMLCh *name) = 0; /** * The Document Type Declaration (see <code>DOMDocumentType</code>) * associated with this document. For XML * documents without a document type declaration this returns * <code>null</code>. The DOM Level 2 does not support editing the * Document Type Declaration. <code>docType</code> cannot be altered in * any way, including through the use of methods inherited from the * <code>DOMNode</code> interface, such as <code>insertNode</code> or * <code>removeNode</code>. * @since DOM Level 1 */ virtual DOMDocumentType *getDoctype() const = 0; /** * The <code>DOMImplementation</code> object that handles this document. A * DOM application may use objects from multiple implementations. * @since DOM Level 1 */ virtual DOMImplementation *getImplementation() const = 0; /** * This is a convenience attribute that allows direct access to the child * node that is the root element of the document. * @since DOM Level 1 */ virtual DOMElement *getDocumentElement() const = 0; /** * Returns a <code>DOMNodeList</code> of all the <code>DOMElement(s)</code> with a * given tag name in the order in which they are encountered in a * preorder traversal of the <code>DOMDocument</code> 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. * @param tagname The name of the tag to match on. The special value "*" * matches all tags. * @return A new <code>DOMNodeList</code> object containing all the matched * <code>DOMElement(s)</code>. * @since DOM Level 1 */ virtual DOMNodeList *getElementsByTagName(const XMLCh *tagname) const = 0; //@} /** @name Functions introduced in DOM Level 2. */ //@{ /** * Imports a node from another document to this document. The returned * node has no parent; (<code>parentNode</code> is <code>null</code>). * The source node is not altered or removed from the original document; * this method creates a new copy of the source node. * <br>For all nodes, importing a node creates a node object owned by the * importing document, with attribute values identical to the source * node's <code>nodeName</code> and <code>nodeType</code>, plus the * attributes related to namespaces (<code>prefix</code>, * <code>localName</code>, and <code>namespaceURI</code>). As in the * <code>cloneNode</code> operation on a <code>DOMNode</code>, the source * node is not altered. * <br>Additional information is copied as appropriate to the * <code>nodeType</code>, 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. * <dl> * <dt>ATTRIBUTE_NODE</dt> * <dd>The <code>ownerElement</code> attribute * is set to <code>null</code> and the <code>specified</code> flag is * set to <code>true</code> on the generated <code>DOMAttr</code>. The * descendants of the source <code>DOMAttr</code> are recursively imported * and the resulting nodes reassembled to form the corresponding subtree. * Note that the <code>deep</code> parameter has no effect on * <code>DOMAttr</code> nodes; they always carry their children with them * when imported.</dd> * <dt>DOCUMENT_FRAGMENT_NODE</dt> * <dd>If the <code>deep</code> option * was set to <code>true</code>, 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -