00001 /* 00002 * Copyright 1999-2004 The Apache Software Foundation. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #if !defined(XERCESDOCUMENTWRAPPER_HEADER_GUARD_1357924680) 00017 #define XERCESDOCUMENTWRAPPER_HEADER_GUARD_1357924680 00018 00019 00020 00021 #include <xalanc/XercesParserLiaison/XercesParserLiaisonDefinitions.hpp> 00022 00023 00024 00025 #include <xalanc/Include/XalanVector.hpp> 00026 00027 00028 00029 #include <xalanc/XalanDOM/XalanDocument.hpp> 00030 00031 00032 00033 #if defined(XALAN_AUTO_PTR_REQUIRES_DEFINITION) 00034 #include <xalanc/XalanDOM/XalanDOMImplementation.hpp> 00035 #include <xalanc/PlatformSupport/XalanDOMStringPool.hpp> 00036 #endif 00037 00038 00039 00040 #include <xalanc/Include/XalanMemMgrAutoPtr.hpp> 00041 00042 00043 00044 #include <xalanc/XercesParserLiaison/XercesDOMWalker.hpp> 00045 #include <xalanc/XercesParserLiaison/XercesWrapperNavigator.hpp> 00046 00047 00048 #include <xalanc/XercesParserLiaison/XercesWrapperToXalanNodeMap.hpp> 00049 #include <xalanc/XercesParserLiaison/XercesNodeListWrapper.hpp> 00050 #include <xalanc/XercesParserLiaison/XercesAttrWrapperAllocator.hpp> 00051 #include <xalanc/XercesParserLiaison/XercesElementWrapperAllocator.hpp> 00052 #include <xalanc/XercesParserLiaison/XercesTextWrapperAllocator.hpp> 00053 #include <xalanc/XercesParserLiaison/XercesWrapperNavigatorAllocator.hpp> 00054 00055 00056 #include <xalanc/XercesParserLiaison/XercesWrapperTypes.hpp> 00057 00058 00059 00060 XALAN_CPP_NAMESPACE_BEGIN 00061 00062 00063 00064 class XalanDOMStringPool; 00065 class XercesCommentWrapper; 00066 class XercesCDATASectionWrapper; 00067 class XercesDocumentFragmentWrapper; 00068 class XercesDocumentTypeWrapper; 00069 class XercesEntityWrapper; 00070 class XercesEntityReferenceWrapper; 00071 class XercesProcessingInstructionWrapper; 00072 class XercesNotationWrapper; 00073 00074 00075 00076 class XALAN_XERCESPARSERLIAISON_EXPORT XercesDocumentWrapper : public XalanDocument 00077 { 00078 public: 00079 00080 friend class XercesWrapperNavigator; 00081 00098 XercesDocumentWrapper( 00099 MemoryManagerType& theManager, 00100 const DOMDocument_Type* theXercesDocument, 00101 bool threadSafe = true, 00102 bool buildWrapper = true, 00103 bool buildMaps = false); 00104 00105 static XercesDocumentWrapper* 00106 create( 00107 MemoryManagerType& theManager, 00108 const DOMDocument_Type* theXercesDocument, 00109 bool threadSafe, 00110 bool buildWrapper, 00111 bool buildMaps); 00112 00113 MemoryManagerType& 00114 getMemoryManager() const 00115 { 00116 return m_nodeMap.getMemoryManager(); 00117 } 00118 00119 virtual 00120 ~XercesDocumentWrapper(); 00121 00122 // These interfaces are inherited from XalanNode... 00123 00124 virtual const XalanDOMString& 00125 getNodeName() const; 00126 00127 virtual const XalanDOMString& 00128 getNodeValue() const; 00129 00130 virtual NodeType 00131 getNodeType() const; 00132 00133 virtual XalanNode* 00134 getParentNode() const; 00135 00136 virtual const XalanNodeList* 00137 getChildNodes() const; 00138 00139 virtual XalanNode* 00140 getFirstChild() const; 00141 00142 virtual XalanNode* 00143 getLastChild() const; 00144 00145 virtual XalanNode* 00146 getPreviousSibling() const; 00147 00148 virtual XalanNode* 00149 getNextSibling() const; 00150 00151 virtual const XalanNamedNodeMap* 00152 getAttributes() const; 00153 00154 virtual XalanDocument* 00155 getOwnerDocument() const; 00156 00157 #if defined(XALAN_NO_COVARIANT_RETURN_TYPE) 00158 virtual XalanNode* 00159 #else 00160 virtual XercesDocumentWrapper* 00161 #endif 00162 cloneNode(bool deep) const; 00163 00164 virtual XalanNode* 00165 insertBefore( 00166 XalanNode* newChild, 00167 XalanNode* refChild); 00168 00169 virtual XalanNode* 00170 replaceChild( 00171 XalanNode* newChild, 00172 XalanNode* oldChild); 00173 00174 virtual XalanNode* 00175 removeChild(XalanNode* oldChild); 00176 00177 virtual XalanNode* 00178 appendChild(XalanNode* newChild); 00179 00180 virtual bool 00181 hasChildNodes() const; 00182 00183 virtual void 00184 setNodeValue(const XalanDOMString& nodeValue); 00185 00186 virtual void 00187 normalize(); 00188 00189 virtual bool 00190 isSupported( 00191 const XalanDOMString& feature, 00192 const XalanDOMString& version) const; 00193 00194 virtual const XalanDOMString& 00195 getNamespaceURI() const; 00196 00197 virtual const XalanDOMString& 00198 getPrefix() const; 00199 00200 virtual const XalanDOMString& 00201 getLocalName() const; 00202 00203 virtual void 00204 setPrefix(const XalanDOMString& prefix); 00205 00206 virtual bool 00207 isIndexed() const; 00208 00209 virtual IndexType 00210 getIndex() const; 00211 00212 virtual XalanElement* 00213 createElement(const XalanDOMString& tagName); 00214 00215 virtual XalanDocumentFragment* 00216 createDocumentFragment(); 00217 00218 virtual XalanText* 00219 createTextNode(const XalanDOMString& data); 00220 00221 virtual XalanComment* 00222 createComment(const XalanDOMString& data); 00223 00224 virtual XalanCDATASection* 00225 createCDATASection(const XalanDOMString& data); 00226 00227 virtual XalanProcessingInstruction* 00228 createProcessingInstruction( 00229 const XalanDOMString& target, 00230 const XalanDOMString& data); 00231 00232 virtual XalanAttr* 00233 createAttribute(const XalanDOMString& name); 00234 00235 virtual XalanEntityReference* 00236 createEntityReference(const XalanDOMString& name); 00237 00238 virtual XalanDocumentType* 00239 getDoctype() const; 00240 00241 virtual XalanDOMImplementation* 00242 getImplementation() const; 00243 00244 virtual XalanElement* 00245 getDocumentElement() const; 00246 00247 virtual XalanNodeList* 00248 getElementsByTagName(const XalanDOMString& tagname) const; 00249 00250 virtual XalanNode* 00251 importNode( 00252 XalanNode* importedNode, 00253 bool deep); 00254 00255 virtual XalanElement* 00256 createElementNS( 00257 const XalanDOMString& namespaceURI, 00258 const XalanDOMString& qualifiedName); 00259 00260 virtual XalanAttr* 00261 createAttributeNS( 00262 const XalanDOMString& namespaceURI, 00263 const XalanDOMString& qualifiedName); 00264 00265 virtual XalanNodeList* 00266 getElementsByTagNameNS( 00267 const XalanDOMString& namespaceURI, 00268 const XalanDOMString& localName) const; 00269 00270 virtual XalanElement* 00271 getElementById(const XalanDOMString& elementId) const; 00272 00273 // These are some special interfaces to manage relationships between 00274 // our nodes and Xerces nodes. 00275 00283 void 00284 destroyWrapper(); 00285 00292 void 00293 rebuildWrapper(); 00294 00305 XalanNode* 00306 mapNode(const DOMNodeType* theXercesNode) const; 00307 00318 XalanAttr* 00319 mapNode(const DOMAttrType* theXercesNode) const; 00320 00331 XalanElement* 00332 mapNode(const DOMElementType* theXercesNode) const; 00333 00344 const DOMNodeType* 00345 mapNode(XalanNode* theXalanNode) const; 00346 00354 const DOMDocument_Type* 00355 getXercesDocument() const 00356 { 00357 return m_xercesDocument; 00358 } 00359 00365 void 00366 buildWrapperNodes(); 00367 00368 typedef XalanVector<XalanNode*> NodeVectorType; 00369 00370 // Helper class to walk the tree and build everything... 00371 class BuildWrapperTreeWalker : public XercesDOMWalker 00372 { 00373 public: 00374 00375 typedef XercesDOMWalker ParentType; 00376 00377 BuildWrapperTreeWalker( 00378 XercesDocumentWrapper* theDocument, 00379 XercesWrapperNavigator* theDocumentNavigator, 00380 IndexType theStartIndex, 00381 bool theBuildMapsFlag); 00382 00383 virtual 00384 ~BuildWrapperTreeWalker(); 00385 00386 struct NavigatorStackEntryType 00387 { 00388 NavigatorStackEntryType( 00389 XercesWrapperNavigator* theNavigator = 0, 00390 XalanNode* theNode = 0) : 00391 m_navigator(theNavigator), 00392 m_node(theNode) 00393 { 00394 } 00395 00396 XercesWrapperNavigator* m_navigator; 00397 00398 XalanNode* m_node; 00399 }; 00400 00401 typedef XalanVector<NavigatorStackEntryType> NavigatorStackType; 00402 00403 protected: 00404 00405 virtual bool 00406 startNode(const DOMNodeType* node); 00407 00408 virtual bool 00409 endNode(const DOMNodeType* node); 00410 00411 #if !defined(XALAN_NO_USING_DECLARATION) 00412 using ParentType::startNode; 00413 using ParentType::endNode; 00414 #endif 00415 00416 private: 00417 00418 XercesDocumentWrapper* m_document; 00419 00420 IndexType m_currentIndex; 00421 00422 NavigatorStackType m_parentNavigatorStack; 00423 00424 NavigatorStackType m_siblingNavigatorStack; 00425 00426 const bool m_buildMaps; 00427 }; 00428 00429 00437 const XalanDOMString& 00438 getPooledString(const XalanDOMString& theString) const; 00439 00448 const XalanDOMString& 00449 getPooledString( 00450 const XalanDOMChar* theString, 00451 XalanDOMString::size_type theLength /* = XalanDOMString::npos */) const; 00452 00453 bool 00454 getMappingMode() const 00455 { 00456 return m_mappingMode; 00457 } 00458 00459 private: 00460 00461 // Destruction API... 00462 void 00463 destroyWrapperNode(XalanNode* theNode); 00464 00465 // Not implemented... 00466 XercesDocumentWrapper(const XercesDocumentWrapper& theSource); 00467 00468 XercesDocumentWrapper& 00469 operator=(const XercesDocumentWrapper& theRHS); 00470 00471 bool 00472 operator==(const XercesDocumentWrapper& theRHS) const; 00473 00474 // Private delete function... 00475 void 00476 destroyNode(XalanNode* theNode); 00477 00478 // More internal implementation stuff... 00479 00480 // Factory methods for our implementation nodes... 00481 XalanNode* 00482 createWrapperNode( 00483 const DOMNodeType* theXercesNode, 00484 IndexType theIndex, 00485 bool mapNode, 00486 XercesWrapperNavigator** theWrapperNodeNavigator = 0) const; 00487 00488 XercesDocumentTypeWrapper* 00489 createWrapperNode( 00490 const DOMDocumentType_Type* theDoctype, 00491 IndexType theIndex, 00492 bool mapNode, 00493 XercesWrapperNavigator** theWrapperNodeNavigator = 0) const; 00494 00495 XercesElementWrapper* 00496 createWrapperNode( 00497 const DOMElementType* theXercesNode, 00498 IndexType theIndex, 00499 bool mapNode, 00500 XercesWrapperNavigator** theWrapperNodeNavigator = 0) const; 00501 00502 XercesTextWrapper* 00503 createWrapperNode( 00504 const DOMTextType* theXercesNode, 00505 IndexType theIndex, 00506 bool mapNode, 00507 XercesWrapperNavigator** theWrapperNodeNavigator = 0) const; 00508 00509 XercesCommentWrapper* 00510 createWrapperNode( 00511 const DOMCommentType* theXercesNode, 00512 IndexType theIndex, 00513 bool mapNode, 00514 XercesWrapperNavigator** theWrapperNodeNavigator = 0) const; 00515 00516 XercesCDATASectionWrapper* 00517 createWrapperNode( 00518 const DOMCDATASectionType* theXercesNode, 00519 IndexType theIndex, 00520 bool mapNode, 00521 XercesWrapperNavigator** theWrapperNodeNavigator = 0) const; 00522 00523 XercesProcessingInstructionWrapper* 00524 createWrapperNode( 00525 const DOMProcessingInstructionType* theXercesNode, 00526 IndexType theIndex, 00527 bool mapNode, 00528 XercesWrapperNavigator** theWrapperNodeNavigator = 0) const; 00529 00530 XercesAttrWrapper* 00531 createWrapperNode( 00532 const DOMAttrType* theXercesNode, 00533 IndexType theIndex, 00534 bool mapNode, 00535 XercesWrapperNavigator** theWrapperNodeNavigator = 0) const; 00536 00537 XercesEntityWrapper* 00538 createWrapperNode( 00539 const DOMEntityType* theXercesNode, 00540 IndexType theIndex, 00541 bool mapNode, 00542 XercesWrapperNavigator** theWrapperNodeNavigator = 0) const; 00543 00544 XercesEntityReferenceWrapper* 00545 createWrapperNode( 00546 const DOMEntityReferenceType* theXercesNode, 00547 IndexType theIndex, 00548 bool mapNode, 00549 XercesWrapperNavigator** theWrapperNodeNavigator = 0) const; 00550 00551 XercesNotationWrapper* 00552 createWrapperNode( 00553 const DOMNotationType* theXercesNode, 00554 IndexType theIndex, 00555 bool mapNode, 00556 XercesWrapperNavigator** theWrapperNodeNavigator = 0) const; 00557 00558 XercesWrapperNavigator& 00559 createNavigator() const; 00560 00561 // This is a private helper class for building the tree... 00562 friend class BuildWrapperTreeWalker; 00563 00564 const DOMDocument_Type* const m_xercesDocument; 00565 00566 XalanElement* m_documentElement; 00567 00568 mutable XercesWrapperToXalanNodeMap m_nodeMap; 00569 00570 XalanMemMgrAutoPtr<XalanDOMImplementation, true> m_domImplementation; 00571 00572 mutable XercesWrapperNavigatorAllocator m_navigatorAllocator; 00573 00574 // Our navigator will be the first entry in m_navigators, 00575 // but we'll cache this so access is faster... 00576 XercesWrapperNavigator* m_navigator; 00577 00578 XercesNodeListWrapper m_children; 00579 00580 mutable NodeVectorType m_nodes; 00581 00582 mutable XercesDocumentTypeWrapper* m_doctype; 00583 00584 bool m_mappingMode; 00585 00586 bool m_indexValid; 00587 00588 const bool m_buildMaps; 00589 00590 mutable XercesElementWrapperAllocator m_elementAllocator; 00591 00592 mutable XercesTextWrapperAllocator m_textAllocator; 00593 00594 mutable XercesAttrWrapperAllocator m_attributeAllocator; 00595 00596 const XalanMemMgrAutoPtr<XalanDOMStringPool,true> m_stringPool; 00597 }; 00598 00599 00600 00601 XALAN_CPP_NAMESPACE_END 00602 00603 00604 00605 #endif // !defined(XERCESDOCUMENTWRAPPER_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.10 |
|