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  

XercesDocumentWrapper.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(XERCESDOCUMENTWRAPPER_HEADER_GUARD_1357924680)
00058 #define XERCESDOCUMENTWRAPPER_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 #include <xalanc/XalanDOM/XalanDocument.hpp>
00073 
00074 
00075 
00076 #if defined(XALAN_AUTO_PTR_REQUIRES_DEFINITION)
00077 #include <xalanc/XalanDOM/XalanDOMImplementation.hpp>
00078 #include <xalanc/PlatformSupport/XalanDOMStringPool.hpp>
00079 #endif
00080 
00081 
00082 
00083 #include <xalanc/Include/XalanAutoPtr.hpp>
00084 
00085 
00086 
00087 #include <xalanc/XercesParserLiaison/XercesDOMWalker.hpp>
00088 #include <xalanc/XercesParserLiaison/XercesWrapperNavigator.hpp>
00089 
00090 
00091 #include <xalanc/XercesParserLiaison/XercesWrapperToXalanNodeMap.hpp>
00092 #include <xalanc/XercesParserLiaison/XercesNodeListWrapper.hpp>
00093 #include <xalanc/XercesParserLiaison/XercesAttrWrapperAllocator.hpp>
00094 #include <xalanc/XercesParserLiaison/XercesElementWrapperAllocator.hpp>
00095 #include <xalanc/XercesParserLiaison/XercesTextWrapperAllocator.hpp>
00096 
00097 
00098 
00099 #include <xalanc/XercesParserLiaison/XercesWrapperTypes.hpp>
00100 
00101 
00102 
00103 XALAN_CPP_NAMESPACE_BEGIN
00104 
00105 
00106 
00107 class XalanDOMStringPool;
00108 class XercesCommentWrapper;
00109 class XercesCDATASectionWrapper;
00110 class XercesDocumentFragmentWrapper;
00111 class XercesDocumentTypeWrapper;
00112 class XercesEntityWrapper;
00113 class XercesEntityReferenceWrapper;
00114 class XercesProcessingInstructionWrapper;
00115 class XercesNotationWrapper;
00116 
00117 
00118 
00119 class XALAN_XERCESPARSERLIAISON_EXPORT XercesDocumentWrapper : public XalanDocument
00120 {
00121 public:
00122 
00123     friend class XercesWrapperNavigator;
00124 
00141     XercesDocumentWrapper(
00142             const DOMDocument_Type*     theXercesDocument,
00143             bool                        threadSafe = true,
00144             bool                        buildWrapper = true,
00145             bool                        buildMaps = false);
00146 
00147     virtual
00148     ~XercesDocumentWrapper();
00149 
00150     // These interfaces are inherited from XalanNode...
00151 
00152     virtual const XalanDOMString&
00153     getNodeName() const;
00154 
00155     virtual const XalanDOMString&
00156     getNodeValue() const;
00157 
00158     virtual NodeType
00159     getNodeType() const;
00160 
00161     virtual XalanNode*
00162     getParentNode() const;
00163 
00164     virtual const XalanNodeList*
00165     getChildNodes() const;
00166 
00167     virtual XalanNode*
00168     getFirstChild() const;
00169 
00170     virtual XalanNode*
00171     getLastChild() const;
00172 
00173     virtual XalanNode*
00174     getPreviousSibling() const;
00175 
00176     virtual XalanNode*
00177     getNextSibling() const;
00178 
00179     virtual const XalanNamedNodeMap*
00180     getAttributes() const;
00181 
00182     virtual XalanDocument*
00183     getOwnerDocument() const;
00184 
00185 #if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
00186     virtual XalanNode*
00187 #else
00188     virtual XercesDocumentWrapper*
00189 #endif
00190     cloneNode(bool deep) const;
00191 
00192     virtual XalanNode*
00193     insertBefore(
00194             XalanNode*  newChild,
00195             XalanNode*  refChild);
00196 
00197     virtual XalanNode*
00198     replaceChild(
00199             XalanNode*  newChild,
00200             XalanNode*  oldChild);
00201 
00202     virtual XalanNode*
00203     removeChild(XalanNode*  oldChild);
00204 
00205     virtual XalanNode*
00206     appendChild(XalanNode*  newChild);
00207 
00208     virtual bool
00209     hasChildNodes() const;
00210 
00211     virtual void
00212     setNodeValue(const XalanDOMString&      nodeValue);
00213 
00214     virtual void
00215     normalize();
00216 
00217     virtual bool
00218     isSupported(
00219             const XalanDOMString&   feature,
00220             const XalanDOMString&   version) const;
00221 
00222     virtual const XalanDOMString&
00223     getNamespaceURI() const;
00224 
00225     virtual const XalanDOMString&
00226     getPrefix() const;
00227 
00228     virtual const XalanDOMString&
00229     getLocalName() const;
00230 
00231     virtual void
00232     setPrefix(const XalanDOMString& prefix);
00233 
00234     virtual bool
00235     isIndexed() const;
00236 
00237     virtual IndexType
00238     getIndex() const;
00239 
00240     virtual XalanElement*
00241     createElement(const XalanDOMString& tagName);
00242 
00243     virtual XalanDocumentFragment*
00244     createDocumentFragment();
00245 
00246     virtual XalanText*
00247     createTextNode(const XalanDOMString&    data);
00248 
00249     virtual XalanComment*
00250     createComment(const XalanDOMString& data);
00251 
00252     virtual XalanCDATASection*
00253     createCDATASection(const XalanDOMString&    data);
00254 
00255     virtual XalanProcessingInstruction*
00256     createProcessingInstruction(
00257             const XalanDOMString&   target,
00258             const XalanDOMString&   data);
00259 
00260     virtual XalanAttr*
00261     createAttribute(const XalanDOMString&   name);
00262 
00263     virtual XalanEntityReference*
00264     createEntityReference(const XalanDOMString& name);
00265 
00266     virtual XalanDocumentType*
00267     getDoctype() const;
00268 
00269     virtual XalanDOMImplementation*
00270     getImplementation() const;
00271 
00272     virtual XalanElement*
00273     getDocumentElement() const;
00274 
00275     virtual XalanNodeList*
00276     getElementsByTagName(const XalanDOMString&      tagname) const;
00277 
00278     virtual XalanNode*
00279     importNode(
00280             XalanNode*  importedNode,
00281             bool        deep);
00282 
00283     virtual XalanElement*
00284     createElementNS(
00285             const XalanDOMString&   namespaceURI,
00286             const XalanDOMString&   qualifiedName);
00287 
00288     virtual XalanAttr*
00289     createAttributeNS(
00290             const XalanDOMString& namespaceURI,
00291             const XalanDOMString& qualifiedName);
00292 
00293     virtual XalanNodeList*
00294     getElementsByTagNameNS(
00295             const XalanDOMString&   namespaceURI,
00296             const XalanDOMString&   localName) const;
00297 
00298     virtual XalanElement*
00299     getElementById(const XalanDOMString&    elementId) const;
00300 
00301     // These are some special interfaces to manage relationships between
00302     // our nodes and Xerces nodes.
00303 
00311     void
00312     destroyWrapper();
00313 
00320     void
00321     rebuildWrapper();
00322 
00333     XalanNode*
00334     mapNode(const DOMNodeType*  theXercesNode) const;
00335 
00346     XalanAttr*
00347     mapNode(const DOMAttrType*  theXercesNode) const;
00348 
00359     XalanElement*
00360     mapNode(const DOMElementType*   theXercesNode) const;
00361 
00372     const DOMNodeType*
00373     mapNode(XalanNode*  theXalanNode) const;
00374 
00382     const DOMDocument_Type*
00383     getXercesDocument() const
00384     {
00385         return m_xercesDocument;
00386     }
00387 
00393     void
00394     buildWrapperNodes();
00395 
00396 #if defined(XALAN_NO_STD_NAMESPACE)
00397     typedef deque<XercesWrapperNavigator>   WrapperNavigatorVectorType;
00398 
00399     typedef deque<XalanNode*>               NodeVectorType;
00400 #else
00401     typedef std::deque<XercesWrapperNavigator>  WrapperNavigatorVectorType;
00402 
00403     typedef std::deque<XalanNode*>              NodeVectorType;
00404 #endif
00405 
00406     // Helper class to walk the tree and build everything...
00407     class BuildWrapperTreeWalker : public XercesDOMWalker
00408     {
00409     public:
00410 
00411         typedef XercesDOMWalker             ParentType;
00412         typedef WrapperNavigatorVectorType  WrapperNavigatorVectorInnerType;
00413 
00414         BuildWrapperTreeWalker(
00415                 XercesDocumentWrapper*              theDocument,
00416                 XercesWrapperNavigator*             theDocumentNavigator,
00417                 WrapperNavigatorVectorInnerType&    theNavigators,
00418                 IndexType                           theStartIndex,
00419                 bool                                theBuildMapsFlag);
00420 
00421         virtual
00422         ~BuildWrapperTreeWalker();
00423 
00424         struct NavigatorStackEntryType
00425         {
00426             NavigatorStackEntryType(
00427                         XercesWrapperNavigator* theNavigator = 0,
00428                         XalanNode*              theNode = 0) :
00429                 m_navigator(theNavigator),
00430                 m_node(theNode)
00431             {
00432             }
00433 
00434             XercesWrapperNavigator* m_navigator;
00435 
00436             XalanNode*              m_node;
00437         };
00438 
00439     #if defined(XALAN_NO_STD_NAMESPACE)
00440         typedef vector<NavigatorStackEntryType>         NavigatorStackType;
00441     #else
00442         typedef std::vector<NavigatorStackEntryType>    NavigatorStackType;
00443     #endif
00444 
00445     protected:
00446 
00447         virtual bool
00448         startNode(const DOMNodeType*    node);
00449 
00450         virtual bool
00451         endNode(const DOMNodeType*  node);
00452 
00453 #if !defined(XALAN_NO_USING_DECLARATION)
00454         using ParentType::startNode;
00455         using ParentType::endNode;
00456 #endif
00457 
00458     private:
00459 
00460         XercesDocumentWrapper*              m_document;
00461 
00462         WrapperNavigatorVectorInnerType&    m_navigators;
00463 
00464         IndexType                           m_currentIndex;
00465 
00466         NavigatorStackType                  m_parentNavigatorStack;
00467 
00468         NavigatorStackType                  m_siblingNavigatorStack;
00469 
00470         const bool                          m_buildMaps;
00471     };
00472 
00473 
00481     const XalanDOMString&
00482     getPooledString(const XalanDOMString&   theString) const;
00483 
00492     const XalanDOMString&
00493     getPooledString(
00494             const XalanDOMChar*         theString,
00495             XalanDOMString::size_type   theLength /* = XalanDOMString::npos */) const;
00496 
00497     bool
00498     getMappingMode() const
00499     {
00500         return m_mappingMode;
00501     }
00502 
00503 private:
00504 
00505     // Destruction API...
00506     void
00507     destroyWrapperNode(XalanNode*   theNode);
00508 
00509     // Not implemented...
00510     XercesDocumentWrapper(const XercesDocumentWrapper&  theSource);
00511 
00512     XercesDocumentWrapper&
00513 	operator=(const XercesDocumentWrapper& theRHS);
00514 
00515     bool
00516 	operator==(const XercesDocumentWrapper&    theRHS) const;
00517 
00518     // Private delete function...
00519     void
00520     destroyNode(XalanNode*  theNode);
00521 
00522     // More internal implementation stuff...
00523 
00524     // Factory methods for our implementation nodes...
00525     XalanNode*
00526     createWrapperNode(
00527             const DOMNodeType*  theXercesNode,
00528             IndexType           theIndex,
00529             bool                mapNode) const;
00530 
00531     XercesDocumentTypeWrapper*
00532     createWrapperNode(
00533             const DOMDocumentType_Type*     theDoctype,
00534             IndexType                       theIndex,
00535             bool                            mapNode) const;
00536 
00537     XercesElementWrapper*
00538     createWrapperNode(
00539             const DOMElementType*   theXercesNode,
00540             IndexType               theIndex,
00541             bool                    mapNode) const;
00542 
00543     XercesTextWrapper*
00544     createWrapperNode(
00545             const DOMTextType*  theXercesNode,
00546             IndexType           theIndex,
00547             bool                mapNode) const;
00548 
00549     XercesCommentWrapper*
00550     createWrapperNode(
00551             const DOMCommentType*   theXercesNode,
00552             IndexType               theIndex,
00553             bool                    mapNode) const;
00554 
00555     XercesCDATASectionWrapper*
00556     createWrapperNode(
00557             const DOMCDATASectionType*  theXercesNode,
00558             IndexType                   theIndex,
00559             bool                        mapNode) const;
00560 
00561     XercesProcessingInstructionWrapper*
00562     createWrapperNode(
00563             const DOMProcessingInstructionType*     theXercesNode,
00564             IndexType                               theIndex,
00565             bool                                    mapNode) const;
00566 
00567     XercesAttrWrapper*
00568     createWrapperNode(
00569             const DOMAttrType*  theXercesNode,
00570             IndexType           theIndex,
00571             bool                mapNode) const;
00572 
00573     XercesEntityWrapper*
00574     createWrapperNode(
00575             const DOMEntityType*    theXercesNode,
00576             IndexType               theIndex,
00577             bool                    mapNode) const;
00578 
00579     XercesEntityReferenceWrapper*
00580     createWrapperNode(
00581             const DOMEntityReferenceType*   theXercesNode,
00582             IndexType                       theIndex,
00583             bool                            mapNode) const;
00584 
00585     XercesNotationWrapper*
00586     createWrapperNode(
00587             const DOMNotationType*  theXercesNode,
00588             IndexType               theIndex,
00589             bool                    mapNode) const;
00590 
00591     XercesWrapperNavigator&
00592     pushNavigator() const;
00593 
00594     // This is a private helper class for building the tree...
00595     friend class BuildWrapperTreeWalker;
00596 
00597     const DOMDocument_Type* const           m_xercesDocument;
00598 
00599     XalanElement*                           m_documentElement;
00600 
00601     mutable XercesWrapperToXalanNodeMap     m_nodeMap;
00602 
00603     XalanAutoPtr<XalanDOMImplementation>    m_domImplementation;
00604 
00605     mutable WrapperNavigatorVectorType      m_navigators;
00606 
00607     // Our navigator will be the first entry in m_navigators,
00608     // but we'll cache this so access is faster...
00609     XercesWrapperNavigator*                 m_navigator;
00610 
00611     XercesNodeListWrapper                   m_children;
00612 
00613     mutable NodeVectorType                  m_nodes;
00614 
00615     mutable XercesDocumentTypeWrapper*      m_doctype;
00616 
00617     bool                                    m_mappingMode;
00618 
00619     bool                                    m_indexValid;
00620 
00621     const bool                              m_buildMaps;
00622 
00623     mutable XercesElementWrapperAllocator   m_elementAllocator;
00624 
00625     mutable XercesTextWrapperAllocator      m_textAllocator;
00626 
00627     mutable XercesAttrWrapperAllocator      m_attributeAllocator;
00628 
00629     const XalanAutoPtr<XalanDOMStringPool>  m_stringPool;
00630 };
00631 
00632 
00633 
00634 XALAN_CPP_NAMESPACE_END
00635 
00636 
00637 
00638 #endif  // !defined(XERCESDOCUMENTWRAPPER_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.