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(XPATHEVALUATOR_HEADER_GUARD_1357924680) 00019 #define XPATHEVALUATOR_HEADER_GUARD_1357924680 00020 00021 00022 00023 #include <xalanc/XPath/XPathDefinitions.hpp> 00024 00025 00026 00027 #if defined(XALAN_AUTO_PTR_REQUIRES_DEFINITION) 00028 #include <xalanc/XPath/XObjectFactory.hpp> 00029 #include <xalanc/XPath/XPathFactoryDefault.hpp> 00030 #include <xalanc/XPath/XPathConstructionContextDefault.hpp> 00031 #include <xalanc/XPath/XPathExecutionContextDefault.hpp> 00032 #endif 00033 00034 00035 00036 #include <xalanc/Include/XalanMemMgrAutoPtr.hpp> 00037 00038 00039 00040 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00041 00042 00043 00044 XALAN_CPP_NAMESPACE_BEGIN 00045 00046 00047 00048 #if !defined(XALAN_AUTO_PTR_REQUIRES_DEFINITION) 00049 class XObjectFactory; 00050 class XPathFactoryDefault; 00051 class XPathConstructionContextDefault; 00052 class XPathExecutionContextDefault; 00053 #endif 00054 00055 00056 00057 class DOMSupport; 00058 class NodeRefList; 00059 class PrefixResolver; 00060 class XalanNode; 00061 class XalanElement; 00062 class XObjectPtr; 00063 class XPath; 00064 class XPathEnvSupport; 00065 class XPathExecutionContext; 00066 00067 00068 00069 class XALAN_XPATH_EXPORT XPathEvaluator 00070 { 00071 public: 00072 00073 // Static initializer to be called before any instances are 00074 // created. The call is _not_ thread-safe, you must only call 00075 // it once, unless you have called terminate previously, and 00076 // you want to re-initialize the library. 00077 static void 00078 initialize(MemoryManager& theManager XALAN_DEFAULT_MEMMGR); 00079 00080 // Static terminator to be called after all instances 00081 // are destroyed. The call is _not_ thread-safe. Once 00082 // terminated, you can call initialize() again, to 00083 // re-initialize the library. 00084 static void 00085 terminate(); 00086 00087 00088 XPathEvaluator(MemoryManager& theManager XALAN_DEFAULT_MEMMGR); 00089 00090 ~XPathEvaluator(); 00091 00092 /** 00093 * Evaluate the supplied XPath expression, within the given context. If 00094 * the expression doesn't select a node, 0 is returned. If it selects 00095 * more than one node, only the first is returned. 00096 * 00097 * @param domSupport An instance of the corresponding DOMSupport-derived for the DOM implementation being used. 00098 * @param contextNode The source tree context node 00099 * @param xpathString The XPath expression to evaluate 00100 * @param namespaceNode A node to use for namespace prefix resolution. 00101 * @return A pointer to the node selected by the expression, if any. 00102 */ 00103 XalanNode* 00104 selectSingleNode( 00105 DOMSupport& domSupport, 00106 XalanNode* contextNode, 00107 const XalanDOMChar* xpathString, 00108 const XalanElement* namespaceNode = 0); 00109 00110 /** 00111 * Evaluate the supplied XPath expression, within the given context. If 00112 * the expression doesn't select a node, 0 is returned. If it selects 00113 * more than one node, only the first is returned. 00114 * 00115 * @param domSupport An instance of the corresponding DOMSupport-derived for the DOM implementation being used. 00116 * @param contextNode The source tree context node 00117 * @param xpathString The XPath expression to evaluate 00118 * @param prefixResolver A prefix resolver instance to use for namespace prefix resolution. 00119 * @return A pointer to the node selected by the expression, if any. 00120 */ 00121 XalanNode* 00122 selectSingleNode( 00123 DOMSupport& domSupport, 00124 XalanNode* contextNode, 00125 const XalanDOMChar* xpathString, 00126 const PrefixResolver& prefixResolver); 00127 00128 /** 00129 * Evaluate the supplied XPath, within the given context. If 00130 * the expression doesn't select a node, 0 is returned. If it selects 00131 * more than one node, only the first is returned. 00132 * 00133 * @param domSupport An instance of the corresponding DOMSupport-derived for the DOM implementation being used. 00134 * @param contextNode The source tree context node 00135 * @param xpath A reference to a compiled XPath expression. 00136 * @param namespaceNode A node to use for namespace prefix resolution. 00137 * @return A pointer to the node selected by the expression, if any. 00138 */ 00139 XalanNode* 00140 selectSingleNode( 00141 DOMSupport& domSupport, 00142 XalanNode* contextNode, 00143 const XPath& xpath, 00144 const XalanElement* namespaceNode = 0); 00145 00146 /** 00147 * Evaluate the supplied XPath, within the given context. If 00148 * the expression doesn't select a node, 0 is returned. If it selects 00149 * more than one node, only the first is returned. 00150 * 00151 * @param domSupport An instance of the corresponding DOMSupport-derived for the DOM implementation being used. 00152 * @param contextNode The source tree context node 00153 * @param xpath A reference to a compiled XPath expression. 00154 * @param prefixResolver A prefix resolver instance to use for namespace prefix resolution. 00155 * @return A pointer to the node selected by the expression, if any. 00156 */ 00157 XalanNode* 00158 selectSingleNode( 00159 DOMSupport& domSupport, 00160 XalanNode* contextNode, 00161 const XPath& xpath, 00162 const PrefixResolver& prefixResolver); 00163 00164 /** 00165 * Evaluate the supplied XPath expression, within the given context. If 00166 * the expression doesn't select a node, an empty list is returned. 00167 * 00168 * @param domSupport An instance of the corresponding DOMSupport-derived for the DOM implementation being used. 00169 * @param contextNode The source tree context node 00170 * @param xpathString The XPath expression to evaluate 00171 * @param namespaceNode A node to use for namespace prefix resolution. 00172 * @return A list of selected nodes. 00173 */ 00174 NodeRefList& 00175 selectNodeList( 00176 NodeRefList& result, 00177 DOMSupport& domSupport, 00178 XalanNode* contextNode, 00179 const XalanDOMChar* xpathString, 00180 const XalanElement* namespaceNode = 0); 00181 00182 /** 00183 * Evaluate the supplied XPath expression, within the given context. If 00184 * the expression doesn't select a node, an empty list is returned. 00185 * 00186 * @param domSupport An instance of the corresponding DOMSupport-derived for the DOM implementation being used. 00187 * @param contextNode The source tree context node 00188 * @param xpathString The XPath expression to evaluate 00189 * @param prefixResolver A prefix resolver instance to use for namespace prefix resolution. 00190 * @return A list of selected nodes. 00191 */ 00192 NodeRefList& 00193 selectNodeList( 00194 NodeRefList& result, 00195 DOMSupport& domSupport, 00196 XalanNode* contextNode, 00197 const XalanDOMChar* xpathString, 00198 const PrefixResolver& prefixResolver); 00199 00200 /** 00201 * Evaluate the supplied XPath, within the given context. If 00202 * the expression doesn't select a node, an empty list is returned. 00203 * 00204 * @param domSupport An instance of the corresponding DOMSupport-derived for the DOM implementation being used. 00205 * @param contextNode The source tree context node 00206 * @param xpath A reference to a compiled XPath expression. 00207 * @param namespaceNode A node to use for namespace prefix resolution. 00208 * @return A list of selected nodes. 00209 */ 00210 NodeRefList& 00211 selectNodeList( 00212 NodeRefList& result, 00213 DOMSupport& domSupport, 00214 XalanNode* contextNode, 00215 const XPath& xpath, 00216 const XalanElement* namespaceNode = 0); 00217 00218 /** 00219 * Evaluate the supplied XPath, within the given context. If 00220 * the expression doesn't select a node, an empty list is returned. 00221 * 00222 * @param domSupport An instance of the corresponding DOMSupport-derived for the DOM implementation being used. 00223 * @param contextNode The source tree context node 00224 * @param xpath A reference to a compiled XPath expression. 00225 * @param prefixResolver A prefix resolver instance to use for namespace prefix resolution. 00226 * @return A list of selected nodes. 00227 */ 00228 NodeRefList& 00229 selectNodeList( 00230 NodeRefList& result, 00231 DOMSupport& domSupport, 00232 XalanNode* contextNode, 00233 const XPath& xpath, 00234 const PrefixResolver& prefixResolver); 00235 00236 /** 00237 * Evaluate the supplied XPath expression, within the given context. The 00238 * result is returned as a generalized object. The object will be 00239 * destroyed when the user's copy of the returned XObjectPtr goes out of 00240 * scope, or when the XPathEvaluator goes out of scope or another expression 00241 * is evaluated. 00242 * 00243 * The user's XObjectPtr copy _must_ no longer be in scope when the XPathEvaluator 00244 * instance goes out of scope, or another expression is evaluated. 00245 * 00246 * @param domSupport An instance of the corresponding DOMSupport-derived for the DOM implementation being used. 00247 * @param contextNode The source tree context node 00248 * @param xpathString The XPath expression to evaluate 00249 * @param namespaceNode A node to use for namespace prefix resolution. 00250 * @return The result of evaluting the XPath expression. 00251 */ 00252 XObjectPtr 00253 evaluate( 00254 DOMSupport& domSupport, 00255 XalanNode* contextNode, 00256 const XalanDOMChar* xpathString, 00257 const XalanElement* namespaceNode = 0); 00258 00259 /** 00260 * Evaluate the supplied XPath expression, within the given context. The 00261 * result is returned as a generalized object. The object will be 00262 * destroyed when the user's copy of the returned XObjectPtr goes out of 00263 * scope, or when the XPathEvaluator goes out of scope or another expression 00264 * is evaluated. 00265 * 00266 * The user's XObjectPtr copy _must_ no longer be in scope when the XPathEvaluator 00267 * instance goes out of scope, or another expression is evaluated. 00268 * 00269 * @param domSupport An instance of the corresponding DOMSupport-derived for the DOM implementation being used. 00270 * @param contextNode The source tree context node 00271 * @param xpathString The XPath expression to evaluate 00272 * @param prefixResolver A prefix resolver instance to use for namespace prefix resolution. 00273 * @return The result of evaluting the XPath expression. 00274 */ 00275 XObjectPtr 00276 evaluate( 00277 DOMSupport& domSupport, 00278 XalanNode* contextNode, 00279 const XalanDOMChar* xpathString, 00280 const PrefixResolver& prefixResolver); 00281 00282 /** 00283 * Evaluate the supplied XPath expression, within the given context. The 00284 * result is returned as a generalized object. The object will be 00285 * destroyed when the user's copy of the returned XObjectPtr goes out of 00286 * scope, or when the XPathEvaluator goes out of scope or another expression 00287 * is evaluated. 00288 * 00289 * The user's XObjectPtr copy _must_ no longer be in scope when the XPathEvaluator 00290 * instance goes out of scope, or another expression is evaluated. 00291 * 00292 * @param domSupport An instance of the corresponding DOMSupport-derived for the DOM implementation being used. 00293 * @param contextNode The source tree context node 00294 * @param xpath A reference to a compiled XPath expression. 00295 * @param namespaceNode A node to use for namespace prefix resolution. 00296 * @return The result of evaluting the XPath expression. 00297 */ 00298 XObjectPtr 00299 evaluate( 00300 DOMSupport& domSupport, 00301 XalanNode* contextNode, 00302 const XPath& xpath, 00303 const XalanElement* namespaceNode = 0); 00304 00305 /** 00306 * Evaluate the supplied XPath expression, within the given context. The 00307 * result is returned as a generalized object. The object will be 00308 * destroyed when the user's copy of the returned XObjectPtr goes out of 00309 * scope, or when the XPathEvaluator goes out of scope or another expression 00310 * is evaluated. 00311 * 00312 * The user's XObjectPtr copy _must_ no longer be in scope when the XPathEvaluator 00313 * instance goes out of scope, or another expression is evaluated. 00314 * 00315 * @param domSupport An instance of the corresponding DOMSupport-derived for the DOM implementation being used. 00316 * @param contextNode The source tree context node 00317 * @param xpath A reference to a compiled XPath expression. 00318 * @param prefixResolver A prefix resolver instance to use for namespace prefix resolution. 00319 * @return The result of evaluting the XPath expression. 00320 */ 00321 XObjectPtr 00322 evaluate( 00323 DOMSupport& domSupport, 00324 XalanNode* contextNode, 00325 const XPath& xpath, 00326 const PrefixResolver& prefixResolver); 00327 00328 /** 00329 * Compile an XPath expression into an object which can be used multiple times. 00330 * Call destroyXPath() when finished with the instance. Otherwise, the object 00331 * will be destroyed when the XPathEvaluator instance goes out of scope. Since 00332 * no PrefixResolver is supplied, the XPath expression may not contain any 00333 * namespace prefixes. 00334 * 00335 * @param xpathString The XPath expression to evaluate 00336 * @return A pointer to an XPath instance. 00337 */ 00338 XPath* 00339 createXPath(const XalanDOMChar* xpathString); 00340 00341 /** 00342 * Compile an XPath expression into an object which can be used multiple times. 00343 * Call destroyXPath() when finished with the instance. Otherwise, the object 00344 * will be destroyed when the XPathEvaluator instance goes out of scope. 00345 * 00346 * @param xpathString The XPath expression to evaluate 00347 * @param domSupport An instance of the corresponding DOMSupport-derived for the DOM implementation being used. 00348 * @param namespaceNode A node to use for namespace prefix resolution. 00349 * @return A pointer to an XPath instance. 00350 */ 00351 XPath* 00352 createXPath( 00353 const XalanDOMChar* xpathString, 00354 DOMSupport& domSupport, 00355 const XalanElement* namespaceNode); 00356 00357 /** 00358 * Compile an XPath expression into an object which can be used multiple times. 00359 * Call destroyXPath() when finished with the instance. Otherwise, the object 00360 * will be destroyed when the XPathEvaluator instance goes out of scope. 00361 * 00362 * @param xpathString The XPath expression to evaluate 00363 * @param prefixResolver A prefix resolver instance to use for namespace prefix resolution. 00364 * @return A pointer to an XPath instance. 00365 */ 00366 XPath* 00367 createXPath( 00368 const XalanDOMChar* xpathString, 00369 const PrefixResolver& prefixResolver); 00370 00371 /** 00372 * Destory a compiled XPath instance. The instance must have 00373 * been created using createXPath(). 00374 * 00375 * @param theXPath The XPath instance to destroy 00376 * @return true if the instance was successfully destroyed 00377 */ 00378 bool 00379 destroyXPath(XPath* theXPath); 00380 00381 XPathExecutionContext& 00382 getExecutionContext(); 00383 00384 private: 00385 00386 /** 00387 * A helper function to evaluate the supplied XPath expression, within 00388 * the given context. 00389 * 00390 * @param domSupport An instance of the corresponding DOMSupport-derived for the DOM implementation being used. 00391 * @param contextNode The source tree context node 00392 * @param xpathString The XPath expression to evaluate 00393 * @param prefixResolver A prefix resolver instance to use for namespace prefix resolution. 00394 * @param envSupport The XPathEnvSupport instance to use. 00395 * @return The result of evaluting the XPath expression. 00396 */ 00397 XObjectPtr 00398 evaluate( 00399 DOMSupport& domSupport, 00400 XalanNode* contextNode, 00401 const XalanDOMChar* xpathString, 00402 const PrefixResolver& prefixResolver, 00403 XPathEnvSupport& envSupport); 00404 00405 /** 00406 * A helper function to evaluate the supplied XPath expression, within 00407 * the given context. 00408 * 00409 * @param domSupport An instance of the corresponding DOMSupport-derived for the DOM implementation being used. 00410 * @param contextNode The source tree context node 00411 * @param xpath The XPath to evaluate 00412 * @param prefixResolver A prefix resolver instance to use for namespace prefix resolution. 00413 * @param envSupport The XPathEnvSupport instance to use. 00414 * @return The result of evaluting the XPath expression. 00415 */ 00416 XObjectPtr 00417 evaluate( 00418 DOMSupport& domSupport, 00419 XalanNode* contextNode, 00420 const XPath& xpath, 00421 const PrefixResolver& prefixResolver, 00422 XPathEnvSupport& envSupport); 00423 00424 // Data members... 00425 const XalanMemMgrAutoPtr<XObjectFactory> m_xobjectFactory; 00426 00427 const XalanMemMgrAutoPtr<XPathFactoryDefault> m_xpathFactory; 00428 00429 const XalanMemMgrAutoPtr<XPathConstructionContextDefault> m_constructionContext; 00430 00431 const XalanMemMgrAutoPtr<XPathExecutionContextDefault> m_executionContext; 00432 00433 MemoryManager& m_memoryManager; 00434 }; 00435 00436 00437 00438 XALAN_CPP_NAMESPACE_END 00439 00440 00441 00442 #endif // XPATHEVALUATOR_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 |
|