## Xalan-C++ API Documentation

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

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