Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.8

Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

NamespacesHandler.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 1999-2004 The Apache Software Foundation.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #if !defined(XALAN_NAMESPACESHANDLER_HEADER_GUARD)
00018 #define XALAN_NAMESPACESHANDLER_HEADER_GUARD
00019 
00020 
00021 
00022 // Base include file.  Must be first.
00023 #include <xalanc/XSLT/XSLTDefinitions.hpp>
00024 
00025 
00026 
00027 #include <map>
00028 #include <set>
00029 #include <vector>
00030 
00031 
00032 
00033 #include <xalanc/PlatformSupport/DOMStringHelper.hpp>
00034 
00035 
00036 
00037 #include <xalanc/XPath/NameSpace.hpp>
00038 #include <xalanc/XPath/XalanQName.hpp>
00039 
00040 
00041 
00042 XALAN_CPP_NAMESPACE_BEGIN
00043 
00044 
00045 
00046 class StylesheetConstructionContext;
00047 class StylesheetExecutionContext;
00048 
00049 
00050 
00051 class XALAN_XSLT_EXPORT NamespacesHandler
00052 {
00053 public:
00054 
00055     class PrefixChecker
00056     {
00057     public:
00058 
00059         PrefixChecker();
00060 
00061         virtual
00062         ~PrefixChecker();
00063 
00064         virtual bool
00065         isActive(const XalanDOMString&  thePrefix) const = 0;
00066     };
00067 
00068     class XALAN_XSLT_EXPORT Namespace
00069     {
00070     public:
00071 
00072         Namespace() :
00073             m_prefix(&s_emptyString),
00074             m_uri(&s_emptyString)
00075         {
00076         }
00077 
00078         Namespace(
00079                     const XalanDOMString&   prefix,
00080                     const XalanDOMString&   uri) :
00081             m_prefix(&prefix),
00082             m_uri(&uri)
00083         {
00084         }
00085 
00091         const XalanDOMString&
00092         getPrefix() const
00093         {
00094             assert(m_prefix != 0);
00095 
00096             return *m_prefix;
00097         }
00098 
00104         void
00105         setPrefix(const XalanDOMString&     prefix)
00106         {
00107             m_prefix = &prefix;
00108         }
00109 
00115         const XalanDOMString&
00116         getURI() const
00117         {
00118             assert(m_uri != 0);
00119 
00120             return *m_uri;
00121         }
00122 
00128         void
00129         setURI(const XalanDOMString&    uri)
00130         {
00131             m_uri = &uri;
00132         }
00133 
00134     protected:
00135 
00136         static const XalanDOMString     s_emptyString;
00137 
00138     private:
00139 
00140         const XalanDOMString*   m_prefix;
00141 
00142         const XalanDOMString*   m_uri;
00143     };
00144 
00145     class XALAN_XSLT_EXPORT NamespaceExtended : public Namespace
00146     {
00147     public:
00148 
00149         NamespaceExtended() :
00150             Namespace(),
00151             m_resultAttributeName(&s_emptyString)
00152         {
00153         }
00154 
00155         NamespaceExtended(
00156                     const XalanDOMString&   prefix,
00157                     const XalanDOMString&   uri) :
00158             Namespace(prefix, uri),
00159             m_resultAttributeName(&s_emptyString)
00160         {
00161         }
00162 
00168         const XalanDOMString&
00169         getResultAttributeName() const
00170         {
00171             assert(m_resultAttributeName != 0);
00172 
00173             return *m_resultAttributeName;
00174         }
00175 
00181         void
00182         setResultAttributeName(const XalanDOMString&    name)
00183         {
00184             m_resultAttributeName = &name;
00185         }
00186 
00187     private:
00188 
00189         const XalanDOMString*   m_resultAttributeName;
00190     };
00191 
00192     typedef XalanQName::NamespaceVectorType             NamespaceVectorType;
00193     typedef XalanQName::NamespacesStackType             NamespacesStackType;
00194 
00195 #if defined(XALAN_NO_STD_NAMESPACE)
00196     typedef vector<Namespace>                           NamespacesVectorType;
00197 
00198     typedef vector<NamespaceExtended>                   NamespaceExtendedVectorType;
00199 
00200     typedef map<const XalanDOMString*,
00201                 const XalanDOMString*,
00202                 DOMStringPointerLessThanFunction>       ExcludedResultPrefixesMapType;
00203 
00204     typedef map<const XalanDOMString*,
00205                 NamespaceExtended,
00206                 DOMStringPointerLessThanFunction>       NamespacesMapType;
00207 
00208     typedef map<const XalanDOMString*,
00209                 const XalanDOMString*,
00210                 DOMStringPointerLessThanFunction>       NamespaceAliasesMapType;
00211 
00212     typedef vector<const XalanDOMString*>               XalanDOMStringPointerVectorType;
00213 #else
00214     typedef std::vector<Namespace>                      NamespacesVectorType;
00215 
00216     typedef std::vector<NamespaceExtended>              NamespaceExtendedVectorType;
00217 
00218     typedef std::map<const XalanDOMString*,
00219                      const XalanDOMString*,
00220                      DOMStringPointerLessThanFunction>  ExcludedResultPrefixesMapType;
00221 
00222     typedef std::map<const XalanDOMString*,
00223                      NamespaceExtended,
00224                      DOMStringPointerLessThanFunction>  NamespacesMapType;
00225 
00226     typedef std::map<const XalanDOMString*,
00227                      const XalanDOMString*,
00228                      DOMStringPointerLessThanFunction>  NamespaceAliasesMapType;
00229 
00230     typedef std::vector<const XalanDOMString*>          XalanDOMStringPointerVectorType;
00231 #endif
00232 
00236     explicit
00237     NamespacesHandler();
00238 
00248     NamespacesHandler(
00249             StylesheetConstructionContext&  theConstructionContext,
00250             const NamespacesHandler&        stylesheetNamespacesHandler,
00251             const NamespacesStackType&      theCurrentNamespaces,
00252             const XalanDOMString&           theXSLTNamespaceURI);
00253 
00254     ~NamespacesHandler();
00255 
00263     void
00264     processExcludeResultPrefixes(
00265             StylesheetConstructionContext&  theConstructionContext,
00266             const XalanDOMChar*             theValue,
00267             const NamespacesStackType&      theCurrentNamespaces);
00268 
00276     void
00277     processExtensionElementPrefixes(
00278             StylesheetConstructionContext&  theConstructionContext,
00279             const XalanDOMChar*             theValue,
00280             const NamespacesStackType&      theCurrentNamespaces);
00281 
00291     void
00292     postConstruction(
00293             StylesheetConstructionContext&  theConstructionContext,
00294             bool                            fProcessNamespaceAliases = true,
00295             const XalanDOMString&           theElementName = XalanDOMString(),
00296             const NamespacesHandler*        parentNamespacesHandler = 0,
00297             const PrefixChecker*            prefixChecker = 0);
00298 
00299     NamespacesHandler&
00300     operator=(const NamespacesHandler&  theRHS);
00301 
00309     bool
00310     shouldExcludeResultNamespaceNode(
00311             const XalanDOMString&   theXSLTNamespaceURI,
00312             const XalanDOMString&   theURI) const;
00313 
00320     void
00321     addExtensionNamespaceURI(
00322             StylesheetConstructionContext&  theConstructionContext,
00323             const XalanDOMString&   theURI);
00324 
00331     const XalanDOMString*
00332     getNamespace(const XalanDOMString&  thePrefix) const;
00333 
00340     const XalanDOMString*
00341     getNamespaceAlias(const XalanDOMString&     theStylesheetNamespace) const;
00342 
00350     void
00351     setNamespaceAlias(
00352             StylesheetConstructionContext&  theConstructionContext,
00353             const XalanDOMString&           theStylesheetNamespace,
00354             const XalanDOMString&           theResultNamespace);
00355 
00361     void
00362     copyNamespaceAliases(const NamespacesHandler&   parentNamespacesHandler);
00363 
00370     void
00371     outputResultNamespaces(
00372             StylesheetExecutionContext&     theExecutionContext,
00373             bool                            supressDefault = false) const;
00374 
00378     void
00379     clear();
00380 
00386     void
00387     swap(NamespacesHandler&     theOther);
00388 
00389     NamespacesMapType::size_type
00390     getNamespaceDeclarationsCount() const
00391     {
00392         return m_namespaceDeclarations.size();
00393     }
00394 
00395 private:
00396 
00402     void
00403     createResultAttributeNames(StylesheetConstructionContext&   theConstructionContext);
00404 
00412     void
00413     processExcludeResultPrefixes(
00414             StylesheetConstructionContext&  theConstructionContext,
00415             const XalanDOMString&           theElementPrefix,
00416             const PrefixChecker*            prefixChecker);
00417 
00421     void
00422     processNamespaceAliases();
00423 
00429     void
00430     copyNamespaceAliases(const NamespaceAliasesMapType&     theNamespaceAliases);
00431 
00437     void
00438     copyExtensionNamespaceURIs(const XalanDOMStringPointerVectorType&   theExtensionNamespaceURIs);
00439 
00445     void
00446     copyExcludeResultPrefixes(const NamespacesVectorType&   theExcludeResultPrefixes);
00447 
00455     bool
00456     isExcludedNamespaceURI(const XalanDOMString&    theNamespaceURI) const;
00457 
00464     bool
00465     isExtensionNamespaceURI(const XalanDOMString&   theNamespaceURI) const
00466     {
00467         return findString(theNamespaceURI, m_extensionNamespaceURIs);
00468     }
00469 
00476     static bool
00477     findString(
00478             const XalanDOMString&                   theString,
00479             const XalanDOMStringPointerVectorType&  theVector);
00480 
00481 
00482     // Not implemented...
00483     bool
00484     operator==(const NamespacesHandler&) const;
00485 
00486 
00487     // Data members...
00488     NamespacesVectorType                m_excludedResultPrefixes;
00489 
00490     NamespaceExtendedVectorType         m_namespaceDeclarations;
00491 
00492     XalanDOMStringPointerVectorType     m_extensionNamespaceURIs;
00493 
00494     NamespaceAliasesMapType             m_namespaceAliases;
00495 };
00496 
00497 
00498 
00499 XALAN_CPP_NAMESPACE_END
00500 
00501 
00502 
00503 #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.8
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.