[2674] | 1 | #ifndef DOMText_HEADER_GUARD_ |
---|
| 2 | #define DOMText_HEADER_GUARD_ |
---|
| 3 | |
---|
| 4 | /* |
---|
| 5 | * Licensed to the Apache Software Foundation (ASF) under one or more |
---|
| 6 | * contributor license agreements. See the NOTICE file distributed with |
---|
| 7 | * this work for additional information regarding copyright ownership. |
---|
| 8 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
| 9 | * (the "License"); you may not use this file except in compliance with |
---|
| 10 | * the License. You may obtain a copy of the License at |
---|
| 11 | * |
---|
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 13 | * |
---|
| 14 | * Unless required by applicable law or agreed to in writing, software |
---|
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 17 | * See the License for the specific language governing permissions and |
---|
| 18 | * limitations under the License. |
---|
| 19 | */ |
---|
| 20 | |
---|
| 21 | /* |
---|
| 22 | * $Id: DOMText.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
| 23 | */ |
---|
| 24 | |
---|
| 25 | #include <xercesc/util/XercesDefs.hpp> |
---|
| 26 | #include <xercesc/dom/DOMCharacterData.hpp> |
---|
| 27 | |
---|
| 28 | XERCES_CPP_NAMESPACE_BEGIN |
---|
| 29 | |
---|
| 30 | |
---|
| 31 | /** |
---|
| 32 | * The <code>DOMText</code> interface inherits from <code>DOMCharacterData</code> |
---|
| 33 | * and represents the textual content (termed character data in XML) of an |
---|
| 34 | * <code>DOMElement</code> or <code>DOMAttr</code>. If there is no markup inside |
---|
| 35 | * an element's content, the text is contained in a single object |
---|
| 36 | * implementing the <code>DOMText</code> interface that is the only child of |
---|
| 37 | * the element. If there is markup, it is parsed into the information items |
---|
| 38 | * (elements, comments, etc.) and <code>DOMText</code> nodes that form the list |
---|
| 39 | * of children of the element. |
---|
| 40 | * <p>When a document is first made available via the DOM, there is only one |
---|
| 41 | * <code>DOMText</code> node for each block of text. Users may create adjacent |
---|
| 42 | * <code>DOMText</code> nodes that represent the contents of a given element |
---|
| 43 | * without any intervening markup, but should be aware that there is no way |
---|
| 44 | * to represent the separations between these nodes in XML or HTML, so they |
---|
| 45 | * will not (in general) persist between DOM editing sessions. The |
---|
| 46 | * <code>normalize()</code> method on <code>DOMNode</code> merges any such |
---|
| 47 | * adjacent <code>DOMText</code> objects into a single node for each block of |
---|
| 48 | * text. |
---|
| 49 | * <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>. |
---|
| 50 | */ |
---|
| 51 | class CDOM_EXPORT DOMText: public DOMCharacterData { |
---|
| 52 | protected: |
---|
| 53 | // ----------------------------------------------------------------------- |
---|
| 54 | // Hidden constructors |
---|
| 55 | // ----------------------------------------------------------------------- |
---|
| 56 | /** @name Hidden constructors */ |
---|
| 57 | //@{ |
---|
| 58 | DOMText() {} |
---|
| 59 | DOMText(const DOMText &other) : DOMCharacterData(other) {} |
---|
| 60 | //@} |
---|
| 61 | |
---|
| 62 | private: |
---|
| 63 | // ----------------------------------------------------------------------- |
---|
| 64 | // Unimplemented constructors and operators |
---|
| 65 | // ----------------------------------------------------------------------- |
---|
| 66 | /** @name Unimplemented operators */ |
---|
| 67 | //@{ |
---|
| 68 | DOMText & operator = (const DOMText &); |
---|
| 69 | //@} |
---|
| 70 | |
---|
| 71 | public: |
---|
| 72 | // ----------------------------------------------------------------------- |
---|
| 73 | // All constructors are hidden, just the destructor is available |
---|
| 74 | // ----------------------------------------------------------------------- |
---|
| 75 | /** @name Destructor */ |
---|
| 76 | //@{ |
---|
| 77 | /** |
---|
| 78 | * Destructor |
---|
| 79 | * |
---|
| 80 | */ |
---|
| 81 | virtual ~DOMText() {}; |
---|
| 82 | //@} |
---|
| 83 | |
---|
| 84 | // ----------------------------------------------------------------------- |
---|
| 85 | // Virtual DOMText interface |
---|
| 86 | // ----------------------------------------------------------------------- |
---|
| 87 | /** @name Functions introduced in DOM Level 1 */ |
---|
| 88 | //@{ |
---|
| 89 | /** |
---|
| 90 | * Breaks this node into two nodes at the specified <code>offset</code>, |
---|
| 91 | * keeping both in the tree as siblings. After being split, this node |
---|
| 92 | * will contain all the content up to the <code>offset</code> point. A |
---|
| 93 | * new node of the same type, which contains all the content at and |
---|
| 94 | * after the <code>offset</code> point, is returned. If the original |
---|
| 95 | * node had a parent node, the new node is inserted as the next sibling |
---|
| 96 | * of the original node. When the <code>offset</code> is equal to the |
---|
| 97 | * length of this node, the new node has no data. |
---|
| 98 | * @param offset The 16-bit unit offset at which to split, starting from |
---|
| 99 | * <code>0</code>. |
---|
| 100 | * @return The new node, of the same type as this node. |
---|
| 101 | * @exception DOMException |
---|
| 102 | * INDEX_SIZE_ERR: Raised if the specified offset is negative or greater |
---|
| 103 | * than the number of 16-bit units in <code>data</code>. |
---|
| 104 | * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. |
---|
| 105 | * @since DOM Level 1 |
---|
| 106 | */ |
---|
| 107 | virtual DOMText *splitText(XMLSize_t offset) = 0; |
---|
| 108 | //@} |
---|
| 109 | |
---|
| 110 | /** @name Functions introduced in DOM Level 3 */ |
---|
| 111 | //@{ |
---|
| 112 | /** |
---|
| 113 | * Returns whether this text node contains whitespace in element content, |
---|
| 114 | * often abusively called "ignorable whitespace". An implementation can |
---|
| 115 | * only return <code>true</code> if, one way or another, it has access |
---|
| 116 | * to the relevant information (e.g., the DTD or schema). |
---|
| 117 | * |
---|
| 118 | * <p><b>"Experimental - subject to change"</b></p> |
---|
| 119 | * |
---|
| 120 | * <br> This attribute represents the property [element content |
---|
| 121 | * whitespace] defined in . |
---|
| 122 | * @since DOM Level 3 |
---|
| 123 | */ |
---|
| 124 | virtual bool getIsWhitespaceInElementContent() const = 0; |
---|
| 125 | |
---|
| 126 | /** |
---|
| 127 | * Returns all text of <code>DOMText</code> nodes logically-adjacent text |
---|
| 128 | * nodes to this node, concatenated in document order. |
---|
| 129 | * |
---|
| 130 | * <p><b>"Experimental - subject to change"</b></p> |
---|
| 131 | * |
---|
| 132 | * @since DOM Level 3 |
---|
| 133 | */ |
---|
| 134 | virtual const XMLCh* getWholeText() = 0; |
---|
| 135 | |
---|
| 136 | /** |
---|
| 137 | * Substitutes the a specified text for the text of the current node and |
---|
| 138 | * all logically-adjacent text nodes. |
---|
| 139 | * |
---|
| 140 | * <p><b>"Experimental - subject to change"</b></p> |
---|
| 141 | * |
---|
| 142 | * <br>This method returns the node in the hierarchy which received the |
---|
| 143 | * replacement text, which is null if the text was empty or is the |
---|
| 144 | * current node if the current node is not read-only or otherwise is a |
---|
| 145 | * new node of the same type as the current node inserted at the site of |
---|
| 146 | * the replacement. All logically-adjacent text nodes are removed |
---|
| 147 | * including the current node unless it was the recipient of the |
---|
| 148 | * replacement text. |
---|
| 149 | * <br>Where the nodes to be removed are read-only descendants of an |
---|
| 150 | * <code>DOMEntityReference</code>, the <code>DOMEntityReference</code> must |
---|
| 151 | * be removed instead of the read-only nodes. If any |
---|
| 152 | * <code>DOMEntityReference</code> to be removed has descendants that are |
---|
| 153 | * not <code>DOMEntityReference</code>, <code>DOMText</code>, or |
---|
| 154 | * <code>DOMCDATASection</code> nodes, the <code>replaceWholeText</code> |
---|
| 155 | * method must fail before performing any modification of the document, |
---|
| 156 | * raising a <code>DOMException</code> with the code |
---|
| 157 | * <code>NO_MODIFICATION_ALLOWED_ERR</code>. |
---|
| 158 | * @param content The content of the replacing <code>DOMText</code> node. |
---|
| 159 | * @return The <code>DOMText</code> node created with the specified content. |
---|
| 160 | * @exception DOMException |
---|
| 161 | * NO_MODIFICATION_ALLOWED_ERR: Raised if one of the <code>DOMText</code> |
---|
| 162 | * nodes being replaced is readonly. |
---|
| 163 | * @since DOM Level 3 |
---|
| 164 | */ |
---|
| 165 | virtual DOMText* replaceWholeText(const XMLCh* content) = 0; |
---|
| 166 | //@} |
---|
| 167 | |
---|
| 168 | // ----------------------------------------------------------------------- |
---|
| 169 | // Non-standard extension |
---|
| 170 | // ----------------------------------------------------------------------- |
---|
| 171 | /** @name Non-standard extension */ |
---|
| 172 | //@{ |
---|
| 173 | /** |
---|
| 174 | * Non-standard extension |
---|
| 175 | * |
---|
| 176 | * Return true if this node contains ignorable whitespaces only. |
---|
| 177 | * @return True if this node contains ignorable whitespaces only. |
---|
| 178 | */ |
---|
| 179 | virtual bool isIgnorableWhitespace() const = 0; |
---|
| 180 | //@} |
---|
| 181 | |
---|
| 182 | }; |
---|
| 183 | |
---|
| 184 | |
---|
| 185 | XERCES_CPP_NAMESPACE_END |
---|
| 186 | |
---|
| 187 | #endif |
---|
| 188 | |
---|
| 189 | |
---|