## Xalan-C++ API Documentation

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

Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members

# XalanQName.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 #if !defined(XALANQNAME_HEADER_GUARD_1357924680)
    00017 #define XALANQNAME_HEADER_GUARD_1357924680
    00018
    00019
    00020
    00021 // Base header file.  Must be first.
    00022 #include <xalanc/XPath/XPathDefinitions.hpp>
    00023
    00024
    00025
    00026 #include <xalanc/Include/XalanMap.hpp>
    00027 #include <xalanc/Include/XalanDeque.hpp>
    00028 #include <xalanc/Include/STLHelper.hpp>
    00029
    00030
    00031
    00032 #include <xalanc/XalanDOM/XalanDOMString.hpp>
    00033
    00034
    00035
    00036 #include <xalanc/PlatformSupport/DOMStringHelper.hpp>
    00037 #include <xalanc/PlatformSupport/PrefixResolver.hpp>
    00038 #include <xalanc/PlatformSupport/XSLException.hpp>
    00039
    00040
    00041
    00042 #include <xalanc/XPath/NameSpace.hpp>
    00043
    00044
    00045
    00046 XALAN_CPP_NAMESPACE_BEGIN
    00047
    00048
    00049
    00050 class XalanElement;
    00051 class XPathEnvSupport;
    00052
    00053
    00054
    00067
    00068 class XALAN_XPATH_EXPORT XalanQName
    00069 {
    00070 public:
    00071
    00072     typedef XalanDeque<NameSpace, ConstructWithMemoryManagerTraits<NameSpace> >
    00073                                                             NamespaceVectorType;
    00074     typedef XalanDeque<NamespaceVectorType, ConstructWithMemoryManagerTraits<NamespaceVectorType> >
    00075                                                             NamespacesStackType;
    00076
    00081     explicit
    00082     XalanQName()
    00083     {
    00084     }
    00085
    00086     virtual
    00087     ~XalanQName()
    00088     {
    00089     }
    00090
    00096     virtual const XalanDOMString&
    00097     getLocalPart() const = 0;
    00098
    00104     virtual const XalanDOMString&
    00105     getNamespace() const = 0;
    00106
    00112     bool
    00113     isValid() const
    00114     {
    00115         return isValidNCName(getLocalPart());
    00116     }
    00117
    00123     bool
    00124     isEmpty() const
    00125     {
    00126         return getNamespace().empty() && getLocalPart().empty();
    00127     }
    00128
    00136     bool
    00137     equals(const XalanQName&    theRHS) const
    00138     {
    00139         // Note that we do not use our member variables here.  See
    00140         // class QNameReference for details...
    00141         return getLocalPart() == theRHS.getLocalPart() &&
    00142                getNamespace() == theRHS.getNamespace();
    00143     }
    00144
    00145     XalanDOMString::size_type
    00146     hash() const
    00147     {
    00148         return getLocalPart().hash() % (getNamespace().hash() + 1);
    00149     }
    00150
    00151     class XALAN_XPATH_EXPORT PrefixResolverProxy : public PrefixResolver
    00152     {
    00153     public:
    00154
    00163         PrefixResolverProxy(
    00164                 const NamespacesStackType&  theStack,
    00165                 const XalanDOMString&       theURI);
    00166
    00167         virtual
    00168         ~PrefixResolverProxy();
    00169
    00170         virtual const XalanDOMString*
    00171         getNamespaceForPrefix(const XalanDOMString&     prefix) const;
    00172
    00173         virtual const XalanDOMString&
    00174         getURI() const;
    00175
    00176     private:
    00177
    00178         const NamespacesStackType&  m_stack;
    00179
    00180         const XalanDOMString&       m_uri;
    00181     };
    00182
    00190     static const XalanDOMString*
    00191     getNamespaceForPrefix(
    00192             const NamespaceVectorType&  namespaces,
    00193             const XalanDOMString&       prefix);
    00194
    00203     static const XalanDOMString*
    00204     getNamespaceForPrefix(
    00205             const NamespacesStackType&  nsStack,
    00206             const XalanDOMString&       prefix);
    00207
    00208     static const XalanDOMString*
    00209     getNamespaceForPrefix(
    00210             const NamespacesStackType&  nsStack,
    00211             const XalanDOMChar*         prefix);
    00212
    00223     static const XalanDOMString*
    00224     getNamespaceForPrefix(
    00225             NamespacesStackType::const_iterator     theBegin,
    00226             NamespacesStackType::const_iterator     theEnd,
    00227             const XalanDOMString&                   prefix);
    00228
    00237     static const XalanDOMString*
    00238     getPrefixForNamespace(
    00239             const NamespaceVectorType&  namespaces,
    00240             const XalanDOMString&       uri);
    00241
    00242     static const XalanDOMString*
    00243     getNamespaceForPrefix(
    00244             const NamespaceVectorType&  namespaces,
    00245             const XalanDOMChar*         prefix);
    00246
    00255     static const XalanDOMString*
    00256     getPrefixForNamespace(
    00257             const NamespacesStackType&  nsStack,
    00258             const XalanDOMString&       uri);
    00259
    00270     static const XalanDOMString*
    00271     getPrefixForNamespace(
    00272             NamespacesStackType::const_iterator     theBegin,
    00273             NamespacesStackType::const_iterator     theEnd,
    00274             const XalanDOMString&                   uri);
    00275
    00276     static const XalanDOMString*
    00277     getNamespaceForPrefix(
    00278             NamespacesStackType::const_iterator     theBegin,
    00279             NamespacesStackType::const_iterator     theEnd,
    00280             const XalanDOMChar*                     prefix);
    00288     static bool
    00289     isValidNCName(const XalanDOMString&     theNCName);
    00290
    00299     static bool
    00300     isValidNCName(
    00301             const XalanDOMChar*         theNCName,
    00302             XalanDOMString::size_type   theLength = XalanDOMString::npos);
    00303
    00312     static bool
    00313     isValidQName(const XalanDOMString&  theQName);
    00314
    00324     static bool
    00325     isValidQName(
    00326             const XalanDOMChar*         theQName,
    00327             XalanDOMString::size_type   theLength = XalanDOMString::npos);
    00328
    00329     class InvalidQNameException : public XSLException
    00330     {
    00331     public:
    00332
    00343         InvalidQNameException(
    00344                 const XalanDOMChar*         theQName,
    00345                 XalanDOMString::size_type   theQNameLength,
    00346                 const XalanDOMString&       theURI,
    00347                 int                         theLineNumber,
    00348                 int                         theColumnNumber,
    00349                 XalanDOMString&             theResult);
    00350
    00359         InvalidQNameException(
    00360                 const LocatorType&          theLocator,
    00361                 const XalanDOMChar*         theQName,
    00362                 XalanDOMString::size_type   theQNameLength,
    00363                 XalanDOMString&             theResult);
    00364
    00372         InvalidQNameException(
    00373                 const XalanDOMChar*         theQName,
    00374                 XalanDOMString::size_type   theQNameLength,
    00375                 XalanDOMString&             theResult);
    00376
    00377         virtual
    00378         ~InvalidQNameException();
    00379
    00380         virtual const XalanDOMChar*
    00381         getType() const
    00382         {
    00383             return m_type;
    00384         }
    00385
    00386     private:
    00387
    00388         static const XalanDOMChar   m_type[];
    00389
    00390         static const XalanDOMString&
    00391         format(
    00392                 const XalanDOMChar*         theQName,
    00393                 XalanDOMString::size_type   theQNameLength,
    00394                 XalanDOMString&             theResult);
    00395     };
    00396
    00397 protected:
    00398
    00399     static const XalanDOMString     s_emptyString;
    00400 };
    00401
    00402
    00403 inline bool
    00404 operator==(
    00405             const XalanQName&   theLHS,
    00406             const XalanQName&   theRHS)
    00407 {
    00408     return theLHS.equals(theRHS);
    00409 }
    00410
    00411
    00412
    00413 inline bool
    00414 operator!=(
    00415             const XalanQName&   theLHS,
    00416             const XalanQName&   theRHS)
    00417 {
    00418     return !(theLHS == theRHS);
    00419 }
    00420
    00421
    00422
    00423 inline bool
    00424 operator<(
    00425             const XalanQName&   theLHS,
    00426             const XalanQName&   theRHS)
    00427 {
    00428     if (theLHS.getNamespace() < theRHS.getNamespace())
    00429     {
    00430         return true;
    00431     }
    00432     else if (equals(theLHS.getNamespace(), theRHS.getNamespace()))
    00433     {
    00434         return theLHS.getLocalPart() < theRHS.getLocalPart();
    00435     }
    00436     else
    00437     {
    00438         return false;
    00439     }
    00440 }
    00441
    00442 template<>
    00443 struct XalanMapKeyTraits<XalanQName>
    00444 {
    00445     typedef XalanHashMemberReference<XalanQName>        Hasher;
    00446     typedef XALAN_STD_QUALIFIER equal_to<XalanQName>    Comparator;
    00447 };
    00448
    00449 template<>
    00450 struct XalanMapKeyTraits<const XalanQName*>
    00451 {
    00452     typedef XalanHashMemberPointer<XalanQName>      Hasher;
    00453     typedef pointer_equal<XalanQName>               Comparator;
    00454 };
    00455
    00456
    00457 XALAN_CPP_NAMESPACE_END
    00458
    00459
    00460
    00461 #endif  // XALANQNAME_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.10 Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.