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(XERCESDOCUMENTBRIDGE_HEADER_GUARD_1357924680) 00017 #define XERCESDOCUMENTBRIDGE_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 #if XERCES_VERSION_MAJOR >= 2 00032 #include <xercesc/dom/deprecated/DOM_Document.hpp> 00033 #else 00034 #include <xercesc/dom/DOM_Document.hpp> 00035 #endif 00036 00037 00038 00039 #include <xalanc/XalanDOM/XalanDocument.hpp> 00040 00041 00042 00043 #if defined(XALAN_AUTO_PTR_REQUIRES_DEFINITION) 00044 #include <xalanc/XalanDOM/XalanDOMImplementation.hpp> 00045 #include <xalanc/PlatformSupport/XalanDOMStringPool.hpp> 00046 #endif 00047 00048 00049 00050 #include <xalanc/Include/XalanAutoPtr.hpp> 00051 00052 00053 00054 #include <xalanc/DOMSupport/TreeWalker.hpp> 00055 00056 00057 00058 #include <xalanc/XercesParserLiaison/Deprecated/XercesToXalanNodeMap.hpp> 00059 #include <xalanc/XercesParserLiaison/Deprecated/XercesBridgeNavigator.hpp> 00060 #include <xalanc/XercesParserLiaison/Deprecated/XercesNodeListBridge.hpp> 00061 #include <xalanc/XercesParserLiaison/Deprecated/XercesTreeWalker.hpp> 00062 #include <xalanc/XercesParserLiaison/Deprecated/XercesElementBridgeAllocator.hpp> 00063 #include <xalanc/XercesParserLiaison/Deprecated/XercesTextBridgeAllocator.hpp> 00064 #include <xalanc/XercesParserLiaison/Deprecated/XercesAttributeBridgeAllocator.hpp> 00065 00066 00067 00068 XALAN_CPP_NAMESPACE_BEGIN 00069 00070 00071 00072 class XalanDOMStringPool; 00073 class XercesAttrBridge; 00074 class XercesCommentBridge; 00075 class XercesCDATASectionBridge; 00076 class XercesDocumentFragmentBridge; 00077 class XercesDocumentTypeBridge; 00078 class XercesElementBridge; 00079 class XercesEntityBridge; 00080 class XercesEntityReferenceBridge; 00081 class XercesProcessingInstructionBridge; 00082 class XercesNotationBridge; 00083 class XercesTextBridge; 00084 00085 00091 class XALAN_XERCESPARSERLIAISON_EXPORT XercesDocumentBridge : public XalanDocument 00092 { 00093 public: 00094 00095 friend class XercesBridgeNavigator; 00096 00112 XercesDocumentBridge( 00113 const DOM_Document_Type& theXercesDocument, 00114 bool threadSafe = true, 00115 bool buildBridge = true); 00116 00117 virtual 00118 ~XercesDocumentBridge(); 00119 00120 // These interfaces are inherited from XalanNode... 00121 00122 virtual const XalanDOMString& 00123 getNodeName() const; 00124 00125 virtual const XalanDOMString& 00126 getNodeValue() const; 00127 00128 virtual NodeType 00129 getNodeType() const; 00130 00131 virtual XalanNode* 00132 getParentNode() const; 00133 00134 virtual const XalanNodeList* 00135 getChildNodes() const; 00136 00137 virtual XalanNode* 00138 getFirstChild() const; 00139 00140 virtual XalanNode* 00141 getLastChild() const; 00142 00143 virtual XalanNode* 00144 getPreviousSibling() const; 00145 00146 virtual XalanNode* 00147 getNextSibling() const; 00148 00149 virtual const XalanNamedNodeMap* 00150 getAttributes() const; 00151 00152 virtual XalanDocument* 00153 getOwnerDocument() const; 00154 00155 #if defined(XALAN_NO_COVARIANT_RETURN_TYPE) 00156 virtual XalanNode* 00157 #else 00158 virtual XercesDocumentBridge* 00159 #endif 00160 cloneNode(bool deep) const; 00161 00162 virtual XalanNode* 00163 insertBefore( 00164 XalanNode* newChild, 00165 XalanNode* refChild); 00166 00167 virtual XalanNode* 00168 replaceChild( 00169 XalanNode* newChild, 00170 XalanNode* oldChild); 00171 00172 virtual XalanNode* 00173 removeChild(XalanNode* oldChild); 00174 00175 virtual XalanNode* 00176 appendChild(XalanNode* newChild); 00177 00178 virtual bool 00179 hasChildNodes() const; 00180 00181 virtual void 00182 setNodeValue(const XalanDOMString& nodeValue); 00183 00184 virtual void 00185 normalize(); 00186 00187 virtual bool 00188 isSupported( 00189 const XalanDOMString& feature, 00190 const XalanDOMString& version) const; 00191 00192 virtual const XalanDOMString& 00193 getNamespaceURI() const; 00194 00195 virtual const XalanDOMString& 00196 getPrefix() const; 00197 00198 virtual const XalanDOMString& 00199 getLocalName() const; 00200 00201 virtual void 00202 setPrefix(const XalanDOMString& prefix); 00203 00204 virtual bool 00205 isIndexed() const; 00206 00207 virtual IndexType 00208 getIndex() const; 00209 00210 virtual XalanElement* 00211 createElement(const XalanDOMString& tagName); 00212 00213 virtual XalanDocumentFragment* 00214 createDocumentFragment(); 00215 00216 virtual XalanText* 00217 createTextNode(const XalanDOMString& data); 00218 00219 virtual XalanComment* 00220 createComment(const XalanDOMString& data); 00221 00222 virtual XalanCDATASection* 00223 createCDATASection(const XalanDOMString& data); 00224 00225 virtual XalanProcessingInstruction* 00226 createProcessingInstruction( 00227 const XalanDOMString& target, 00228 const XalanDOMString& data); 00229 00230 virtual XalanAttr* 00231 createAttribute(const XalanDOMString& name); 00232 00233 virtual XalanEntityReference* 00234 createEntityReference(const XalanDOMString& name); 00235 00236 virtual XalanDocumentType* 00237 getDoctype() const; 00238 00239 virtual XalanDOMImplementation* 00240 getImplementation() const; 00241 00242 virtual XalanElement* 00243 getDocumentElement() const; 00244 00245 virtual XalanNodeList* 00246 getElementsByTagName(const XalanDOMString& tagname) const; 00247 00248 virtual XalanNode* 00249 importNode( 00250 XalanNode* importedNode, 00251 bool deep); 00252 00253 virtual XalanElement* 00254 createElementNS( 00255 const XalanDOMString& namespaceURI, 00256 const XalanDOMString& qualifiedName); 00257 00258 virtual XalanAttr* 00259 createAttributeNS( 00260 const XalanDOMString& namespaceURI, 00261 const XalanDOMString& qualifiedName); 00262 00263 virtual XalanNodeList* 00264 getElementsByTagNameNS( 00265 const XalanDOMString& namespaceURI, 00266 const XalanDOMString& localName) const; 00267 00268 virtual XalanElement* 00269 getElementById(const XalanDOMString& elementId) const; 00270 00271 // These are some special interfaces to manage relationships between 00272 // our nodes and Xerces nodes. 00273 00281 void 00282 destroyBridge(); 00283 00290 void 00291 rebuildBridge(); 00292 00293 XalanNode* 00294 mapNode(const DOM_NodeType& theXercesNode) const; 00295 00296 XalanAttr* 00297 mapNode(const DOM_AttrType& theXercesNode) const; 00298 00299 XalanElement* 00300 mapNode(const DOM_ElementType& theXercesNode) const; 00301 00302 DOM_NodeType 00303 mapNode(const XalanNode* theXalanNode) const; 00304 00305 DOM_AttrType 00306 mapNode(const XalanAttr* theXalanNode) const; 00307 00308 NodeImplType* 00309 mapNodeToImpl(const XalanNode* theXalanNode) const; 00310 00318 DOM_Document_Type 00319 getXercesDocument() const 00320 { 00321 return m_xercesDocument; 00322 } 00323 00329 void 00330 buildBridgeNodes(); 00331 00332 #if defined(XALAN_NO_STD_NAMESPACE) 00333 typedef deque<XercesBridgeNavigator> NavigatorBridgeVectorType; 00334 00335 typedef deque<XalanNode*> NodeVectorType; 00336 #else 00337 typedef std::deque<XercesBridgeNavigator> NavigatorBridgeVectorType; 00338 00339 typedef std::deque<XalanNode*> NodeVectorType; 00340 #endif 00341 00342 // Helper class to walk the tree and build everything... 00343 class BuildBridgeTreeWalker : public XercesTreeWalker 00344 { 00345 public: 00346 00347 typedef NavigatorBridgeVectorType NavigatorBridgeVectorInnerType; 00348 00349 BuildBridgeTreeWalker( 00350 XercesDocumentBridge* theDocument, 00351 XercesBridgeNavigator* theDocumentNavigator, 00352 NavigatorBridgeVectorInnerType& theNavigators, 00353 IndexType theStartIndex); 00354 00355 virtual 00356 ~BuildBridgeTreeWalker(); 00357 00358 struct NavigatorStackEntryType 00359 { 00360 NavigatorStackEntryType( 00361 XercesBridgeNavigator* theNavigator = 0, 00362 XalanNode* theNode = 0) : 00363 m_navigator(theNavigator), 00364 m_node(theNode) 00365 { 00366 } 00367 00368 XercesBridgeNavigator* m_navigator; 00369 00370 XalanNode* m_node; 00371 }; 00372 00373 #if defined(XALAN_NO_STD_NAMESPACE) 00374 typedef vector<NavigatorStackEntryType> NavigatorStackType; 00375 #else 00376 typedef std::vector<NavigatorStackEntryType> NavigatorStackType; 00377 #endif 00378 00379 protected: 00380 00381 virtual void 00382 startNode(const DOM_NodeType& node); 00383 00384 virtual void 00385 endNode(const DOM_NodeType& node); 00386 00387 private: 00388 00389 XercesDocumentBridge* m_document; 00390 00391 NavigatorBridgeVectorInnerType& m_navigators; 00392 00393 IndexType m_currentIndex; 00394 00395 NavigatorStackType m_parentNavigatorStack; 00396 00397 NavigatorStackType m_siblingNavigatorStack; 00398 }; 00399 00400 00408 const XalanDOMString& 00409 getPooledString(const XalanDOMString& theString) const; 00410 00419 const XalanDOMString& 00420 getPooledString( 00421 const XalanDOMChar* theString, 00422 XalanDOMString::size_type theLength /* = XalanDOMString::npos */) const; 00423 00424 private: 00425 00426 XalanNode* 00427 mapNode(NodeImplType* theXercesNodeImpl) const; 00428 00429 // Destruction API... 00430 void 00431 destroyBridgeNode(XalanNode* theNode); 00432 00433 // Not implemented... 00434 XercesDocumentBridge(const XercesDocumentBridge& theSource); 00435 00436 XercesDocumentBridge& 00437 operator=(const XercesDocumentBridge& theRHS); 00438 00439 bool 00440 operator==(const XercesDocumentBridge& theRHS) const; 00441 00442 // Private delete function... 00443 void 00444 destroyNode(XalanNode* theNode); 00445 00446 // More internal implementation stuff... 00447 XalanNode* 00448 internalCloneNode( 00449 const XalanNode* theXalanNode, 00450 const DOM_NodeType& theXercesNode, 00451 bool deep); 00452 00453 // Factory methods for our implementation nodes... 00454 XalanNode* 00455 createBridgeNode( 00456 const DOM_NodeType& theXercesNode, 00457 IndexType theIndex, 00458 bool mapNode) const; 00459 00460 XercesDocumentTypeBridge* 00461 createBridgeNode( 00462 const DOM_DocumentType_Type& theDoctype, 00463 IndexType theIndex, 00464 bool mapNode) const; 00465 00466 XercesElementBridge* 00467 createBridgeNode( 00468 const DOM_ElementType& theXercesNode, 00469 IndexType theIndex, 00470 bool mapNode) const; 00471 00472 XercesDocumentFragmentBridge* 00473 createBridgeNode( 00474 const DOM_DocumentFragmentType& theXercesNode, 00475 IndexType theIndex, 00476 bool mapNode) const; 00477 00478 XercesTextBridge* 00479 createBridgeNode( 00480 const DOM_TextType& theXercesNode, 00481 IndexType theIndex, 00482 bool mapNode) const; 00483 00484 XercesCommentBridge* 00485 createBridgeNode( 00486 const DOM_CommentType& theXercesNode, 00487 IndexType theIndex, 00488 bool mapNode) const; 00489 00490 XercesCDATASectionBridge* 00491 createBridgeNode( 00492 const DOM_CDATASectionType& theXercesNode, 00493 IndexType theIndex, 00494 bool mapNode) const; 00495 00496 XercesProcessingInstructionBridge* 00497 createBridgeNode( 00498 const DOM_ProcessingInstructionType& theXercesNode, 00499 IndexType theIndex, 00500 bool mapNode) const; 00501 00502 XercesAttrBridge* 00503 createBridgeNode( 00504 const DOM_AttrType& theXercesNode, 00505 IndexType theIndex, 00506 bool mapNode) const; 00507 00508 XercesEntityBridge* 00509 createBridgeNode( 00510 const DOM_EntityType& theXercesNode, 00511 IndexType theIndex, 00512 bool mapNode) const; 00513 00514 XercesEntityReferenceBridge* 00515 createBridgeNode( 00516 const DOM_EntityReferenceType& theXercesNode, 00517 IndexType theIndex, 00518 bool mapNode) const; 00519 00520 XercesNotationBridge* 00521 createBridgeNode( 00522 const DOM_NotationType& theXercesNode, 00523 IndexType theIndex, 00524 bool mapNode) const; 00525 00526 XercesBridgeNavigator& 00527 pushNavigator(bool mappingMode) const; 00528 00529 // This is a private helper class for building the tree... 00530 friend class BuildBridgeTreeWalker; 00531 00532 // $$$ ToDo: This is because DOM_Document::getElementById() is not 00533 // const... 00534 mutable DOM_Document_Type m_xercesDocument; 00535 00536 XalanElement* m_documentElement; 00537 00538 mutable XercesToXalanNodeMap m_nodeMap; 00539 00540 XalanAutoPtr<XalanDOMImplementation> m_domImplementation; 00541 00542 mutable NavigatorBridgeVectorType m_navigators; 00543 00544 // Our navigator will be the first entry in m_navigators, 00545 // but we'll cache this so access is faster... 00546 XercesBridgeNavigator* m_navigator; 00547 00548 XercesNodeListBridge m_children; 00549 00550 mutable NodeVectorType m_nodes; 00551 00552 mutable XercesDocumentTypeBridge* m_doctype; 00553 00554 bool m_mappingMode; 00555 00556 bool m_indexValid; 00557 00558 mutable XercesElementBridgeAllocator m_elementAllocator; 00559 00560 mutable XercesTextBridgeAllocator m_textAllocator; 00561 00562 mutable XercesAttributeBridgeAllocator m_attributeAllocator; 00563 00564 const XalanAutoPtr<XalanDOMStringPool> m_stringPool; 00565 }; 00566 00567 00568 00569 XALAN_CPP_NAMESPACE_END 00570 00571 00572 00573 #endif // !defined(XERCESDOCUMENTBRIDGE_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 |
|