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