Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.6

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-2002 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 <xalanc/XSLT/XSLTDefinitions.hpp>
00068 
00069 
00070 
00071 #include <map>
00072 #include <set>
00073 #include <vector>
00074 
00075 
00076 
00077 #include <xalanc/PlatformSupport/DOMStringHelper.hpp>
00078 
00079 
00080 
00081 #include <xalanc/XPath/NameSpace.hpp>
00082 #include <xalanc/XPath/XalanQName.hpp>
00083 
00084 
00085 
00086 XALAN_CPP_NAMESPACE_BEGIN
00087 
00088 
00089 
00090 class StylesheetConstructionContext;
00091 class StylesheetExecutionContext;
00092 
00093 
00094 
00095 class XALAN_XSLT_EXPORT NamespacesHandler
00096 {
00097 public:
00098 
00099     class PrefixChecker
00100     {
00101     public:
00102 
00103         PrefixChecker();
00104 
00105         virtual
00106         ~PrefixChecker();
00107 
00108         virtual bool
00109         isActive(const XalanDOMString&  thePrefix) const = 0;
00110     };
00111 
00112     class XALAN_XSLT_EXPORT Namespace
00113     {
00114     public:
00115 
00116         Namespace() :
00117             m_prefix(&s_emptyString),
00118             m_uri(&s_emptyString)
00119         {
00120         }
00121 
00122         Namespace(
00123                     const XalanDOMString&   prefix,
00124                     const XalanDOMString&   uri) :
00125             m_prefix(&prefix),
00126             m_uri(&uri)
00127         {
00128         }
00129 
00135         const XalanDOMString&
00136         getPrefix() const
00137         {
00138             assert(m_prefix != 0);
00139 
00140             return *m_prefix;
00141         }
00142 
00148         void
00149         setPrefix(const XalanDOMString&     prefix)
00150         {
00151             m_prefix = &prefix;
00152         }
00153 
00159         const XalanDOMString&
00160         getURI() const
00161         {
00162             assert(m_uri != 0);
00163 
00164             return *m_uri;
00165         }
00166 
00172         void
00173         setURI(const XalanDOMString&    uri)
00174         {
00175             m_uri = &uri;
00176         }
00177 
00178     protected:
00179 
00180         static const XalanDOMString     s_emptyString;
00181 
00182     private:
00183 
00184         const XalanDOMString*   m_prefix;
00185 
00186         const XalanDOMString*   m_uri;
00187     };
00188 
00189     class XALAN_XSLT_EXPORT NamespaceExtended : public Namespace
00190     {
00191     public:
00192 
00193         NamespaceExtended() :
00194             Namespace(),
00195             m_resultAttributeName(&s_emptyString)
00196         {
00197         }
00198 
00199         NamespaceExtended(
00200                     const XalanDOMString&   prefix,
00201                     const XalanDOMString&   uri) :
00202             Namespace(prefix, uri),
00203             m_resultAttributeName(&s_emptyString)
00204         {
00205         }
00206 
00212         const XalanDOMString&
00213         getResultAttributeName() const
00214         {
00215             assert(m_resultAttributeName != 0);
00216 
00217             return *m_resultAttributeName;
00218         }
00219 
00225         void
00226         setResultAttributeName(const XalanDOMString&    name)
00227         {
00228             m_resultAttributeName = &name;
00229         }
00230 
00231     private:
00232 
00233         const XalanDOMString*   m_resultAttributeName;
00234     };
00235 
00236     typedef XalanQName::NamespaceVectorType             NamespaceVectorType;
00237     typedef XalanQName::NamespacesStackType             NamespacesStackType;
00238 
00239 #if defined(XALAN_NO_STD_NAMESPACE)
00240     typedef vector<Namespace>                           NamespacesVectorType;
00241 
00242     typedef vector<NamespaceExtended>                   NamespaceExtendedVectorType;
00243 
00244     typedef map<const XalanDOMString*,
00245                 const XalanDOMString*,
00246                 DOMStringPointerLessThanFunction>       ExcludedResultPrefixesMapType;
00247 
00248     typedef map<const XalanDOMString*,
00249                 NamespaceExtended,
00250                 DOMStringPointerLessThanFunction>       NamespacesMapType;
00251 
00252     typedef map<const XalanDOMString*,
00253                 const XalanDOMString*,
00254                 DOMStringPointerLessThanFunction>       NamespaceAliasesMapType;
00255 
00256     typedef vector<const XalanDOMString*>               XalanDOMStringPointerVectorType;
00257 #else
00258     typedef std::vector<Namespace>                      NamespacesVectorType;
00259 
00260     typedef std::vector<NamespaceExtended>              NamespaceExtendedVectorType;
00261 
00262     typedef std::map<const XalanDOMString*,
00263                      const XalanDOMString*,
00264                      DOMStringPointerLessThanFunction>  ExcludedResultPrefixesMapType;
00265 
00266     typedef std::map<const XalanDOMString*,
00267                      NamespaceExtended,
00268                      DOMStringPointerLessThanFunction>  NamespacesMapType;
00269 
00270     typedef std::map<const XalanDOMString*,
00271                      const XalanDOMString*,
00272                      DOMStringPointerLessThanFunction>  NamespaceAliasesMapType;
00273 
00274     typedef std::vector<const XalanDOMString*>          XalanDOMStringPointerVectorType;
00275 #endif
00276 
00280     explicit
00281     NamespacesHandler();
00282 
00292     NamespacesHandler(
00293             StylesheetConstructionContext&  theConstructionContext,
00294             const NamespacesHandler&        stylesheetNamespacesHandler,
00295             const NamespacesStackType&      theCurrentNamespaces,
00296             const XalanDOMString&           theXSLTNamespaceURI);
00297 
00298     ~NamespacesHandler();
00299 
00307     void
00308     processExcludeResultPrefixes(
00309             StylesheetConstructionContext&  theConstructionContext,
00310             const XalanDOMChar*             theValue,
00311             const NamespacesStackType&      theCurrentNamespaces);
00312 
00320     void
00321     processExtensionElementPrefixes(
00322             StylesheetConstructionContext&  theConstructionContext,
00323             const XalanDOMChar*             theValue,
00324             const NamespacesStackType&      theCurrentNamespaces);
00325 
00335     void
00336     postConstruction(
00337             StylesheetConstructionContext&  theConstructionContext,
00338             bool                            fProcessNamespaceAliases = true,
00339             const XalanDOMString&           theElementName = XalanDOMString(),
00340             const NamespacesHandler*        parentNamespacesHandler = 0,
00341             const PrefixChecker*            prefixChecker = 0);
00342 
00343     NamespacesHandler&
00344     operator=(const NamespacesHandler&  theRHS);
00345 
00353     bool
00354     shouldExcludeResultNamespaceNode(
00355             const XalanDOMString&   theXSLTNamespaceURI,
00356             const XalanDOMString&   theURI) const;
00357 
00364     void
00365     addExtensionNamespaceURI(
00366             StylesheetConstructionContext&  theConstructionContext,
00367             const XalanDOMString&   theURI);
00368 
00375     const XalanDOMString*
00376     getNamespace(const XalanDOMString&  thePrefix) const;
00377 
00384     const XalanDOMString*
00385     getNamespaceAlias(const XalanDOMString&     theStylesheetNamespace) const;
00386 
00394     void
00395     setNamespaceAlias(
00396             StylesheetConstructionContext&  theConstructionContext,
00397             const XalanDOMString&           theStylesheetNamespace,
00398             const XalanDOMString&           theResultNamespace);
00399 
00405     void
00406     copyNamespaceAliases(const NamespacesHandler&   parentNamespacesHandler);
00407 
00414     void
00415     outputResultNamespaces(
00416             StylesheetExecutionContext&     theExecutionContext,
00417             bool                            supressDefault = false) const;
00418 
00422     void
00423     clear();
00424 
00430     void
00431     swap(NamespacesHandler&     theOther);
00432 
00433     NamespacesMapType::size_type
00434     getNamespaceDeclarationsCount() const
00435     {
00436         return m_namespaceDeclarations.size();
00437     }
00438 
00439 private:
00440 
00446     void
00447     createResultAttributeNames(StylesheetConstructionContext&   theConstructionContext);
00448 
00456     void
00457     processExcludeResultPrefixes(
00458             StylesheetConstructionContext&  theConstructionContext,
00459             const XalanDOMString&           theElementPrefix,
00460             const PrefixChecker*            prefixChecker);
00461 
00465     void
00466     processNamespaceAliases();
00467 
00473     void
00474     copyNamespaceAliases(const NamespaceAliasesMapType&     theNamespaceAliases);
00475 
00481     void
00482     copyExtensionNamespaceURIs(const XalanDOMStringPointerVectorType&   theExtensionNamespaceURIs);
00483 
00489     void
00490     copyExcludeResultPrefixes(const NamespacesVectorType&   theExcludeResultPrefixes);
00491 
00499     bool
00500     isExcludedNamespaceURI(const XalanDOMString&    theNamespaceURI) const;
00501 
00508     bool
00509     isExtensionNamespaceURI(const XalanDOMString&   theNamespaceURI) const
00510     {
00511         return findString(theNamespaceURI, m_extensionNamespaceURIs);
00512     }
00513 
00520     static bool
00521     findString(
00522             const XalanDOMString&                   theString,
00523             const XalanDOMStringPointerVectorType&  theVector);
00524 
00525 
00526     // Not implemented...
00527     bool
00528     operator==(const NamespacesHandler&) const;
00529 
00530 
00531     // Data members...
00532     NamespacesVectorType                m_excludedResultPrefixes;
00533 
00534     NamespaceExtendedVectorType         m_namespaceDeclarations;
00535 
00536     XalanDOMStringPointerVectorType     m_extensionNamespaceURIs;
00537 
00538     NamespaceAliasesMapType             m_namespaceAliases;
00539 };
00540 
00541 
00542 
00543 XALAN_CPP_NAMESPACE_END
00544 
00545 
00546 
00547 #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.6
Copyright © 2000, 2001, 2002, 2003 The Apache Software Foundation. All Rights Reserved.