00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 1999 The Apache Software Foundation. All rights 00006 * reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 00012 * 1. Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * 00015 * 2. Redistributions in binary form must reproduce the above copyright 00016 * notice, this list of conditions and the following disclaimer in 00017 * the documentation and/or other materials provided with the 00018 * distribution. 00019 * 00020 * 3. The end-user documentation included with the redistribution, 00021 * if any, must include the following acknowledgment: 00022 * "This product includes software developed by the 00023 * Apache Software Foundation (http://www.apache.org/)." 00024 * Alternately, this acknowledgment may appear in the software itself, 00025 * if and wherever such third-party acknowledgments normally appear. 00026 * 00027 * 4. The names "Xalan" and "Apache Software Foundation" must 00028 * not be used to endorse or promote products derived from this 00029 * software without prior written permission. For written 00030 * permission, please contact apache@apache.org. 00031 * 00032 * 5. Products derived from this software may not be called "Apache", 00033 * nor may "Apache" appear in their name, without prior written 00034 * permission of the Apache Software Foundation. 00035 * 00036 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 00037 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00038 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00039 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 00040 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00041 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00042 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 00043 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00044 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00045 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00046 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00047 * SUCH DAMAGE. 00048 * ==================================================================== 00049 * 00050 * This software consists of voluntary contributions made by many 00051 * individuals on behalf of the Apache Software Foundation and was 00052 * originally based on software copyright (c) 1999, International 00053 * Business Machines, Inc., http://www.ibm.com. For more 00054 * information on the Apache Software Foundation, please see 00055 * <http://www.apache.org/>. 00056 */ 00057 #if !defined(XERCESDOCUMENTBRIDGE_HEADER_GUARD_1357924680) 00058 #define XERCESDOCUMENTBRIDGE_HEADER_GUARD_1357924680 00059 00060 00061 00062 #include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp> 00063 00064 00065 00066 #include <deque> 00067 #include <set> 00068 #include <vector> 00069 00070 00071 00072 #include <dom/DOM_Document.hpp> 00073 00074 00075 00076 #include <XalanDOM/XalanDocument.hpp> 00077 00078 00079 00080 #if defined(XALAN_AUTO_PTR_REQUIRES_DEFINITION) 00081 #include <XalanDOM/XalanDOMImplementation.hpp> 00082 #include <PlatformSupport/XalanDOMStringPool.hpp> 00083 #endif 00084 00085 00086 00087 #include <Include/XalanAutoPtr.hpp> 00088 00089 00090 00091 #include <DOMSupport/TreeWalker.hpp> 00092 00093 00094 00095 #include <XercesParserLiaison/XercesToXalanNodeMap.hpp> 00096 #include <XercesParserLiaison/XercesBridgeNavigator.hpp> 00097 #include <XercesParserLiaison/XercesNodeListBridge.hpp> 00098 #include <XercesParserLiaison/XercesTreeWalker.hpp> 00099 #include <XercesParserLiaison/XercesElementBridgeAllocator.hpp> 00100 #include <XercesParserLiaison/XercesTextBridgeAllocator.hpp> 00101 #include <XercesParserLiaison/XercesAttributeBridgeAllocator.hpp> 00102 00103 00104 00105 class XalanDOMStringPool; 00106 class XercesAttrBridge; 00107 class XercesCommentBridge; 00108 class XercesCDATASectionBridge; 00109 class XercesDocumentFragmentBridge; 00110 class XercesDocumentTypeBridge; 00111 class XercesElementBridge; 00112 class XercesEntityBridge; 00113 class XercesEntityReferenceBridge; 00114 class XercesProcessingInstructionBridge; 00115 class XercesNotationBridge; 00116 class XercesTextBridge; 00117 00118 00119 00120 class XALAN_XERCESPARSERLIAISON_EXPORT XercesDocumentBridge : public XalanDocument 00121 { 00122 public: 00123 00124 friend class XercesBridgeNavigator; 00125 00142 XercesDocumentBridge( 00143 const DOM_Document& theXercesDocument, 00144 unsigned long theNumber = ~0UL, 00145 bool threadSafe = true, 00146 bool buildBridge = true); 00147 00148 virtual 00149 ~XercesDocumentBridge(); 00150 00151 // These interfaces are inherited from XalanNode... 00152 00153 virtual const XalanDOMString& 00154 getNodeName() const; 00155 00156 virtual const XalanDOMString& 00157 getNodeValue() const; 00158 00159 virtual NodeType 00160 getNodeType() const; 00161 00162 virtual XalanNode* 00163 getParentNode() const; 00164 00165 virtual const XalanNodeList* 00166 getChildNodes() const; 00167 00168 virtual XalanNode* 00169 getFirstChild() const; 00170 00171 virtual XalanNode* 00172 getLastChild() const; 00173 00174 virtual XalanNode* 00175 getPreviousSibling() const; 00176 00177 virtual XalanNode* 00178 getNextSibling() const; 00179 00180 virtual const XalanNamedNodeMap* 00181 getAttributes() const; 00182 00183 virtual XalanDocument* 00184 getOwnerDocument() const; 00185 00186 #if defined(XALAN_NO_COVARIANT_RETURN_TYPE) 00187 virtual XalanNode* 00188 #else 00189 virtual XercesDocumentBridge* 00190 #endif 00191 cloneNode(bool deep) const; 00192 00193 virtual XalanNode* 00194 insertBefore( 00195 XalanNode* newChild, 00196 XalanNode* refChild); 00197 00198 virtual XalanNode* 00199 replaceChild( 00200 XalanNode* newChild, 00201 XalanNode* oldChild); 00202 00203 virtual XalanNode* 00204 removeChild(XalanNode* oldChild); 00205 00206 virtual XalanNode* 00207 appendChild(XalanNode* newChild); 00208 00209 virtual bool 00210 hasChildNodes() const; 00211 00212 virtual void 00213 setNodeValue(const XalanDOMString& nodeValue); 00214 00215 virtual void 00216 normalize(); 00217 00218 virtual bool 00219 supports( 00220 const XalanDOMString& feature, 00221 const XalanDOMString& version) const; 00222 00223 virtual const XalanDOMString& 00224 getNamespaceURI() const; 00225 00226 virtual const XalanDOMString& 00227 getPrefix() const; 00228 00229 virtual const XalanDOMString& 00230 getLocalName() const; 00231 00232 virtual void 00233 setPrefix(const XalanDOMString& prefix); 00234 00235 virtual bool 00236 isIndexed() const; 00237 00238 virtual unsigned long 00239 getIndex() const; 00240 00241 virtual XalanElement* 00242 createElement(const XalanDOMString& tagName); 00243 00244 virtual XalanDocumentFragment* 00245 createDocumentFragment(); 00246 00247 virtual XalanText* 00248 createTextNode(const XalanDOMString& data); 00249 00250 virtual XalanComment* 00251 createComment(const XalanDOMString& data); 00252 00253 virtual XalanCDATASection* 00254 createCDATASection(const XalanDOMString& data); 00255 00256 virtual XalanProcessingInstruction* 00257 createProcessingInstruction( 00258 const XalanDOMString& target, 00259 const XalanDOMString& data); 00260 00261 virtual XalanAttr* 00262 createAttribute(const XalanDOMString& name); 00263 00264 virtual XalanEntityReference* 00265 createEntityReference(const XalanDOMString& name); 00266 00267 virtual XalanDocumentType* 00268 getDoctype() const; 00269 00270 virtual XalanDOMImplementation* 00271 getImplementation() const; 00272 00273 virtual XalanElement* 00274 getDocumentElement() const; 00275 00276 virtual XalanNodeList* 00277 getElementsByTagName(const XalanDOMString& tagname) const; 00278 00279 virtual XalanNode* 00280 importNode( 00281 XalanNode* importedNode, 00282 bool deep); 00283 00284 virtual XalanElement* 00285 createElementNS( 00286 const XalanDOMString& namespaceURI, 00287 const XalanDOMString& qualifiedName); 00288 00289 virtual XalanAttr* 00290 createAttributeNS( 00291 const XalanDOMString& namespaceURI, 00292 const XalanDOMString& qualifiedName); 00293 00294 virtual XalanNodeList* 00295 getElementsByTagNameNS( 00296 const XalanDOMString& namespaceURI, 00297 const XalanDOMString& localName) const; 00298 00299 virtual XalanElement* 00300 getElementById(const XalanDOMString& elementId) const; 00301 00302 virtual unsigned long 00303 getNumber() const; 00304 00305 // These are some special interfaces to manage relationships between 00306 // our nodes and Xerces nodes. 00307 00315 void 00316 destroyBridge(); 00317 00324 void 00325 rebuildBridge(); 00326 00327 XalanNode* 00328 mapNode(const DOM_Node& theXercesNode) const; 00329 00330 XalanAttr* 00331 mapNode(const DOM_Attr& theXercesNode) const; 00332 00333 XalanElement* 00334 mapNode(const DOM_Element& theXercesNode) const; 00335 00336 DOM_Node 00337 mapNode(const XalanNode* theXalanNode) const; 00338 00339 DOM_Attr 00340 mapNode(const XalanAttr* theXalanNode) const; 00341 00342 NodeImpl* 00343 mapNodeToImpl(const XalanNode* theXalanNode) const; 00344 00352 DOM_Document 00353 getXercesDocument() const 00354 { 00355 return m_xercesDocument; 00356 } 00357 00363 void 00364 buildBridgeNodes(); 00365 00366 #if defined(XALAN_NO_NAMESPACES) 00367 typedef deque<XercesBridgeNavigator> NavigatorBridgeVectorType; 00368 00369 typedef deque<XalanNode*> NodeVectorType; 00370 #else 00371 typedef std::deque<XercesBridgeNavigator> NavigatorBridgeVectorType; 00372 00373 typedef std::deque<XalanNode*> NodeVectorType; 00374 #endif 00375 00376 // Helper class to walk the tree and build everything... 00377 class BuildBridgeTreeWalker : public XercesTreeWalker 00378 { 00379 public: 00380 00381 typedef NavigatorBridgeVectorType NavigatorBridgeVectorInnerType; 00382 00383 BuildBridgeTreeWalker( 00384 XercesDocumentBridge* theDocument, 00385 XercesBridgeNavigator* theDocumentNavigator, 00386 NavigatorBridgeVectorInnerType& theNavigators, 00387 unsigned long theStartIndex); 00388 00389 virtual 00390 ~BuildBridgeTreeWalker(); 00391 00392 struct NavigatorStackEntryType 00393 { 00394 NavigatorStackEntryType( 00395 XercesBridgeNavigator* theNavigator = 0, 00396 XalanNode* theNode = 0) : 00397 m_navigator(theNavigator), 00398 m_node(theNode) 00399 { 00400 } 00401 00402 XercesBridgeNavigator* m_navigator; 00403 00404 XalanNode* m_node; 00405 }; 00406 00407 #if defined(XALAN_NO_NAMESPACES) 00408 typedef vector<NavigatorStackEntryType> NavigatorStackType; 00409 #else 00410 typedef std::vector<NavigatorStackEntryType> NavigatorStackType; 00411 #endif 00412 00413 protected: 00414 00415 virtual void 00416 startNode(const DOM_Node& node); 00417 00418 virtual void 00419 endNode(const DOM_Node& node); 00420 00421 private: 00422 00423 XercesDocumentBridge* m_document; 00424 00425 NavigatorBridgeVectorInnerType& m_navigators; 00426 00427 unsigned long m_currentIndex; 00428 00429 NavigatorStackType m_parentNavigatorStack; 00430 00431 NavigatorStackType m_siblingNavigatorStack; 00432 }; 00433 00434 00442 const XalanDOMString& 00443 getPooledString(const XalanDOMString& theString) const; 00444 00452 const XalanDOMString& 00453 getPooledString(const XalanDOMChar* theString) const; 00454 00455 private: 00456 00457 XalanNode* 00458 mapNode(NodeImpl* theXercesNodeImpl) const; 00459 00460 // Destruction API... 00461 void 00462 destroyBridgeNode(XalanNode* theNode); 00463 00464 // Not implemented... 00465 XercesDocumentBridge(const XercesDocumentBridge& theSource); 00466 00467 XercesDocumentBridge& 00468 operator=(const XercesDocumentBridge& theRHS); 00469 00470 bool 00471 operator==(const XercesDocumentBridge& theRHS) const; 00472 00473 // Private delete function... 00474 void 00475 destroyNode(XalanNode* theNode); 00476 00477 // More internal implementation stuff... 00478 XalanNode* 00479 internalCloneNode( 00480 const XalanNode* theXalanNode, 00481 const DOM_Node& theXercesNode, 00482 bool deep); 00483 00484 // Factory methods for our implementation nodes... 00485 XalanNode* 00486 createBridgeNode( 00487 const DOM_Node& theXercesNode, 00488 unsigned long theIndex, 00489 bool mapNode) const; 00490 00491 XercesDocumentTypeBridge* 00492 createBridgeNode( 00493 const DOM_DocumentType& theDoctype, 00494 unsigned long theIndex, 00495 bool mapNode) const; 00496 00497 XercesElementBridge* 00498 createBridgeNode( 00499 const DOM_Element& theXercesNode, 00500 unsigned long theIndex, 00501 bool mapNode) const; 00502 00503 XercesDocumentFragmentBridge* 00504 createBridgeNode( 00505 const DOM_DocumentFragment& theXercesNode, 00506 unsigned long theIndex, 00507 bool mapNode) const; 00508 00509 XercesTextBridge* 00510 createBridgeNode( 00511 const DOM_Text& theXercesNode, 00512 unsigned long theIndex, 00513 bool mapNode) const; 00514 00515 XercesCommentBridge* 00516 createBridgeNode( 00517 const DOM_Comment& theXercesNode, 00518 unsigned long theIndex, 00519 bool mapNode) const; 00520 00521 XercesCDATASectionBridge* 00522 createBridgeNode( 00523 const DOM_CDATASection& theXercesNode, 00524 unsigned long theIndex, 00525 bool mapNode) const; 00526 00527 XercesProcessingInstructionBridge* 00528 createBridgeNode( 00529 const DOM_ProcessingInstruction& theXercesNode, 00530 unsigned long theIndex, 00531 bool mapNode) const; 00532 00533 XercesAttrBridge* 00534 createBridgeNode( 00535 const DOM_Attr& theXercesNode, 00536 unsigned long theIndex, 00537 bool mapNode) const; 00538 00539 XercesEntityBridge* 00540 createBridgeNode( 00541 const DOM_Entity& theXercesNode, 00542 unsigned long theIndex, 00543 bool mapNode) const; 00544 00545 XercesEntityReferenceBridge* 00546 createBridgeNode( 00547 const DOM_EntityReference& theXercesNode, 00548 unsigned long theIndex, 00549 bool mapNode) const; 00550 00551 XercesNotationBridge* 00552 createBridgeNode( 00553 const DOM_Notation& theXercesNode, 00554 unsigned long theIndex, 00555 bool mapNode) const; 00556 00557 XercesBridgeNavigator& 00558 pushNavigator(bool mappingMode) const; 00559 00560 // This is a private helper class for building the tree... 00561 friend class BuildBridgeTreeWalker; 00562 00563 const unsigned long m_number; 00564 00565 // $$$ ToDo: This is because DOM_Document::getElementById() is not 00566 // const... 00567 mutable DOM_Document m_xercesDocument; 00568 00569 XalanElement* m_documentElement; 00570 00571 mutable XercesToXalanNodeMap m_nodeMap; 00572 00573 XalanAutoPtr<XalanDOMImplementation> m_domImplementation; 00574 00575 mutable NavigatorBridgeVectorType m_navigators; 00576 00577 // Our navigator will be the first entry in m_navigators, 00578 // but we'll cache this so access is faster... 00579 XercesBridgeNavigator* m_navigator; 00580 00581 XercesNodeListBridge m_children; 00582 00583 mutable NodeVectorType m_nodes; 00584 00585 mutable XercesDocumentTypeBridge* m_doctype; 00586 00587 bool m_mappingMode; 00588 00589 bool m_indexValid; 00590 00591 mutable XercesElementBridgeAllocator m_elementAllocator; 00592 00593 mutable XercesTextBridgeAllocator m_textAllocator; 00594 00595 mutable XercesAttributeBridgeAllocator m_attributeAllocator; 00596 00597 const XalanAutoPtr<XalanDOMStringPool> m_stringPool; 00598 }; 00599 00600 00601 00602 #endif // !defined(XERCESDOCUMENTBRIDGE_HEADER_GUARD_1357924680)
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
![]() |
Xalan-C++ XSL Transformer Version 1.1 |
|