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