00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 2000 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 <XSLT/XSLTDefinitions.hpp> 00068 00069 00070 00071 #include <map> 00072 #include <set> 00073 #include <vector> 00074 00075 00076 00077 #include <XalanDOM/XalanDOMString.hpp> 00078 00079 00080 00081 #include <XPath/NameSpace.hpp> 00082 #include <XPath/QName.hpp> 00083 00084 00085 00086 class StylesheetConstructionContext; 00087 class StylesheetExecutionContext; 00088 00089 00090 00091 class XALAN_XSLT_EXPORT NamespacesHandler 00092 { 00093 public: 00094 00098 static void 00099 initialize(); 00100 00104 static void 00105 terminate(); 00106 00107 00108 /* Some static strings for various namespace URIs... 00109 * 00110 */ 00111 static const XalanDOMString& s_ApacheXSLTNamespaceURI; 00112 00113 static const XalanDOMString& s_LotusXSLTNamespaceURI; 00114 00115 static const XalanDOMString& s_LotusXSLTNamespaceURIWithSeparator; 00116 00117 00118 class NameSpaceExtended : public NameSpace 00119 { 00120 public: 00121 00122 NameSpaceExtended( 00123 const XalanDOMString& prefix = XalanDOMString(), 00124 const XalanDOMString& uri = XalanDOMString()) : 00125 NameSpace(prefix, uri), 00126 m_resultAttributeName() 00127 { 00128 } 00129 00130 NameSpaceExtended(const NameSpace& theNamespace) : 00131 NameSpace(theNamespace), 00132 m_resultAttributeName() 00133 { 00134 } 00135 00141 const XalanDOMString& 00142 getResultAttributeName() const 00143 { 00144 return m_resultAttributeName; 00145 } 00146 00152 void 00153 setResultAttributeName(const XalanDOMString& name) 00154 { 00155 m_resultAttributeName = name; 00156 } 00157 00158 private: 00159 00160 XalanDOMString m_resultAttributeName; 00161 }; 00162 00163 typedef QName::NamespaceVectorType NamespaceVectorType; 00164 typedef QName::NamespacesStackType NamespacesStackType; 00165 00166 #if defined(XALAN_NO_NAMESPACES) 00167 typedef map<XalanDOMString, 00168 XalanDOMString, 00169 less<XalanDOMString> > ExcludedResultPrefixesMapType; 00170 00171 typedef map<XalanDOMString, 00172 NameSpaceExtended, 00173 less<XalanDOMString> > NamespacesMapType; 00174 00175 typedef map<XalanDOMString, 00176 XalanDOMString, 00177 less<XalanDOMString> > NamespaceAliasesMapType; 00178 00179 typedef set<XalanDOMString, 00180 less<XalanDOMString> > ExtensionNamespaceURISetType; 00181 #else 00182 typedef std::map<XalanDOMString, XalanDOMString> ExcludedResultPrefixesMapType; 00183 00184 typedef std::map<XalanDOMString, 00185 NameSpaceExtended> NamespacesMapType; 00186 00187 typedef std::map<XalanDOMString, XalanDOMString> NamespaceAliasesMapType; 00188 00189 typedef std::set<XalanDOMString> ExtensionNamespaceURISetType; 00190 #endif 00191 00195 explicit 00196 NamespacesHandler(); 00197 00206 NamespacesHandler( 00207 const NamespacesHandler& stylesheetNamespacesHandler, 00208 const NamespacesStackType& theCurrentNamespaces, 00209 const XalanDOMString& theXSLTNamespaceURI); 00210 00211 NamespacesHandler(const NamespacesHandler& theSource); 00212 00213 ~NamespacesHandler(); 00214 00222 void 00223 processExcludeResultPrefixes( 00224 const XalanDOMChar* theValue, 00225 const NamespacesStackType& theCurrentNamespaces, 00226 StylesheetConstructionContext& theConstructionContext); 00227 00235 void 00236 processExtensionElementPrefixes( 00237 const XalanDOMChar* theValue, 00238 const NamespacesStackType& theCurrentNamespaces, 00239 StylesheetConstructionContext& theConstructionContext); 00240 00247 void 00248 postConstruction( 00249 const XalanDOMString& theElementName = XalanDOMString(), 00250 const NamespacesHandler* parentNamespacesHandler = 0); 00251 00252 NamespacesHandler& 00253 operator=(const NamespacesHandler& theRHS); 00254 00263 bool 00264 shouldExcludeResultNamespaceNode( 00265 const XalanDOMString& theXSLTNamespaceURI, 00266 const XalanDOMString& thePrefix, 00267 const XalanDOMString& theURI) const; 00268 00276 bool 00277 hasExcludedPrefix(const XalanDOMString& thePrefix) const 00278 { 00279 return m_excludedResultPrefixes.count(thePrefix) != 0 ? true : false; 00280 } 00281 00287 void 00288 addExtensionNamespaceURI(const XalanDOMString& theURI) 00289 { 00290 m_extensionNamespaceURIs.insert(theURI); 00291 } 00292 00299 const XalanDOMString& 00300 getNamespace(const XalanDOMString& thePrefix) const; 00301 00308 const XalanDOMString& 00309 getNamespaceAlias(const XalanDOMString& theStylesheetNamespace) const; 00310 00317 void 00318 setNamespaceAlias( 00319 const XalanDOMString& theStylesheetNamespace, 00320 const XalanDOMString& theResultNamespace) 00321 { 00322 m_namespaceAliases[theStylesheetNamespace] = theResultNamespace; 00323 } 00324 00330 void 00331 copyNamespaceAliases(const NamespacesHandler& parentNamespacesHandler); 00332 00338 void 00339 outputResultNamespaces(StylesheetExecutionContext& theExecutionContext) const; 00340 00344 void 00345 clear(); 00346 00352 void 00353 swap(NamespacesHandler& theOther); 00354 00355 bool 00356 getProcessNamespaceAliaises() const 00357 { 00358 return m_processAliases; 00359 } 00360 00361 void 00362 setProcessNamespaceAliaises(bool fValue) 00363 { 00364 m_processAliases = fValue; 00365 } 00366 00367 private: 00368 00372 void 00373 createResultAttributeNames(); 00374 00380 void 00381 processExcludeResultPrefixes(const XalanDOMString& theElementPrefix); 00382 00386 void 00387 processNamespaceAliases(); 00388 00394 void 00395 copyNamespaceAliases(const NamespaceAliasesMapType& theNamespaceAliases); 00396 00402 void 00403 copyExtensionNamespaceURIs(const ExtensionNamespaceURISetType& theExtensionNamespaceURIs); 00404 00410 void 00411 copyExcludeResultPrefixes(const ExcludedResultPrefixesMapType& theExcludeResultPrefixes); 00412 00422 bool 00423 shouldExcludeResultNamespaceNode( 00424 const XalanDOMString& theXSLTNamespaceURI, 00425 const NamespacesHandler& parentNamespacesHandler, 00426 const NameSpace& theNamespace) const; 00427 00428 // Not implemented... 00429 bool 00430 operator==(const NamespacesHandler&) const; 00431 00432 // Data members... 00433 ExcludedResultPrefixesMapType m_excludedResultPrefixes; 00434 00435 NamespacesMapType m_namespaceDeclarations; 00436 00437 ExtensionNamespaceURISetType m_extensionNamespaceURIs; 00438 00439 NamespaceAliasesMapType m_namespaceAliases; 00440 00441 // If true namespace aliases will be processed. If false, they will not. 00442 bool m_processAliases; 00443 00444 const static XalanDOMString s_dummyEmptyString; 00445 }; 00446 00447 00448 00449 #endif // XALAN_NAMESPACESHANDLER_HEADER_GUARD
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
![]() |
Xalan-C++ XSL Transformer Version 1.1 |
|