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 #endif 00083 00084 00085 00086 #include <PlatformSupport/XalanAutoPtr.hpp> 00087 00088 00089 00090 #include <DOMSupport/TreeWalker.hpp> 00091 00092 00093 00094 #include <XercesParserLiaison/XercesToXalanNodeMap.hpp> 00095 #include <XercesParserLiaison/XercesBridgeNavigator.hpp> 00096 #include <XercesParserLiaison/XercesDocumentNamedNodeListCache.hpp> 00097 #include <XercesParserLiaison/XercesNodeListBridge.hpp> 00098 #include <XercesParserLiaison/XercesTreeWalker.hpp> 00099 00100 00101 #define XALAN_USE_BLOCK_ALLOCATORS 00102 00103 #if defined(XALAN_USE_BLOCK_ALLOCATORS) 00104 #include <XercesParserLiaison/XercesElementBridgeAllocator.hpp> 00105 #include <XercesParserLiaison/XercesTextBridgeAllocator.hpp> 00106 #include <XercesParserLiaison/XercesAttributeBridgeAllocator.hpp> 00107 #endif 00108 00109 00110 00111 class XercesAttrBridge; 00112 class XercesCommentBridge; 00113 class XercesCDATASectionBridge; 00114 class XercesDocumentFragmentBridge; 00115 class XercesDocumentTypeBridge; 00116 class XercesElementBridge; 00117 class XercesEntityBridge; 00118 class XercesEntityReferenceBridge; 00119 class XercesProcessingInstructionBridge; 00120 class XercesNotationBridge; 00121 class XercesTextBridge; 00122 00123 00124 00125 class XALAN_XERCESPARSERLIAISON_EXPORT XercesDocumentBridge : public XalanDocument 00126 { 00127 public: 00128 00129 friend class XercesBridgeNavigator; 00130 00145 XercesDocumentBridge( 00146 const DOM_Document& theXercesDocument, 00147 bool buildBridge = true); 00148 00149 virtual 00150 ~XercesDocumentBridge(); 00151 00152 // These interfaces are inherited from XalanNode... 00153 00154 virtual XalanDOMString 00155 getNodeName() const; 00156 00157 virtual XalanDOMString 00158 getNodeValue() const; 00159 00160 virtual NodeType 00161 getNodeType() const; 00162 00163 virtual XalanNode* 00164 getParentNode() const; 00165 00166 virtual const XalanNodeList* 00167 getChildNodes() const; 00168 00169 virtual XalanNode* 00170 getFirstChild() const; 00171 00172 virtual XalanNode* 00173 getLastChild() const; 00174 00175 virtual XalanNode* 00176 getPreviousSibling() const; 00177 00178 virtual XalanNode* 00179 getNextSibling() const; 00180 00181 virtual const XalanNamedNodeMap* 00182 getAttributes() const; 00183 00184 virtual XalanDocument* 00185 getOwnerDocument() const; 00186 00187 #if defined(XALAN_NO_COVARIANT_RETURN_TYPE) 00188 virtual XalanNode* 00189 #else 00190 virtual XercesDocumentBridge* 00191 #endif 00192 cloneNode(bool deep) const; 00193 00194 virtual XalanNode* 00195 insertBefore( 00196 XalanNode* newChild, 00197 XalanNode* refChild); 00198 00199 virtual XalanNode* 00200 replaceChild( 00201 XalanNode* newChild, 00202 XalanNode* oldChild); 00203 00204 virtual XalanNode* 00205 removeChild(XalanNode* oldChild); 00206 00207 virtual XalanNode* 00208 appendChild(XalanNode* newChild); 00209 00210 virtual bool 00211 hasChildNodes() const; 00212 00213 virtual void 00214 setNodeValue(const XalanDOMString& nodeValue); 00215 00216 virtual void 00217 normalize(); 00218 00219 virtual bool 00220 supports( 00221 const XalanDOMString& feature, 00222 const XalanDOMString& version) const; 00223 00224 virtual XalanDOMString 00225 getNamespaceURI() const; 00226 00227 virtual XalanDOMString 00228 getPrefix() const; 00229 00230 virtual XalanDOMString 00231 getLocalName() const; 00232 00233 virtual void 00234 setPrefix(const XalanDOMString& prefix); 00235 00236 virtual bool 00237 isIndexed() const; 00238 00239 virtual unsigned long 00240 getIndex() const; 00241 00242 virtual XalanDOMString 00243 getXSLTData() const; 00244 00245 virtual XalanElement* 00246 createElement(const XalanDOMString& tagName); 00247 00248 virtual XalanDocumentFragment* 00249 createDocumentFragment(); 00250 00251 virtual XalanText* 00252 createTextNode(const XalanDOMString& data); 00253 00254 virtual XalanComment* 00255 createComment(const XalanDOMString& data); 00256 00257 virtual XalanCDATASection* 00258 createCDATASection(const XalanDOMString& data); 00259 00260 virtual XalanProcessingInstruction* 00261 createProcessingInstruction( 00262 const XalanDOMString& target, 00263 const XalanDOMString& data); 00264 00265 virtual XalanAttr* 00266 createAttribute(const XalanDOMString& name); 00267 00268 virtual XalanEntityReference* 00269 createEntityReference(const XalanDOMString& name); 00270 00271 virtual XalanDocumentType* 00272 getDoctype() const; 00273 00274 virtual XalanDOMImplementation* 00275 getImplementation() const; 00276 00277 virtual XalanElement* 00278 getDocumentElement() const; 00279 00280 virtual XalanNodeList* 00281 getElementsByTagName(const XalanDOMString& tagname) const; 00282 00283 virtual XalanNode* 00284 importNode( 00285 XalanNode* importedNode, 00286 bool deep); 00287 00288 virtual XalanElement* 00289 createElementNS( 00290 const XalanDOMString& namespaceURI, 00291 const XalanDOMString& qualifiedName); 00292 00293 virtual XalanAttr* 00294 createAttributeNS( 00295 const XalanDOMString& namespaceURI, 00296 const XalanDOMString& qualifiedName); 00297 00298 virtual XalanNodeList* 00299 getElementsByTagNameNS( 00300 const XalanDOMString& namespaceURI, 00301 const XalanDOMString& localName) const; 00302 00303 virtual XalanElement* 00304 getElementById(const XalanDOMString& elementId) const; 00305 00306 00307 // These are some special interfaces to manage relationships between 00308 // our nodes and Xerces nodes. 00309 00317 void 00318 destroyBridge(); 00319 00326 void 00327 rebuildBridge(); 00328 00329 XalanNode* 00330 mapNode(const DOM_Node& theXercesNode) const; 00331 00332 XalanAttr* 00333 mapNode(const DOM_Attr& theXercesNode) const; 00334 00335 XalanElement* 00336 mapNode(const DOM_Element& theXercesNode) const; 00337 00338 DOM_Node 00339 mapNode(const XalanNode* theXalanNode) const; 00340 00341 DOM_Attr 00342 mapNode(const XalanAttr* theXalanNode) const; 00343 00344 NodeImpl* 00345 mapNodeToImpl(const XalanNode* theXalanNode) const; 00346 00354 DOM_Document 00355 getXercesDocument() const 00356 { 00357 return m_xercesDocument; 00358 } 00359 00368 void 00369 buildBridgeNodes(); 00370 00371 #if defined(XALAN_NO_NAMESPACES) 00372 typedef deque<XercesBridgeNavigator> NavigatorBridgeVectorType; 00373 00374 typedef deque<XalanNode*> NodeVectorType; 00375 #else 00376 typedef std::deque<XercesBridgeNavigator> NavigatorBridgeVectorType; 00377 00378 typedef std::deque<XalanNode*> NodeVectorType; 00379 #endif 00380 00381 // Helper class to walk the tree and build everything... 00382 class BuildBridgeTreeWalker : public XercesTreeWalker 00383 { 00384 public: 00385 00386 typedef NavigatorBridgeVectorType NavigatorBridgeVectorInnerType; 00387 00388 BuildBridgeTreeWalker( 00389 XercesDocumentBridge* theDocument, 00390 XercesBridgeNavigator* theDocumentNavigator, 00391 NavigatorBridgeVectorInnerType& theNavigators, 00392 unsigned long theStartIndex); 00393 00394 virtual 00395 ~BuildBridgeTreeWalker(); 00396 00397 struct NavigatorStackEntryType 00398 { 00399 NavigatorStackEntryType( 00400 XercesBridgeNavigator* theNavigator = 0, 00401 XalanNode* theNode = 0) : 00402 m_navigator(theNavigator), 00403 m_node(theNode) 00404 { 00405 } 00406 00407 XercesBridgeNavigator* m_navigator; 00408 00409 XalanNode* m_node; 00410 }; 00411 00412 #if defined(XALAN_NO_NAMESPACES) 00413 typedef vector<NavigatorStackEntryType> NavigatorStackType; 00414 #else 00415 typedef std::vector<NavigatorStackEntryType> NavigatorStackType; 00416 #endif 00417 00418 protected: 00419 00420 virtual void 00421 startNode(const DOM_Node& node); 00422 00423 virtual void 00424 endNode(const DOM_Node& node); 00425 00426 private: 00427 00428 XercesDocumentBridge* m_document; 00429 00430 NavigatorBridgeVectorInnerType& m_navigators; 00431 00432 unsigned long m_currentIndex; 00433 00434 NavigatorStackType m_parentNavigatorStack; 00435 00436 NavigatorStackType m_siblingNavigatorStack; 00437 }; 00438 00439 private: 00440 00441 XalanNode* 00442 mapNode(NodeImpl* theXercesNodeImpl) const; 00443 00444 // Destruction API... 00445 void 00446 destroyBridgeNode(XalanNode* theNode); 00447 00448 // Not implemented... 00449 XercesDocumentBridge(const XercesDocumentBridge& theSource); 00450 00451 XercesDocumentBridge& 00452 operator=(const XercesDocumentBridge& theRHS); 00453 00454 bool 00455 operator==(const XercesDocumentBridge& theRHS) const; 00456 00457 // Private delete function... 00458 void 00459 destroyNode(XalanNode* theNode); 00460 00461 // More internal implementation stuff... 00462 XalanNode* 00463 internalCloneNode( 00464 const XalanNode* theXalanNode, 00465 const DOM_Node& theXercesNode, 00466 bool deep); 00467 00468 // Factory methods for our implementation nodes... 00469 XalanNode* 00470 createBridgeNode( 00471 const DOM_Node& theXercesNode, 00472 unsigned long theIndex, 00473 bool mapNode) const; 00474 00475 XercesDocumentTypeBridge* 00476 createBridgeNode( 00477 const DOM_DocumentType& theDoctype, 00478 unsigned long theIndex, 00479 bool mapNode) const; 00480 00481 XercesElementBridge* 00482 createBridgeNode( 00483 const DOM_Element& theXercesNode, 00484 unsigned long theIndex, 00485 bool mapNode) const; 00486 00487 XercesDocumentFragmentBridge* 00488 createBridgeNode( 00489 const DOM_DocumentFragment& theXercesNode, 00490 unsigned long theIndex, 00491 bool mapNode) const; 00492 00493 XercesTextBridge* 00494 createBridgeNode( 00495 const DOM_Text& theXercesNode, 00496 unsigned long theIndex, 00497 bool mapNode) const; 00498 00499 XercesCommentBridge* 00500 createBridgeNode( 00501 const DOM_Comment& theXercesNode, 00502 unsigned long theIndex, 00503 bool mapNode) const; 00504 00505 XercesCDATASectionBridge* 00506 createBridgeNode( 00507 const DOM_CDATASection& theXercesNode, 00508 unsigned long theIndex, 00509 bool mapNode) const; 00510 00511 XercesProcessingInstructionBridge* 00512 createBridgeNode( 00513 const DOM_ProcessingInstruction& theXercesNode, 00514 unsigned long theIndex, 00515 bool mapNode) const; 00516 00517 XercesAttrBridge* 00518 createBridgeNode( 00519 const DOM_Attr& theXercesNode, 00520 unsigned long theIndex, 00521 bool mapNode) const; 00522 00523 XercesEntityBridge* 00524 createBridgeNode( 00525 const DOM_Entity& theXercesNode, 00526 unsigned long theIndex, 00527 bool mapNode) const; 00528 00529 XercesEntityReferenceBridge* 00530 createBridgeNode( 00531 const DOM_EntityReference& theXercesNode, 00532 unsigned long theIndex, 00533 bool mapNode) const; 00534 00535 XercesNotationBridge* 00536 createBridgeNode( 00537 const DOM_Notation& theXercesNode, 00538 unsigned long theIndex, 00539 bool mapNode) const; 00540 00541 XercesBridgeNavigator& 00542 pushNavigator(bool mappingMode) const; 00543 00544 // This is a private helper class for building the tree... 00545 friend class BuildBridgeTreeWalker; 00546 00547 // $$$ ToDo: This is because DOM_Document::getElementById() is not 00548 // const... 00549 mutable DOM_Document m_xercesDocument; 00550 00551 XalanElement* m_documentElement; 00552 00553 XercesNodeListBridge m_children; 00554 00555 XercesDocumentNamedNodeListCache m_cachedNodeLists; 00556 00557 mutable XercesToXalanNodeMap m_nodeMap; 00558 00559 XalanAutoPtr<XalanDOMImplementation> m_domImplementation; 00560 00561 mutable NavigatorBridgeVectorType m_navigators; 00562 00563 // Our navigator will be the first entry in m_navigators, 00564 // but we'll cache this so access is faster... 00565 XercesBridgeNavigator& m_navigator; 00566 00567 mutable NodeVectorType m_nodes; 00568 00569 mutable XercesDocumentTypeBridge* m_doctype; 00570 00571 bool m_mappingMode; 00572 00573 bool m_indexValid; 00574 00575 #if defined(XALAN_USE_BLOCK_ALLOCATORS) 00576 mutable XercesElementBridgeAllocator m_elementAllocator; 00577 00578 mutable XercesTextBridgeAllocator m_textAllocator; 00579 00580 mutable XercesAttributeBridgeAllocator m_attributeAllocator; 00581 #endif 00582 }; 00583 00584 00585 00586 #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.0 |
|