## Xalan-C++ API Documentation

### The Xalan C++ XSLT Processor Version 1.5

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