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  

NamespacesHandler.hpp

Go to the documentation of this file.
00001 /*
00002  * The Apache Software License, Version 1.1
00003  *
00004  *
00005  * Copyright (c) 2000 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  * $ Id: $
00058  *
00059  */
00060 
00061 #if !defined(XALAN_NAMESPACESHANDLER_HEADER_GUARD)
00062 #define XALAN_NAMESPACESHANDLER_HEADER_GUARD
00063 
00064 
00065 
00066 // Base include file.  Must be first.
00067 #include <XSLT/XSLTDefinitions.hpp>
00068 
00069 
00070 
00071 #include <map>
00072 #include <set>
00073 #include <vector>
00074 
00075 
00076 
00077 #include <XalanDOM/XalanDOMString.hpp>
00078 
00079 
00080 
00081 #include <XPath/NameSpace.hpp>
00082 #include <XPath/XalanQName.hpp>
00083 
00084 
00085 
00086 class StylesheetConstructionContext;
00087 class StylesheetExecutionContext;
00088 
00089 
00090 
00091 class XALAN_XSLT_EXPORT NamespacesHandler
00092 {
00093 public:
00094 
00098     static void
00099     initialize();
00100 
00104     static void
00105     terminate();
00106 
00107 
00108     /* Some static strings for various namespace URIs...
00109      *
00110      */
00111     static const XalanDOMString&    s_ApacheXSLTNamespaceURI;
00112 
00113     static const XalanDOMString&    s_LotusXSLTNamespaceURI;
00114 
00115     static const XalanDOMString&    s_LotusXSLTNamespaceURIWithSeparator;
00116 
00117 
00118     class NameSpaceExtended : public NameSpace
00119     {
00120     public:
00121 
00122         NameSpaceExtended(
00123                     const XalanDOMString&   prefix = XalanDOMString(),
00124                     const XalanDOMString&   uri = XalanDOMString()) :
00125             NameSpace(prefix, uri),
00126             m_resultAttributeName()
00127         {
00128         }
00129 
00130         NameSpaceExtended(const NameSpace&  theNamespace) :
00131             NameSpace(theNamespace),
00132             m_resultAttributeName()
00133         {
00134         }
00135 
00141         const XalanDOMString&
00142         getResultAttributeName() const
00143         {
00144             return m_resultAttributeName;
00145         }
00146 
00152         void
00153         setResultAttributeName(const XalanDOMString&    name)
00154         {
00155             m_resultAttributeName = name;
00156         }
00157 
00158     private:
00159 
00160         XalanDOMString  m_resultAttributeName;
00161     };
00162 
00163     typedef XalanQName::NamespaceVectorType             NamespaceVectorType;
00164     typedef XalanQName::NamespacesStackType             NamespacesStackType;
00165 
00166 #if defined(XALAN_NO_NAMESPACES)
00167     typedef map<XalanDOMString,
00168                 XalanDOMString,
00169                 less<XalanDOMString> >                  ExcludedResultPrefixesMapType;
00170 
00171     typedef map<XalanDOMString,
00172                 NameSpaceExtended,
00173                 less<XalanDOMString> >                  NamespacesMapType;
00174 
00175     typedef map<XalanDOMString,
00176                 XalanDOMString,
00177                 less<XalanDOMString> >                  NamespaceAliasesMapType;
00178 
00179     typedef set<XalanDOMString,
00180                 less<XalanDOMString> >                  ExtensionNamespaceURISetType;
00181 
00182     typedef set<XalanDOMString,
00183                 less<XalanDOMString> >                  ActivePrefixesSetType;
00184 #else
00185     typedef std::map<XalanDOMString, XalanDOMString>    ExcludedResultPrefixesMapType;
00186 
00187     typedef std::map<XalanDOMString,
00188                      NameSpaceExtended>                 NamespacesMapType;
00189 
00190     typedef std::map<XalanDOMString, XalanDOMString>    NamespaceAliasesMapType;
00191 
00192     typedef std::set<XalanDOMString>                    ExtensionNamespaceURISetType;
00193 
00194     typedef std::set<XalanDOMString>                    ActivePrefixesSetType;
00195 #endif
00196 
00200     explicit
00201     NamespacesHandler();
00202 
00211     NamespacesHandler(
00212             const NamespacesHandler&    stylesheetNamespacesHandler,
00213             const NamespacesStackType&  theCurrentNamespaces,
00214             const XalanDOMString&       theXSLTNamespaceURI);
00215 
00216     NamespacesHandler(const NamespacesHandler&  theSource);
00217 
00218     ~NamespacesHandler();
00219 
00227     void
00228     processExcludeResultPrefixes(
00229             const XalanDOMChar*             theValue,
00230             const NamespacesStackType&      theCurrentNamespaces,
00231             StylesheetConstructionContext&  theConstructionContext);
00232 
00240     void
00241     processExtensionElementPrefixes(
00242             const XalanDOMChar*             theValue,
00243             const NamespacesStackType&      theCurrentNamespaces,
00244             StylesheetConstructionContext&  theConstructionContext);
00245 
00252     void
00253     postConstruction(
00254             const XalanDOMString&       theElementName = XalanDOMString(),
00255             const NamespacesHandler*    parentNamespacesHandler = 0);
00256 
00257     NamespacesHandler&
00258     operator=(const NamespacesHandler&  theRHS);
00259 
00267     bool
00268     shouldExcludeResultNamespaceNode(
00269             const XalanDOMString&   theXSLTNamespaceURI,
00270             const XalanDOMString&   theURI) const;
00271 
00277     void
00278     addExtensionNamespaceURI(const XalanDOMString&  theURI)
00279     {
00280         m_extensionNamespaceURIs.insert(theURI);
00281     }
00282 
00289     const XalanDOMString*
00290     getNamespace(const XalanDOMString&  thePrefix) const;
00291 
00298     const XalanDOMString*
00299     getNamespaceAlias(const XalanDOMString&     theStylesheetNamespace) const;
00300 
00307     void
00308     setNamespaceAlias(
00309             const XalanDOMString&   theStylesheetNamespace,
00310             const XalanDOMString&   theResultNamespace)
00311     {
00312         m_namespaceAliases[theStylesheetNamespace] = theResultNamespace;
00313     }
00314 
00320     void
00321     addActivePrefix(const XalanDOMString&   thePrefix)
00322     {
00323         m_activePrefixes.insert(thePrefix);
00324     }
00325 
00331     void
00332     copyNamespaceAliases(const NamespacesHandler&   parentNamespacesHandler);
00333 
00340     void
00341     outputResultNamespaces(
00342             StylesheetExecutionContext&     theExecutionContext,
00343             bool                            supressDefault = false) const;
00344 
00348     void
00349     clear();
00350 
00356     void
00357     swap(NamespacesHandler&     theOther);
00358 
00359     bool
00360     getProcessNamespaceAliaises() const
00361     {
00362         return m_processAliases;
00363     }
00364 
00365     void
00366     setProcessNamespaceAliaises(bool    fValue)
00367     {
00368         m_processAliases = fValue;
00369     }
00370 
00371     NamespacesMapType::size_type
00372     getNamespaceDeclarationsCount() const
00373     {
00374         return m_namespaceDeclarations.size();
00375     }
00376 
00377 private:
00378 
00382     void
00383     createResultAttributeNames();
00384 
00390     void
00391     processExcludeResultPrefixes(const XalanDOMString&  theElementPrefix);
00392 
00396     void
00397     processNamespaceAliases();
00398 
00404     void
00405     copyNamespaceAliases(const NamespaceAliasesMapType&     theNamespaceAliases);
00406 
00412     void
00413     copyExtensionNamespaceURIs(const ExtensionNamespaceURISetType&  theExtensionNamespaceURIs);
00414 
00420     void
00421     copyExcludeResultPrefixes(const ExcludedResultPrefixesMapType&  theExcludeResultPrefixes);
00422 
00432     bool
00433     shouldExcludeResultNamespaceNode(
00434             const XalanDOMString&       theXSLTNamespaceURI,
00435             const NamespacesHandler&    parentNamespacesHandler,
00436             const NameSpace&            theNamespace) const;
00437 
00445     bool
00446     isExcludedNamespaceURI(const XalanDOMString&    theNamespaceURI) const;
00447 
00448     // Not implemented...
00449     bool
00450     operator==(const NamespacesHandler&) const;
00451 
00452     // Data members...
00453     ExcludedResultPrefixesMapType   m_excludedResultPrefixes;
00454 
00455     NamespacesMapType               m_namespaceDeclarations;
00456 
00457     ExtensionNamespaceURISetType    m_extensionNamespaceURIs;
00458 
00459     NamespaceAliasesMapType         m_namespaceAliases;
00460 
00461     ActivePrefixesSetType           m_activePrefixes;
00462 
00463     // If true namespace aliases will be processed.  If false, they will not.
00464     bool                            m_processAliases;
00465 };
00466 
00467 
00468 
00469 #endif  // XALAN_NAMESPACESHANDLER_HEADER_GUARD

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.