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/XalanQName.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 XalanQName::NamespaceVectorType NamespaceVectorType; 00164 typedef XalanQName::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 00182 typedef set<XalanDOMString, 00183 less<XalanDOMString> > ActivePrefixesSetType; 00184 #else 00185 typedef std::map<XalanDOMString, XalanDOMString> ExcludedResultPrefixesMapType; 00186 00187 typedef std::map<XalanDOMString, 00188 NameSpaceExtended> NamespacesMapType; 00189 00190 typedef std::map<XalanDOMString, XalanDOMString> NamespaceAliasesMapType; 00191 00192 typedef std::set<XalanDOMString> ExtensionNamespaceURISetType; 00193 00194 typedef std::set<XalanDOMString> ActivePrefixesSetType; 00195 #endif 00196 00200 explicit 00201 NamespacesHandler(); 00202 00211 NamespacesHandler( 00212 const NamespacesHandler& stylesheetNamespacesHandler, 00213 const NamespacesStackType& theCurrentNamespaces, 00214 const XalanDOMString& theXSLTNamespaceURI); 00215 00216 NamespacesHandler(const NamespacesHandler& theSource); 00217 00218 ~NamespacesHandler(); 00219 00227 void 00228 processExcludeResultPrefixes( 00229 const XalanDOMChar* theValue, 00230 const NamespacesStackType& theCurrentNamespaces, 00231 StylesheetConstructionContext& theConstructionContext); 00232 00240 void 00241 processExtensionElementPrefixes( 00242 const XalanDOMChar* theValue, 00243 const NamespacesStackType& theCurrentNamespaces, 00244 StylesheetConstructionContext& theConstructionContext); 00245 00252 void 00253 postConstruction( 00254 const XalanDOMString& theElementName = XalanDOMString(), 00255 const NamespacesHandler* parentNamespacesHandler = 0); 00256 00257 NamespacesHandler& 00258 operator=(const NamespacesHandler& theRHS); 00259 00268 bool 00269 shouldExcludeResultNamespaceNode( 00270 const XalanDOMString& theXSLTNamespaceURI, 00271 const XalanDOMString& thePrefix, 00272 const XalanDOMString& theURI) const; 00273 00281 bool 00282 hasExcludedPrefix(const XalanDOMString& thePrefix) const 00283 { 00284 return m_excludedResultPrefixes.count(thePrefix) != 0 ? true : false; 00285 } 00286 00292 void 00293 addExtensionNamespaceURI(const XalanDOMString& theURI) 00294 { 00295 m_extensionNamespaceURIs.insert(theURI); 00296 } 00297 00304 const XalanDOMString* 00305 getNamespace(const XalanDOMString& thePrefix) const; 00306 00313 const XalanDOMString* 00314 getNamespaceAlias(const XalanDOMString& theStylesheetNamespace) const; 00315 00322 void 00323 setNamespaceAlias( 00324 const XalanDOMString& theStylesheetNamespace, 00325 const XalanDOMString& theResultNamespace) 00326 { 00327 m_namespaceAliases[theStylesheetNamespace] = theResultNamespace; 00328 } 00329 00335 void 00336 addActivePrefix(const XalanDOMString& thePrefix) 00337 { 00338 m_activePrefixes.insert(thePrefix); 00339 } 00340 00346 void 00347 copyNamespaceAliases(const NamespacesHandler& parentNamespacesHandler); 00348 00355 void 00356 outputResultNamespaces( 00357 StylesheetExecutionContext& theExecutionContext, 00358 bool supressDefault = false) const; 00359 00363 void 00364 clear(); 00365 00371 void 00372 swap(NamespacesHandler& theOther); 00373 00374 bool 00375 getProcessNamespaceAliaises() const 00376 { 00377 return m_processAliases; 00378 } 00379 00380 void 00381 setProcessNamespaceAliaises(bool fValue) 00382 { 00383 m_processAliases = fValue; 00384 } 00385 00386 NamespacesMapType::size_type 00387 getNamespaceDeclarationsCount() const 00388 { 00389 return m_namespaceDeclarations.size(); 00390 } 00391 00392 private: 00393 00397 void 00398 createResultAttributeNames(); 00399 00405 void 00406 processExcludeResultPrefixes(const XalanDOMString& theElementPrefix); 00407 00411 void 00412 processNamespaceAliases(); 00413 00419 void 00420 copyNamespaceAliases(const NamespaceAliasesMapType& theNamespaceAliases); 00421 00427 void 00428 copyExtensionNamespaceURIs(const ExtensionNamespaceURISetType& theExtensionNamespaceURIs); 00429 00435 void 00436 copyExcludeResultPrefixes(const ExcludedResultPrefixesMapType& theExcludeResultPrefixes); 00437 00447 bool 00448 shouldExcludeResultNamespaceNode( 00449 const XalanDOMString& theXSLTNamespaceURI, 00450 const NamespacesHandler& parentNamespacesHandler, 00451 const NameSpace& theNamespace) const; 00452 00453 // Not implemented... 00454 bool 00455 operator==(const NamespacesHandler&) const; 00456 00457 // Data members... 00458 ExcludedResultPrefixesMapType m_excludedResultPrefixes; 00459 00460 NamespacesMapType m_namespaceDeclarations; 00461 00462 ExtensionNamespaceURISetType m_extensionNamespaceURIs; 00463 00464 NamespaceAliasesMapType m_namespaceAliases; 00465 00466 ActivePrefixesSetType m_activePrefixes; 00467 00468 // If true namespace aliases will be processed. If false, they will not. 00469 bool m_processAliases; 00470 }; 00471 00472 00473 00474 #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 |
|