00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 1999-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 #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 00078 00079 00080 #include <xalanc/XPath/NameSpace.hpp> 00081 00082 00083 00084 XALAN_CPP_NAMESPACE_BEGIN 00085 00086 00087 00088 class XalanElement; 00089 class XPathEnvSupport; 00090 00091 00092 00105 class XALAN_XPATH_EXPORT XalanQName 00106 { 00107 public: 00108 00109 #if defined(XALAN_NO_STD_NAMESPACE) 00110 typedef deque<NameSpace> NamespaceVectorType; 00111 typedef deque<NamespaceVectorType> NamespacesStackType; 00112 #else 00113 typedef std::deque<NameSpace> NamespaceVectorType; 00114 typedef std::deque<NamespaceVectorType> NamespacesStackType; 00115 #endif 00116 00121 explicit 00122 XalanQName() 00123 { 00124 } 00125 00126 virtual 00127 ~XalanQName() 00128 { 00129 } 00130 00136 virtual const XalanDOMString& 00137 getLocalPart() const = 0; 00138 00144 virtual const XalanDOMString& 00145 getNamespace() const = 0; 00146 00152 bool 00153 isValid() const 00154 { 00155 return isValidNCName(getLocalPart()); 00156 } 00157 00163 bool 00164 isEmpty() const 00165 { 00166 return getNamespace().empty() && getLocalPart().empty(); 00167 } 00168 00176 bool 00177 equals(const XalanQName& theRHS) const 00178 { 00179 // Note that we do not use our member variables here. See 00180 // class QNameReference for details... 00181 return getLocalPart() == theRHS.getLocalPart() && 00182 getNamespace() == theRHS.getNamespace(); 00183 } 00184 00185 XalanDOMString::size_type 00186 hash() const 00187 { 00188 return getLocalPart().hash() % getNamespace().hash(); 00189 } 00190 00191 class XALAN_XPATH_EXPORT PrefixResolverProxy : public PrefixResolver 00192 { 00193 public: 00194 00203 PrefixResolverProxy( 00204 const NamespacesStackType& theStack, 00205 const XalanDOMString& theURI); 00206 00207 virtual 00208 ~PrefixResolverProxy(); 00209 00210 virtual const XalanDOMString* 00211 getNamespaceForPrefix(const XalanDOMString& prefix) const; 00212 00213 virtual const XalanDOMString& 00214 getURI() const; 00215 00216 private: 00217 00218 const NamespacesStackType& m_stack; 00219 00220 const XalanDOMString& m_uri; 00221 }; 00222 00230 static const XalanDOMString* 00231 getNamespaceForPrefix( 00232 const NamespaceVectorType& namespaces, 00233 const XalanDOMString& prefix); 00234 00243 static const XalanDOMString* 00244 getNamespaceForPrefix( 00245 const NamespacesStackType& nsStack, 00246 const XalanDOMString& prefix); 00247 00258 static const XalanDOMString* 00259 getNamespaceForPrefix( 00260 NamespacesStackType::const_iterator theBegin, 00261 NamespacesStackType::const_iterator theEnd, 00262 const XalanDOMString& prefix); 00263 00272 static const XalanDOMString* 00273 getPrefixForNamespace( 00274 const NamespaceVectorType& namespaces, 00275 const XalanDOMString& uri); 00276 00285 static const XalanDOMString* 00286 getPrefixForNamespace( 00287 const NamespacesStackType& nsStack, 00288 const XalanDOMString& uri); 00289 00300 static const XalanDOMString* 00301 getPrefixForNamespace( 00302 NamespacesStackType::const_iterator theBegin, 00303 NamespacesStackType::const_iterator theEnd, 00304 const XalanDOMString& uri); 00305 00313 static bool 00314 isValidNCName(const XalanDOMString& theNCName); 00315 00324 static bool 00325 isValidNCName( 00326 const XalanDOMChar* theNCName, 00327 XalanDOMString::size_type theLength = XalanDOMString::npos); 00328 00337 static bool 00338 isValidQName(const XalanDOMString& theQName); 00339 00349 static bool 00350 isValidQName( 00351 const XalanDOMChar* theQName, 00352 XalanDOMString::size_type theLength = XalanDOMString::npos); 00353 00354 protected: 00355 00356 static const XalanDOMString s_emptyString; 00357 }; 00358 00359 00360 00361 inline bool 00362 operator==( 00363 const XalanQName& theLHS, 00364 const XalanQName& theRHS) 00365 { 00366 return theLHS.equals(theRHS); 00367 } 00368 00369 00370 00371 inline bool 00372 operator!=( 00373 const XalanQName& theLHS, 00374 const XalanQName& theRHS) 00375 { 00376 return !(theLHS == theRHS); 00377 } 00378 00379 00380 00381 inline bool 00382 operator<( 00383 const XalanQName& theLHS, 00384 const XalanQName& theRHS) 00385 { 00386 if (theLHS.getNamespace() < theRHS.getNamespace()) 00387 { 00388 return true; 00389 } 00390 else if (equals(theLHS.getNamespace(), theRHS.getNamespace())) 00391 { 00392 return theLHS.getLocalPart() < theRHS.getLocalPart(); 00393 } 00394 else 00395 { 00396 return false; 00397 } 00398 } 00399 00400 00401 00402 XALAN_CPP_NAMESPACE_END 00403 00404 00405 00406 #endif // XALANQNAME_HEADER_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
![]() |
Xalan-C++ XSLT Processor Version 1.6 |
|