## 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

# XalanQName.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(XALANQNAME_HEADER_GUARD_1357924680)
    00058 #define XALANQNAME_HEADER_GUARD_1357924680
    00059
    00060
    00061
    00062 // Base header file.  Must be first.
    00063 #include <xalanc/XPath/XPathDefinitions.hpp>
    00064
    00065
    00066
    00067 #include <deque>
    00068
    00069
    00070
    00071 #include <xalanc/XalanDOM/XalanDOMString.hpp>
    00072
    00073
    00074
    00075 #include <xalanc/PlatformSupport/DOMStringHelper.hpp>
    00076 #include <xalanc/PlatformSupport/PrefixResolver.hpp>
    00077 #include <xalanc/PlatformSupport/XSLException.hpp>
    00078
    00079
    00080
    00081 #include <xalanc/XPath/NameSpace.hpp>
    00082
    00083
    00084
    00085 XALAN_CPP_NAMESPACE_BEGIN
    00086
    00087
    00088
    00089 class XalanElement;
    00090 class XPathEnvSupport;
    00091
    00092
    00093
    00106 class XALAN_XPATH_EXPORT XalanQName
    00107 {
    00108 public:
    00109
    00110 #if defined(XALAN_NO_STD_NAMESPACE)
    00111     typedef deque<NameSpace>                    NamespaceVectorType;
    00112     typedef deque<NamespaceVectorType>          NamespacesStackType;
    00113 #else
    00114     typedef std::deque<NameSpace>               NamespaceVectorType;
    00115     typedef std::deque<NamespaceVectorType>     NamespacesStackType;
    00116 #endif
    00117
    00122     explicit
    00123     XalanQName()
    00124     {
    00125     }
    00126
    00127     virtual
    00128     ~XalanQName()
    00129     {
    00130     }
    00131
    00137     virtual const XalanDOMString&
    00138     getLocalPart() const = 0;
    00139
    00145     virtual const XalanDOMString&
    00146     getNamespace() const = 0;
    00147
    00153     bool
    00154     isValid() const
    00155     {
    00156         return isValidNCName(getLocalPart());
    00157     }
    00158
    00164     bool
    00165     isEmpty() const
    00166     {
    00167         return getNamespace().empty() && getLocalPart().empty();
    00168     }
    00169
    00177     bool
    00178     equals(const XalanQName&    theRHS) const
    00179     {
    00180         // Note that we do not use our member variables here.  See
    00181         // class QNameReference for details...
    00182         return getLocalPart() == theRHS.getLocalPart() &&
    00183                getNamespace() == theRHS.getNamespace();
    00184     }
    00185
    00186     XalanDOMString::size_type
    00187     hash() const
    00188     {
    00189         return getLocalPart().hash() % getNamespace().hash();
    00190     }
    00191
    00192     class XALAN_XPATH_EXPORT PrefixResolverProxy : public PrefixResolver
    00193     {
    00194     public:
    00195
    00204         PrefixResolverProxy(
    00205                 const NamespacesStackType&  theStack,
    00206                 const XalanDOMString&       theURI);
    00207
    00208         virtual
    00209         ~PrefixResolverProxy();
    00210
    00211         virtual const XalanDOMString*
    00212         getNamespaceForPrefix(const XalanDOMString&     prefix) const;
    00213
    00214         virtual const XalanDOMString&
    00215         getURI() const;
    00216
    00217     private:
    00218
    00219         const NamespacesStackType&  m_stack;
    00220
    00221         const XalanDOMString&       m_uri;
    00222     };
    00223
    00231     static const XalanDOMString*
    00232     getNamespaceForPrefix(
    00233             const NamespaceVectorType&  namespaces,
    00234             const XalanDOMString&       prefix);
    00235
    00244     static const XalanDOMString*
    00245     getNamespaceForPrefix(
    00246             const NamespacesStackType&  nsStack,
    00247             const XalanDOMString&       prefix);
    00248
    00259     static const XalanDOMString*
    00260     getNamespaceForPrefix(
    00261             NamespacesStackType::const_iterator     theBegin,
    00262             NamespacesStackType::const_iterator     theEnd,
    00263             const XalanDOMString&                   prefix);
    00264
    00273     static const XalanDOMString*
    00274     getPrefixForNamespace(
    00275             const NamespaceVectorType&  namespaces,
    00276             const XalanDOMString&       uri);
    00277
    00286     static const XalanDOMString*
    00287     getPrefixForNamespace(
    00288             const NamespacesStackType&  nsStack,
    00289             const XalanDOMString&       uri);
    00290
    00301     static const XalanDOMString*
    00302     getPrefixForNamespace(
    00303             NamespacesStackType::const_iterator     theBegin,
    00304             NamespacesStackType::const_iterator     theEnd,
    00305             const XalanDOMString&                   uri);
    00306
    00314     static bool
    00315     isValidNCName(const XalanDOMString&     theNCName);
    00316
    00325     static bool
    00326     isValidNCName(
    00327             const XalanDOMChar*         theNCName,
    00328             XalanDOMString::size_type   theLength = XalanDOMString::npos);
    00329
    00338     static bool
    00339     isValidQName(const XalanDOMString&  theQName);
    00340
    00350     static bool
    00351     isValidQName(
    00352             const XalanDOMChar*         theQName,
    00353             XalanDOMString::size_type   theLength = XalanDOMString::npos);
    00354
    00355     class InvalidQNameException : public XSLException
    00356     {
    00357     public:
    00358
    00369         InvalidQNameException(
    00370                 const XalanDOMChar*         theQName,
    00371                 XalanDOMString::size_type   theQNameLength,
    00372                 const XalanDOMString&       theURI,
    00373                 int                         theLineNumber,
    00374                 int                         theColumnNumber);
    00375
    00384         InvalidQNameException(
    00385                 const LocatorType&          theLocator,
    00386                 const XalanDOMChar*         theQName,
    00387                 XalanDOMString::size_type   theQNameLength);
    00388
    00396         InvalidQNameException(
    00397                 const XalanDOMChar*         theQName,
    00398                 XalanDOMString::size_type   theQNameLength);
    00399
    00400         virtual
    00401         ~InvalidQNameException();
    00402
    00403     private:
    00404
    00405         static const XalanDOMString
    00406         format(
    00407                 const XalanDOMChar*         theQName,
    00408                 XalanDOMString::size_type   theQNameLength);
    00409     };
    00410
    00411 protected:
    00412
    00413     static const XalanDOMString     s_emptyString;
    00414 };
    00415
    00416
    00417
    00418 inline bool
    00419 operator==(
    00420             const XalanQName&   theLHS,
    00421             const XalanQName&   theRHS)
    00422 {
    00423     return theLHS.equals(theRHS);
    00424 }
    00425
    00426
    00427
    00428 inline bool
    00429 operator!=(
    00430             const XalanQName&   theLHS,
    00431             const XalanQName&   theRHS)
    00432 {
    00433     return !(theLHS == theRHS);
    00434 }
    00435
    00436
    00437
    00438 inline bool
    00439 operator<(
    00440             const XalanQName&   theLHS,
    00441             const XalanQName&   theRHS)
    00442 {
    00443     if (theLHS.getNamespace() < theRHS.getNamespace())
    00444     {
    00445         return true;
    00446     }
    00447     else if (equals(theLHS.getNamespace(), theRHS.getNamespace()))
    00448     {
    00449         return theLHS.getLocalPart() < theRHS.getLocalPart();
    00450     }
    00451     else
    00452     {
    00453         return false;
    00454     }
    00455 }
    00456
    00457
    00458
    00459 XALAN_CPP_NAMESPACE_END
    00460
    00461
    00462
    00463 #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.7 Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.