00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one 00003 * or more contributor license agreements. See the NOTICE file 00004 * distributed with this work for additional information 00005 * regarding copyright ownership. The ASF licenses this file 00006 * to you under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 #if !defined(XALANDOCUMENTPREFIXRESOLVER_HEADER_GUARD_1357924680) 00019 #define XALANDOCUMENTPREFIXRESOLVER_HEADER_GUARD_1357924680 00020 00021 00022 00023 // Base include file. Must be first. 00024 #include <xalanc/DOMSupport/DOMSupportDefinitions.hpp> 00025 00026 00027 00028 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00029 00030 00031 00032 #include <xalanc/PlatformSupport/PrefixResolver.hpp> 00033 #include <xalanc/PlatformSupport/DOMStringHelper.hpp> 00034 00035 00036 00037 #include <xalanc/Include/XalanVector.hpp> 00038 #include <xalanc/Include/XalanMap.hpp> 00039 #include <xalanc/Include/STLHelper.hpp> 00040 00041 00042 00043 #include <xalanc/DOMSupport/TreeWalker.hpp> 00044 00045 00046 00047 XALAN_CPP_NAMESPACE_BEGIN 00048 00049 00050 00051 00052 00053 class XalanAttr; 00054 class XalanDocument; 00055 00056 typedef XalanVector<const XalanNode*> AttributeVectorTypeDecl; 00057 XALAN_USES_MEMORY_MANAGER(AttributeVectorTypeDecl) 00058 00059 00060 class XALAN_DOMSUPPORT_EXPORT XalanDocumentPrefixResolver : public PrefixResolver 00061 { 00062 public: 00063 00064 typedef AttributeVectorTypeDecl AttributeVectorType; 00065 typedef XalanMap<const XalanDOMString*, 00066 AttributeVectorType> NamespacesMapType; 00067 00068 /** 00069 * Constructor. 00070 * 00071 * @param theDocument The XalanDocument instance to use for namespace bindings. 00072 * @param theURI The base URI for the instance. This is rarely needed, but can be provided if the URI for the XalanDocument instance is known. 00073 */ 00074 XalanDocumentPrefixResolver( 00075 const XalanDocument* theDocument, 00076 const XalanDOMString& theURI = XalanDOMString(XalanMemMgrs::getDummyMemMgr()), 00077 MemoryManager& theManager XALAN_DEFAULT_MEMMGR); 00078 00079 virtual 00080 ~XalanDocumentPrefixResolver(); 00081 00082 00083 virtual const XalanDOMString* 00084 getNamespaceForPrefix(const XalanDOMString& prefix) const; 00085 00086 virtual const XalanDOMString& 00087 getURI() const; 00088 00089 /** 00090 * A utility class to walk the XalanDocument instance and look for attribute nodes that declare namespaces. 00091 */ 00092 class NamespaceNodesTreeWalker : public TreeWalker 00093 { 00094 public: 00095 00096 NamespaceNodesTreeWalker(NamespacesMapType& theMap); 00097 00098 virtual 00099 ~NamespaceNodesTreeWalker(); 00100 00101 protected: 00102 00103 virtual bool 00104 startNode(const XalanNode* node); 00105 00106 virtual bool 00107 startNode(XalanNode* node); 00108 00109 virtual bool 00110 endNode(const XalanNode* node); 00111 00112 virtual bool 00113 endNode(XalanNode* node); 00114 00115 private: 00116 00117 NamespacesMapType& m_map; 00118 }; 00119 00120 00121 protected: 00122 00123 /** 00124 * This function is called when more than one binding exists for a given prefix. 00125 * The default behavior uses the first binding, but a deriving class can change 00126 * that behavior by overriding. 00127 * 00128 * @param theVector The vector associated with the namespace prefix. 00129 * @return A pointer to a const XalanDOMString containing the desired binding, or NULL. 00130 */ 00131 virtual const XalanDOMString* 00132 duplicateBinding(const AttributeVectorType& theVector) const; 00133 00134 private: 00135 00136 NamespacesMapType m_namespaces; 00137 00138 const XalanDOMString m_uri; 00139 }; 00140 00141 00142 00143 XALAN_CPP_NAMESPACE_END 00144 00145 00146 00147 #endif // XALANDOCUMENTPREFIXRESOLVER_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.11 |
|