📄 domnode.hpp
字号:
#ifndef DOMNode_HEADER_GUARD_#define DOMNode_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: DOMNode.hpp 568078 2007-08-21 11:43:25Z amassari $ */#include <xercesc/util/XercesDefs.hpp>XERCES_CPP_NAMESPACE_BEGINclass DOMDocument;class DOMNamedNodeMap;class DOMNodeList;class DOMUserDataHandler;/** * The <code>DOMNode</code> interface is the primary datatype for the entire * Document Object Model. It represents a single node in the document tree. * While all objects implementing the <code>DOMNode</code> interface expose * methods for dealing with children, not all objects implementing the * <code>DOMNode</code> interface may have children. For example, * <code>DOMText</code> nodes may not have children, and adding children to * such nodes results in a <code>DOMException</code> being raised. * <p>The attributes <code>nodeName</code>, <code>nodeValue</code> and * <code>attributes</code> are included as a mechanism to get at node * information without casting down to the specific derived interface. In * cases where there is no obvious mapping of these attributes for a * specific <code>nodeType</code> (e.g., <code>nodeValue</code> for an * <code>DOMElement</code> or <code>attributes</code> for a <code>DOMComment</code> * ), this returns <code>null</code>. Note that the specialized interfaces * may contain additional and more convenient mechanisms to get and set the * relevant information. * <p>The values of <code>nodeName</code>, * <code>nodeValue</code>, and <code>attributes</code> vary according to the * node type as follows: * <table border='1'> * <tr> * <td>Interface</td> * <td>nodeName</td> * <td>nodeValue</td> * <td>attributes</td> * </tr> * <tr> * <td valign='top' rowspan='1' colspan='1'>DOMAttr</td> * <td valign='top' rowspan='1' colspan='1'>name of attribute</td> * <td valign='top' rowspan='1' colspan='1'>value of attribute</td> * <td valign='top' rowspan='1' colspan='1'>null</td> * </tr> * <tr> * <td valign='top' rowspan='1' colspan='1'>DOMCDATASection</td> * <td valign='top' rowspan='1' colspan='1'>"#cdata-section"</td> * <td valign='top' rowspan='1' colspan='1'>content of the CDATA Section</td> * <td valign='top' rowspan='1' colspan='1'>null</td> * </tr> * <tr> * <td valign='top' rowspan='1' colspan='1'>DOMComment</td> * <td valign='top' rowspan='1' colspan='1'>"#comment"</td> * <td valign='top' rowspan='1' colspan='1'>content of the comment</td> * <td valign='top' rowspan='1' colspan='1'>null</td> * </tr> * <tr> * <td valign='top' rowspan='1' colspan='1'>DOMDocument</td> * <td valign='top' rowspan='1' colspan='1'>"#document"</td> * <td valign='top' rowspan='1' colspan='1'>null</td> * <td valign='top' rowspan='1' colspan='1'>null</td> * </tr> * <tr> * <td valign='top' rowspan='1' colspan='1'>DOMDocumentFragment</td> * <td valign='top' rowspan='1' colspan='1'>"#document-fragment"</td> * <td valign='top' rowspan='1' colspan='1'>null</td> * <td valign='top' rowspan='1' colspan='1'>null</td> * </tr> * <tr> * <td valign='top' rowspan='1' colspan='1'>DOMDocumentType</td> * <td valign='top' rowspan='1' colspan='1'>document type name</td> * <td valign='top' rowspan='1' colspan='1'>null</td> * <td valign='top' rowspan='1' colspan='1'>null</td> * </tr> * <tr> * <td valign='top' rowspan='1' colspan='1'>DOMElement</td> * <td valign='top' rowspan='1' colspan='1'>tag name</td> * <td valign='top' rowspan='1' colspan='1'>null</td> * <td valign='top' rowspan='1' colspan='1'>NamedNodeMap</td> * </tr> * <tr> * <td valign='top' rowspan='1' colspan='1'>DOMEntity</td> * <td valign='top' rowspan='1' colspan='1'>entity name</td> * <td valign='top' rowspan='1' colspan='1'>null</td> * <td valign='top' rowspan='1' colspan='1'>null</td> * </tr> * <tr> * <td valign='top' rowspan='1' colspan='1'>DOMEntityReference</td> * <td valign='top' rowspan='1' colspan='1'>name of entity referenced</td> * <td valign='top' rowspan='1' colspan='1'>null</td> * <td valign='top' rowspan='1' colspan='1'>null</td> * </tr> * <tr> * <td valign='top' rowspan='1' colspan='1'>DOMNotation</td> * <td valign='top' rowspan='1' colspan='1'>notation name</td> * <td valign='top' rowspan='1' colspan='1'>null</td> * <td valign='top' rowspan='1' colspan='1'>null</td> * </tr> * <tr> * <td valign='top' rowspan='1' colspan='1'>DOMProcessingInstruction</td> * <td valign='top' rowspan='1' colspan='1'>target</td> * <td valign='top' rowspan='1' colspan='1'>entire content excluding the target</td> * <td valign='top' rowspan='1' colspan='1'>null</td> * </tr> * <tr> * <td valign='top' rowspan='1' colspan='1'>DOMText</td> * <td valign='top' rowspan='1' colspan='1'>"#text"</td> * <td valign='top' rowspan='1' colspan='1'>content of the text node</td> * <td valign='top' rowspan='1' colspan='1'>null</td> * </tr> * </table> * <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>. * * @since DOM Level 1 */class CDOM_EXPORT DOMNode {protected: // ----------------------------------------------------------------------- // Hidden constructors // ----------------------------------------------------------------------- /** @name Hidden constructors */ //@{ DOMNode() {} DOMNode(const DOMNode &) {} //@}private: // ----------------------------------------------------------------------- // Unimplemented constructors and operators // ----------------------------------------------------------------------- /** @name Unimplemented operators */ //@{ DOMNode & operator = (const DOMNode &); //@}public: // ----------------------------------------------------------------------- // All constructors are hidden, just the destructor is available // ----------------------------------------------------------------------- /** @name Destructor */ //@{ /** * Destructor * */ virtual ~DOMNode() {}; //@} // ----------------------------------------------------------------------- // Class Types // ----------------------------------------------------------------------- /** @name Public Contants */ //@{ /** * NodeType * * @since DOM Level 1 */ 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 }; /** * TreePosition: * * <p><b>"Experimental - subject to change"</b></p> * * <p><code>TREE_POSITION_PRECEDING:</code> * The node precedes the reference node.</p> * <p><code>TREE_POSITION_FOLLOWING:</code> * The node follows the reference node.</p> * <p><code>TREE_POSITION_ANCESTOR:</code> * The node is an ancestor of the reference node.</p> * <p><code>TREE_POSITION_DESCENDANT:</code> * The node is a descendant of the reference node.</p> * <p><code>TREE_POSITION_EQUIVALENT:</code> * The two nodes have an equivalent position. This is the case of two * attributes that have the same <code>ownerElement</code>, and two * nodes that are the same.</p> * <p><code>TREE_POSITION_SAME_NODE:</code> * The two nodes are the same. Two nodes that are the same have an * equivalent position, though the reverse may not be true.</p> * <p><code>TREE_POSITION_DISCONNECTED:</code> * The two nodes are disconnected, they do not have any common ancestor. * This is the case of two nodes that are not in the same document.</p> * * @since DOM Level 3 */ enum DOMTreePosition { TREE_POSITION_PRECEDING = 0x01, TREE_POSITION_FOLLOWING = 0x02, TREE_POSITION_ANCESTOR = 0x04, TREE_POSITION_DESCENDANT = 0x08, TREE_POSITION_EQUIVALENT = 0x10, TREE_POSITION_SAME_NODE = 0x20, TREE_POSITION_DISCONNECTED = 0x00 }; //@} // ----------------------------------------------------------------------- // Virtual DOMNode interface // ----------------------------------------------------------------------- /** @name Functions introduced in DOM Level 1 */ //@{ // ----------------------------------------------------------------------- // Getter methods // ----------------------------------------------------------------------- /** * The name of this node, depending on its type; see the table above. * @since DOM Level 1 */ virtual const XMLCh * getNodeName() const = 0; /** * Gets the value of this node, depending on its type. * * @exception DOMException * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. * @since DOM Level 1 */ virtual const XMLCh * getNodeValue() const = 0; /** * An enum value representing the type of the underlying object. * @since DOM Level 1 */ virtual short getNodeType() const = 0; /** * Gets the parent of this node. * * All nodes, except <code>DOMDocument</code>, * <code>DOMDocumentFragment</code>, and <code>DOMAttr</code> may have a parent. * However, if a node has just been created and not yet added to the tree, * or if it has been removed from the tree, a <code>null</code> DOMNode * is returned. * @since DOM Level 1 */ virtual DOMNode *getParentNode() const = 0; /** * Gets a <code>DOMNodeList</code> that contains all children of this node. * * If there * are no children, this is a <code>DOMNodeList</code> containing no nodes. * The content of the returned <code>DOMNodeList</code> is "live" in the sense * that, for instance, changes to the children of the node object that * it was created from are immediately reflected in the nodes returned by * the <code>DOMNodeList</code> accessors; it is not a static snapshot of the * content of the node. This is true for every <code>DOMNodeList</code>, * including the ones returned by the <code>getElementsByTagName</code> * method. * @since DOM Level 1 */ virtual DOMNodeList *getChildNodes() const = 0; /** * Gets the first child of this node. * * If there is no such node, this returns <code>null</code>. * @since DOM Level 1 */ virtual DOMNode *getFirstChild() const = 0; /** * Gets the last child of this node. * * If there is no such node, this returns <code>null</code>. * @since DOM Level 1 */ virtual DOMNode *getLastChild() const = 0; /** * Gets the node immediately preceding this node. * * If there is no such node, this returns <code>null</code>. * @since DOM Level 1 */ virtual DOMNode *getPreviousSibling() const = 0; /** * Gets the node immediately following this node. * * If there is no such node, this returns <code>null</code>. * @since DOM Level 1 */ virtual DOMNode *getNextSibling() const = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -