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 00095 class NameSpaceExtended : public NameSpace 00096 { 00097 public: 00098 00099 NameSpaceExtended( 00100 const XalanDOMString& prefix = XalanDOMString(), 00101 const XalanDOMString& uri = XalanDOMString()) : 00102 NameSpace(prefix, uri), 00103 m_resultAttributeName() 00104 { 00105 } 00106 00107 NameSpaceExtended(const NameSpace& theNamespace) : 00108 NameSpace(theNamespace), 00109 m_resultAttributeName() 00110 { 00111 } 00112 00118 const XalanDOMString& 00119 getResultAttributeName() const 00120 { 00121 return m_resultAttributeName; 00122 } 00123 00129 void 00130 setResultAttributeName(const XalanDOMString& name) 00131 { 00132 m_resultAttributeName = name; 00133 } 00134 00135 private: 00136 00137 XalanDOMString m_resultAttributeName; 00138 }; 00139 00140 typedef XalanQName::NamespaceVectorType NamespaceVectorType; 00141 typedef XalanQName::NamespacesStackType NamespacesStackType; 00142 00143 #if defined(XALAN_NO_NAMESPACES) 00144 typedef map<XalanDOMString, 00145 XalanDOMString, 00146 less<XalanDOMString> > ExcludedResultPrefixesMapType; 00147 00148 typedef map<XalanDOMString, 00149 NameSpaceExtended, 00150 less<XalanDOMString> > NamespacesMapType; 00151 00152 typedef map<XalanDOMString, 00153 XalanDOMString, 00154 less<XalanDOMString> > NamespaceAliasesMapType; 00155 00156 typedef set<XalanDOMString, 00157 less<XalanDOMString> > ExtensionNamespaceURISetType; 00158 00159 typedef set<XalanDOMString, 00160 less<XalanDOMString> > ActivePrefixesSetType; 00161 #else 00162 typedef std::map<XalanDOMString, XalanDOMString> ExcludedResultPrefixesMapType; 00163 00164 typedef std::map<XalanDOMString, 00165 NameSpaceExtended> NamespacesMapType; 00166 00167 typedef std::map<XalanDOMString, XalanDOMString> NamespaceAliasesMapType; 00168 00169 typedef std::set<XalanDOMString> ExtensionNamespaceURISetType; 00170 00171 typedef std::set<XalanDOMString> ActivePrefixesSetType; 00172 #endif 00173 00177 explicit 00178 NamespacesHandler(); 00179 00188 NamespacesHandler( 00189 const NamespacesHandler& stylesheetNamespacesHandler, 00190 const NamespacesStackType& theCurrentNamespaces, 00191 const XalanDOMString& theXSLTNamespaceURI); 00192 00193 NamespacesHandler(const NamespacesHandler& theSource); 00194 00195 ~NamespacesHandler(); 00196 00204 void 00205 processExcludeResultPrefixes( 00206 const XalanDOMChar* theValue, 00207 const NamespacesStackType& theCurrentNamespaces, 00208 StylesheetConstructionContext& theConstructionContext); 00209 00217 void 00218 processExtensionElementPrefixes( 00219 const XalanDOMChar* theValue, 00220 const NamespacesStackType& theCurrentNamespaces, 00221 StylesheetConstructionContext& theConstructionContext); 00222 00229 void 00230 postConstruction( 00231 const XalanDOMString& theElementName = XalanDOMString(), 00232 const NamespacesHandler* parentNamespacesHandler = 0); 00233 00234 NamespacesHandler& 00235 operator=(const NamespacesHandler& theRHS); 00236 00244 bool 00245 shouldExcludeResultNamespaceNode( 00246 const XalanDOMString& theXSLTNamespaceURI, 00247 const XalanDOMString& theURI) const; 00248 00254 void 00255 addExtensionNamespaceURI(const XalanDOMString& theURI) 00256 { 00257 m_extensionNamespaceURIs.insert(theURI); 00258 } 00259 00266 const XalanDOMString* 00267 getNamespace(const XalanDOMString& thePrefix) const; 00268 00275 const XalanDOMString* 00276 getNamespaceAlias(const XalanDOMString& theStylesheetNamespace) const; 00277 00284 void 00285 setNamespaceAlias( 00286 const XalanDOMString& theStylesheetNamespace, 00287 const XalanDOMString& theResultNamespace) 00288 { 00289 m_namespaceAliases[theStylesheetNamespace] = theResultNamespace; 00290 } 00291 00297 void 00298 addActivePrefix(const XalanDOMString& thePrefix) 00299 { 00300 m_activePrefixes.insert(thePrefix); 00301 } 00302 00308 void 00309 copyNamespaceAliases(const NamespacesHandler& parentNamespacesHandler); 00310 00317 void 00318 outputResultNamespaces( 00319 StylesheetExecutionContext& theExecutionContext, 00320 bool supressDefault = false) const; 00321 00325 void 00326 clear(); 00327 00333 void 00334 swap(NamespacesHandler& theOther); 00335 00336 bool 00337 getProcessNamespaceAliaises() const 00338 { 00339 return m_processAliases; 00340 } 00341 00342 void 00343 setProcessNamespaceAliaises(bool fValue) 00344 { 00345 m_processAliases = fValue; 00346 } 00347 00348 NamespacesMapType::size_type 00349 getNamespaceDeclarationsCount() const 00350 { 00351 return m_namespaceDeclarations.size(); 00352 } 00353 00354 private: 00355 00359 void 00360 createResultAttributeNames(); 00361 00367 void 00368 processExcludeResultPrefixes(const XalanDOMString& theElementPrefix); 00369 00373 void 00374 processNamespaceAliases(); 00375 00381 void 00382 copyNamespaceAliases(const NamespaceAliasesMapType& theNamespaceAliases); 00383 00389 void 00390 copyExtensionNamespaceURIs(const ExtensionNamespaceURISetType& theExtensionNamespaceURIs); 00391 00397 void 00398 copyExcludeResultPrefixes(const ExcludedResultPrefixesMapType& theExcludeResultPrefixes); 00399 00409 bool 00410 shouldExcludeResultNamespaceNode( 00411 const XalanDOMString& theXSLTNamespaceURI, 00412 const NamespacesHandler& parentNamespacesHandler, 00413 const NameSpace& theNamespace) const; 00414 00422 bool 00423 isExcludedNamespaceURI(const XalanDOMString& theNamespaceURI) const; 00424 00425 // Not implemented... 00426 bool 00427 operator==(const NamespacesHandler&) const; 00428 00429 // Data members... 00430 ExcludedResultPrefixesMapType m_excludedResultPrefixes; 00431 00432 NamespacesMapType m_namespaceDeclarations; 00433 00434 ExtensionNamespaceURISetType m_extensionNamespaceURIs; 00435 00436 NamespaceAliasesMapType m_namespaceAliases; 00437 00438 ActivePrefixesSetType m_activePrefixes; 00439 00440 // If true namespace aliases will be processed. If false, they will not. 00441 bool m_processAliases; 00442 }; 00443 00444 00445 00446 #endif // XALAN_NAMESPACESHANDLER_HEADER_GUARD
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
![]() |
Xalan-C++ XSLT Processor Version 1.4 |
|