Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.3

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

XercesDocumentBridge.hpp

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

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

Xalan-C++ XSLT Processor Version 1.3
Copyright © 2000, 2001 The Apache Software Foundation. All Rights Reserved.