00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one 00003 * or more contributor license agreements. See the NOTICE file 00004 * distributed with this work for additional information 00005 * regarding copyright ownership. The ASF licenses this file 00006 * to you under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 #if !defined(XERCESTEXTBRIDGE_HEADER_GUARD_1357924680) 00019 #define XERCESTEXTBRIDGE_HEADER_GUARD_1357924680 00020 00021 00022 00023 #include <xalanc/XercesParserLiaison/XercesParserLiaisonDefinitions.hpp> 00024 00025 00026 00027 #if XERCES_VERSION_MAJOR >= 2 00028 #include <xercesc/dom/deprecated/DOM_Text.hpp> 00029 #else 00030 #include <xercesc/dom/DOM_Text.hpp> 00031 #endif 00032 00033 00034 #include <xalanc/XalanDOM/XalanText.hpp> 00035 00036 00037 00038 #include <xalanc/XercesParserLiaison/Deprecated/XercesDOM_NodeHack.hpp> 00039 00040 00041 00042 XALAN_CPP_NAMESPACE_BEGIN 00043 00044 00045 00046 class XercesBridgeNavigator; 00047 00048 00049 /** 00050 * This class is deprecated. 00051 * 00052 * @deprecated This class is part of the deprecated Xerces DOM bridge. 00053 */ 00054 class XALAN_XERCESPARSERLIAISON_EXPORT XercesTextBridge : public XalanText 00055 { 00056 public: 00057 00058 typedef XERCES_CPP_NAMESPACE_QUALIFIER DOM_Text DOM_TextType; 00059 00060 XercesTextBridge( 00061 const DOM_TextType& theXercesText, 00062 const XercesBridgeNavigator& theNavigator); 00063 00064 virtual 00065 ~XercesTextBridge(); 00066 00067 00068 /** 00069 * Gets the name of this node. 00070 */ 00071 virtual const XalanDOMString& 00072 getNodeName() const; 00073 00074 /** 00075 * Gets the value of this node, depending on its type. 00076 */ 00077 virtual const XalanDOMString& 00078 getNodeValue() const; 00079 00080 /** 00081 * An enum value representing the type of the underlying object. 00082 */ 00083 virtual NodeType 00084 getNodeType() const; 00085 00086 /** 00087 * Gets the parent of this node. 00088 * 00089 * All nodes, except <code>Document</code>, 00090 * <code>DocumentFragment</code>, and <code>Attr</code> may have a parent. 00091 * However, if a node has just been created and not yet added to the tree, 00092 * or if it has been removed from the tree, a <code>null</code> DOM_Node 00093 * is returned. 00094 */ 00095 virtual XalanNode* 00096 getParentNode() const; 00097 00098 /** 00099 * Gets a <code>NodeList</code> that contains all children of this node. 00100 * 00101 * If there 00102 * are no children, this is a <code>NodeList</code> containing no nodes. 00103 * The content of the returned <code>NodeList</code> is "live" in the sense 00104 * that, for instance, changes to the children of the node object that 00105 * it was created from are immediately reflected in the nodes returned by 00106 * the <code>NodeList</code> accessors; it is not a static snapshot of the 00107 * content of the node. This is true for every <code>NodeList</code>, 00108 * including the ones returned by the <code>getElementsByTagName</code> 00109 * method. 00110 */ 00111 virtual const XalanNodeList* 00112 getChildNodes() const; 00113 00114 /** 00115 * Gets the first child of this node. 00116 * 00117 * If there is no such node, this returns <code>null</code>. 00118 */ 00119 virtual XalanNode* 00120 getFirstChild() const; 00121 00122 /** 00123 * Gets the last child of this node. 00124 * 00125 * If there is no such node, this returns <code>null</code>. 00126 */ 00127 virtual XalanNode* 00128 getLastChild() const; 00129 00130 /** 00131 * Gets the node immediately preceding this node. 00132 * 00133 * If there is no such node, this returns <code>null</code>. 00134 */ 00135 virtual XalanNode* 00136 getPreviousSibling() const; 00137 00138 /** 00139 * Gets the node immediately following this node. 00140 * 00141 * If there is no such node, this returns <code>null</code>. 00142 */ 00143 virtual XalanNode* 00144 getNextSibling() const; 00145 00146 /** 00147 * Gets a <code>NamedNodeMap</code> containing the attributes of this node (if it 00148 * is an <code>Element</code>) or <code>null</code> otherwise. 00149 */ 00150 virtual const XalanNamedNodeMap* 00151 getAttributes() const; 00152 00153 /** 00154 * Gets the <code>DOM_Document</code> object associated with this node. 00155 * 00156 * This is also 00157 * the <code>DOM_Document</code> object used to create new nodes. When this 00158 * node is a <code>DOM_Document</code> or a <code>DOM_DocumentType</code> 00159 * which is not used with any <code>DOM_Document</code> yet, this is 00160 * <code>null</code>. 00161 */ 00162 virtual XalanDocument* 00163 getOwnerDocument() const; 00164 00165 //@} 00166 /** @name Cloning function. */ 00167 //@{ 00168 00169 /** 00170 * Returns a duplicate of this node. 00171 * 00172 * This function serves as a generic copy constructor for nodes. 00173 * 00174 * The duplicate node has no parent ( 00175 * <code>parentNode</code> returns <code>null</code>.). 00176 * <br>Cloning an <code>Element</code> copies all attributes and their 00177 * values, including those generated by the XML processor to represent 00178 * defaulted attributes, but this method does not copy any text it contains 00179 * unless it is a deep clone, since the text is contained in a child 00180 * <code>Text</code> node. Cloning any other type of node simply returns a 00181 * copy of this node. 00182 * @param deep If <code>true</code>, recursively clone the subtree under the 00183 * specified node; if <code>false</code>, clone only the node itself (and 00184 * its attributes, if it is an <code>Element</code>). 00185 * @return The duplicate node. 00186 */ 00187 #if defined(XALAN_NO_COVARIANT_RETURN_TYPE) 00188 virtual XalanNode* 00189 #else 00190 virtual XercesTextBridge* 00191 #endif 00192 cloneNode(bool deep) const; 00193 00194 //@} 00195 /** @name Functions to modify the DOM Node. */ 00196 //@{ 00197 00198 /** 00199 * Inserts the node <code>newChild</code> before the existing child node 00200 * <code>refChild</code>. 00201 * 00202 * If <code>refChild</code> is <code>null</code>, 00203 * insert <code>newChild</code> at the end of the list of children. 00204 * <br>If <code>newChild</code> is a <code>DocumentFragment</code> object, 00205 * all of its children are inserted, in the same order, before 00206 * <code>refChild</code>. If the <code>newChild</code> is already in the 00207 * tree, it is first removed. Note that a <code>DOM_Node</code> that 00208 * has never been assigned to refer to an actual node is == null. 00209 * @param newChild The node to insert. 00210 * @param refChild The reference node, i.e., the node before which the new 00211 * node must be inserted. 00212 * @return The node being inserted. 00213 */ 00214 virtual XalanNode* 00215 insertBefore( 00216 XalanNode* newChild, 00217 XalanNode* refChild); 00218 00219 /** 00220 * Replaces the child node <code>oldChild</code> with <code>newChild</code> 00221 * in the list of children, and returns the <code>oldChild</code> node. 00222 * 00223 * If <CODE>newChild</CODE> is a <CODE>DOM_DocumentFragment</CODE> object, 00224 * <CODE>oldChild</CODE> is replaced by all of the <CODE>DOM_DocumentFragment</CODE> 00225 * children, which are inserted in the same order. 00226 * 00227 * If the <code>newChild</code> is already in the tree, it is first removed. 00228 * @param newChild The new node to put in the child list. 00229 * @param oldChild The node being replaced in the list. 00230 * @return The node replaced. 00231 */ 00232 virtual XalanNode* 00233 replaceChild( 00234 XalanNode* newChild, 00235 XalanNode* oldChild); 00236 00237 /** 00238 * Removes the child node indicated by <code>oldChild</code> from the list 00239 * of children, and returns it. 00240 * 00241 * @param oldChild The node being removed. 00242 * @return The node removed. 00243 */ 00244 virtual XalanNode* 00245 removeChild(XalanNode* oldChild); 00246 00247 /** 00248 * Adds the node <code>newChild</code> to the end of the list of children of 00249 * this node. 00250 * 00251 * If the <code>newChild</code> is already in the tree, it is 00252 * first removed. 00253 * @param newChild The node to add.If it is a <code>DocumentFragment</code> 00254 * object, the entire contents of the document fragment are moved into 00255 * the child list of this node 00256 * @return The node added. 00257 */ 00258 virtual XalanNode* 00259 appendChild(XalanNode* newChild); 00260 00261 //@} 00262 /** @name Query functions. */ 00263 //@{ 00264 00265 /** 00266 * This is a convenience method to allow easy determination of whether a 00267 * node has any children. 00268 * 00269 * @return <code>true</code> if the node has any children, 00270 * <code>false</code> if the node has no children. 00271 */ 00272 virtual bool 00273 hasChildNodes() const; 00274 00275 00276 //@} 00277 /** @name Set functions. */ 00278 //@{ 00279 00280 00281 /** 00282 * Sets the value of the node. 00283 * 00284 * Any node which can have a nodeValue (@see getNodeValue) will 00285 * also accept requests to set it to a string. The exact response to 00286 * this varies from node to node -- Attribute, for example, stores 00287 * its values in its children and has to replace them with a new Text 00288 * holding the replacement value. 00289 * 00290 * For most types of Node, value is null and attempting to set it 00291 * will throw DOMException(NO_MODIFICATION_ALLOWED_ERR). This will 00292 * also be thrown if the node is read-only. 00293 */ 00294 virtual void 00295 setNodeValue(const XalanDOMString& nodeValue); 00296 00297 //@} 00298 /** @name Functions introduced in DOM Level 2. */ 00299 //@{ 00300 00301 /** 00302 * Puts all <CODE>DOM_Text</CODE> 00303 * nodes in the full depth of the sub-tree underneath this <CODE>DOM_Node</CODE>, 00304 * including attribute nodes, into a "normal" form where only markup (e.g., 00305 * tags, comments, processing instructions, CDATA sections, and entity 00306 * references) separates <CODE>DOM_Text</CODE> 00307 * nodes, i.e., there are no adjacent <CODE>DOM_Text</CODE> 00308 * nodes. This can be used to ensure that the DOM view of a document is the 00309 * same as if it were saved and re-loaded, and is useful when operations 00310 * (such as XPointer lookups) that depend on a particular document tree 00311 * structure are to be used. 00312 * <P><B>Note:</B> In cases where the document contains <CODE>DOM_CDATASections</CODE>, 00313 * the normalize operation alone may not be sufficient, since XPointers do 00314 * not differentiate between <CODE>DOM_Text</CODE> 00315 * nodes and <CODE>DOM_CDATASection</CODE> nodes.</P> 00316 */ 00317 virtual void 00318 normalize(); 00319 00320 /** 00321 * Tests whether the DOM implementation implements a specific 00322 * feature and that feature is supported by this node. 00323 * @param feature The string of the feature to test. This is the same 00324 * name as what can be passed to the method <code>hasFeature</code> on 00325 * <code>DOMImplementation</code>. 00326 * @param version This is the version number of the feature to test. In 00327 * Level 2, version 1, this is the string "2.0". If the version is not 00328 * specified, supporting any version of the feature will cause the 00329 * method to return <code>true</code>. 00330 * @return Returns <code>true</code> if the specified feature is supported 00331 * on this node, <code>false</code> otherwise. 00332 */ 00333 virtual bool 00334 isSupported( 00335 const XalanDOMString& feature, 00336 const XalanDOMString& version) const; 00337 00338 /** 00339 * Get the <em>namespace URI</em> of 00340 * this node, or <code>null</code> if it is unspecified. 00341 * <p> 00342 * This is not a computed value that is the result of a namespace lookup 00343 * based on an examination of the namespace declarations in scope. It is 00344 * merely the namespace URI given at creation time. 00345 * <p> 00346 * For nodes of any type other than <CODE>ELEMENT_NODE</CODE> and 00347 * <CODE>ATTRIBUTE_NODE</CODE> and nodes created with a DOM Level 1 method, 00348 * such as <CODE>createElement</CODE> from the <CODE>Document</CODE> 00349 * interface, this is always <CODE>null</CODE>. 00350 */ 00351 virtual const XalanDOMString& 00352 getNamespaceURI() const; 00353 00354 /** 00355 * Get the <em>namespace prefix</em> 00356 * of this node, or <code>null</code> if it is unspecified. 00357 */ 00358 virtual const XalanDOMString& 00359 getPrefix() const; 00360 00361 /** 00362 * Returns the local part of the <em>qualified name</em> of this node. 00363 * <p> 00364 * For nodes created with a DOM Level 1 method, such as 00365 * <code>createElement</code> from the <code>DOM_Document</code> interface, 00366 * it is null. 00367 */ 00368 virtual const XalanDOMString& 00369 getLocalName() const; 00370 00371 /** 00372 * Set the <em>namespace prefix</em> of this node. 00373 * <p> 00374 * Note that setting this attribute, when permitted, changes 00375 * the <CODE>nodeName</CODE> attribute, which holds the <EM>qualified 00376 * name</EM>, as well as the <CODE>tagName</CODE> and <CODE>name</CODE> 00377 * attributes of the <CODE>DOM_Element</CODE> and <CODE>DOM_Attr</CODE> 00378 * interfaces, when applicable. 00379 * <p> 00380 * Note also that changing the prefix of an 00381 * attribute, that is known to have a default value, does not make a new 00382 * attribute with the default value and the original prefix appear, since the 00383 * <CODE>namespaceURI</CODE> and <CODE>localName</CODE> do not change. 00384 * 00385 * @param prefix The prefix of this node. 00386 * @exception DOMException 00387 * INVALID_CHARACTER_ERR: Raised if the specified prefix contains 00388 * an illegal character. 00389 * <br> 00390 * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. 00391 * <br> 00392 * NAMESPACE_ERR: Raised if the specified <CODE>prefix</CODE> is 00393 * malformed, if the specified prefix is "xml" and the 00394 * <CODE>namespaceURI</CODE> of this node is different from 00395 * "http://www.w3.org/XML/1998/namespace", if specified prefix is 00396 * "xmlns" and the <CODE>namespaceURI</CODE> is neither 00397 * <CODE>null</CODE> nor an empty string, or if the 00398 * <CODE>localName</CODE> is <CODE>null</CODE>. 00399 */ 00400 virtual void 00401 setPrefix(const XalanDOMString& prefix); 00402 00403 virtual bool 00404 isIndexed() const; 00405 00406 virtual IndexType 00407 getIndex() const; 00408 00409 //@} 00410 00411 // These interfaces are inherited from XalanText... 00412 00413 /** @name Getter functions. */ 00414 //@{ 00415 /** 00416 * Returns the character data of the node that implements this interface. 00417 * 00418 * The DOM implementation may not put arbitrary limits on the amount of data that 00419 * may be stored in a <code>CharacterData</code> node. However, 00420 * implementation limits may mean that the entirety of a node's data may 00421 * not fit into a single <code>DOMString</code>. In such cases, the user 00422 * may call <code>substringData</code> to retrieve the data in 00423 * appropriately sized pieces. 00424 * @exception DOMException 00425 * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. 00426 * @exception DOMException 00427 * DOMSTRING_SIZE_ERR: Raised when it would return more characters than 00428 * fit in a <code>DOMString</code> variable on the implementation 00429 * platform. 00430 */ 00431 virtual const XalanDOMString& 00432 getData() const; 00433 00434 /** 00435 * Returns the number of characters that are available through <code>data</code> and 00436 * the <code>substringData</code> method below. 00437 * 00438 * This may have the value 00439 * zero, i.e., <code>CharacterData</code> nodes may be empty. 00440 */ 00441 virtual unsigned int 00442 getLength() const; 00443 00444 /** 00445 * Extracts a range of data from the node. 00446 * 00447 * @param offset Start offset of substring to extract. 00448 * @param count The number of characters to extract. 00449 * @return The specified substring. If the sum of <code>offset</code> and 00450 * <code>count</code> exceeds the <code>length</code>, then all 00451 * characters to the end of the data are returned. 00452 * @exception DOMException 00453 * INDEX_SIZE_ERR: Raised if the specified offset is negative or greater 00454 * than the number of characters in <code>data</code>, or if the 00455 * specified <code>count</code> is negative. 00456 * <br>DOMSTRING_SIZE_ERR: Raised if the specified range of text does not 00457 * fit into a <code>DOMString</code>. 00458 */ 00459 virtual XalanDOMString 00460 substringData( 00461 unsigned int offset, 00462 unsigned int count) const; 00463 00464 //@} 00465 /** @name Functions that set or change data. */ 00466 //@{ 00467 /** 00468 * Append the string to the end of the character data of the node. 00469 * 00470 * Upon success, <code>data</code> provides access to the concatenation of 00471 * <code>data</code> and the <code>DOMString</code> specified. 00472 * @param arg The <code>DOMString</code> to append. 00473 * @exception DOMException 00474 * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. 00475 */ 00476 virtual void 00477 appendData(const XalanDOMString& arg); 00478 00479 /** 00480 * Insert a string at the specified character offset. 00481 * 00482 * @param offset The character offset at which to insert. 00483 * @param arg The <code>DOMString</code> to insert. 00484 * @exception DOMException 00485 * INDEX_SIZE_ERR: Raised if the specified offset is negative or greater 00486 * than the number of characters in <code>data</code>. 00487 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. 00488 */ 00489 virtual void 00490 insertData( 00491 unsigned int offset, 00492 const XalanDOMString& arg); 00493 00494 /** 00495 * Remove a range of characters from the node. 00496 * 00497 * Upon success, 00498 * <code>data</code> and <code>length</code> reflect the change. 00499 * @param offset The offset from which to remove characters. 00500 * @param count The number of characters to delete. If the sum of 00501 * <code>offset</code> and <code>count</code> exceeds <code>length</code> 00502 * then all characters from <code>offset</code> to the end of the data 00503 * are deleted. 00504 * @exception DOMException 00505 * INDEX_SIZE_ERR: Raised if the specified offset is negative or greater 00506 * than the number of characters in <code>data</code>, or if the 00507 * specified <code>count</code> is negative. 00508 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. 00509 */ 00510 virtual void 00511 deleteData( 00512 unsigned int offset, 00513 unsigned int count); 00514 00515 /** 00516 * Replace the characters starting at the specified character offset with 00517 * the specified string. 00518 * 00519 * @param offset The offset from which to start replacing. 00520 * @param count The number of characters to replace. If the sum of 00521 * <code>offset</code> and <code>count</code> exceeds <code>length</code> 00522 * , then all characters to the end of the data are replaced (i.e., the 00523 * effect is the same as a <code>remove</code> method call with the same 00524 * range, followed by an <code>append</code> method invocation). 00525 * @param arg The <code>DOMString</code> with which the range must be 00526 * replaced. 00527 * @exception DOMException 00528 * INDEX_SIZE_ERR: Raised if the specified offset is negative or greater 00529 * than the number of characters in <code>data</code>, or if the 00530 * specified <code>count</code> is negative. 00531 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. 00532 */ 00533 virtual void 00534 replaceData( 00535 unsigned int offset, 00536 unsigned int count, 00537 const XalanDOMString& arg); 00538 00539 //@} 00540 00541 //@} 00542 /** @name Functions to modify the Text node. */ 00543 //@{ 00544 00545 /** 00546 * Breaks this node into two nodes at the specified 00547 * offset, keeping both in the tree as siblings. 00548 * 00549 * This node then only 00550 * contains all the content up to the <code>offset</code> point. And a new 00551 * node of the same nodeType, which is inserted as the next sibling of this 00552 * node, contains all the content at and after the <code>offset</code> 00553 * point. When the <code>offset</code> is equal to the lenght of this node, 00554 * the new node has no data. 00555 * @param offset The offset at which to split, starting from 0. 00556 * @return The new <code>Text</code> node. 00557 * @exception DOMException 00558 * INDEX_SIZE_ERR: Raised if the specified offset is negative or greater 00559 * than the number of characters in <code>data</code>. 00560 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. 00561 */ 00562 virtual XalanText* 00563 splitText(unsigned int offset); 00564 00565 //@} 00566 00567 virtual bool 00568 isWhitespace() const; 00569 00570 /** 00571 * Get the Xerces node this instance represent. 00572 * 00573 * @return The Xerces node 00574 */ 00575 DOM_TextType 00576 getXercesNode() const 00577 { 00578 return m_xercesNode; 00579 } 00580 00581 private: 00582 00583 // Not implemented... 00584 XercesTextBridge(const XercesTextBridge& theSource); 00585 00586 XercesTextBridge& 00587 operator=(const XercesTextBridge& theSource); 00588 00589 bool 00590 operator==(const XercesTextBridge& theRHS) const; 00591 00592 // Data members... 00593 XercesDOM_TextHack m_xercesNode; 00594 00595 const XercesBridgeNavigator& m_navigator; 00596 }; 00597 00598 00599 00600 XALAN_CPP_NAMESPACE_END 00601 00602 00603 00604 #endif // !defined(XERCESTEXTBRIDGE_HEADER_GUARD_1357924680)
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
Xalan-C++ XSLT Processor Version 1.11 |
|