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(XPATHEXECUTIONCONTEXTDEFAULT_HEADER_GUARD_1357924680) 00019 #define XPATHEXECUTIONCONTEXTDEFAULT_HEADER_GUARD_1357924680 00020 00021 00022 00023 // Base include file. Must be first. 00024 #include <xalanc/XPath/XPathDefinitions.hpp> 00025 00026 00027 00028 #include <xalanc/Include/XalanObjectCache.hpp> 00029 #include <xalanc/Include/XalanVector.hpp> 00030 00031 00032 00033 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00034 00035 00036 00037 // Base class include file. 00038 #include <xalanc/XPath/XPathExecutionContext.hpp> 00039 00040 00041 00042 #include <xalanc/PlatformSupport/XalanDOMStringCache.hpp> 00043 00044 00045 00046 #include <xalanc/XPath/MutableNodeRefList.hpp> 00047 #include <xalanc/XPath/XalanQNameByValue.hpp> 00048 00049 00050 00051 XALAN_CPP_NAMESPACE_BEGIN 00052 00053 00054 00055 class DOMSupport; 00056 class XPathEnvSupport; 00057 class XalanQName; 00058 00059 00060 00061 /** 00062 * A basic implementation of the class XPathExecutionContext. 00063 */ 00064 class XALAN_XPATH_EXPORT XPathExecutionContextDefault : public XPathExecutionContext 00065 { 00066 public: 00067 00068 typedef XalanVector<XalanNode*> CurrentNodeStackType; 00069 typedef XalanVector<const NodeRefListBase*> ContextNodeListStackType; 00070 00071 /** 00072 * Construct an XPathExecutionContextDefault object 00073 * 00074 * @param theXPathEnvSupport XPathEnvSupport class instance 00075 * @param theDOMSupport DOMSupport class instance 00076 * @param theXobjectFactory factory class instance for XObjects 00077 * @param theCurrentNode current node in the source tree 00078 * @param theContextNodeList node list for current context 00079 * @param thePrefixResolver pointer to prefix resolver to use 00080 */ 00081 XPathExecutionContextDefault( 00082 XPathEnvSupport& theXPathEnvSupport, 00083 DOMSupport& theDOMSupport, 00084 XObjectFactory& theXObjectFactory, 00085 XalanNode* theCurrentNode = 0, 00086 const NodeRefListBase* theContextNodeList = 0, 00087 const PrefixResolver* thePrefixResolver = 0); 00088 00089 /** 00090 * Construct an XPathExecutionContextDefault object 00091 * 00092 * @param theXPathEnvSupport XPathEnvSupport class instance 00093 * @param theXObjectFactory factory class instance for XObjects 00094 * @param theCurrentNode current node in the source tree 00095 * @param theContextNodeList node list for current context 00096 * @param thePrefixResolver pointer to prefix resolver to use 00097 */ 00098 explicit 00099 XPathExecutionContextDefault( 00100 MemoryManager& theManager, 00101 XalanNode* theCurrentNode = 0, 00102 const NodeRefListBase* theContextNodeList = 0, 00103 const PrefixResolver* thePrefixResolver = 0); 00104 00105 static XPathExecutionContextDefault* 00106 create( 00107 MemoryManager& theManager, 00108 XalanNode* theCurrentNode = 0, 00109 const NodeRefListBase* theContextNodeList = 0, 00110 const PrefixResolver* thePrefixResolver = 0); 00111 00112 virtual 00113 ~XPathExecutionContextDefault(); 00114 00115 00116 /** 00117 * Get the XPathEnvSupport instance. 00118 * 00119 * @return a pointer to the instance. 00120 */ 00121 XPathEnvSupport* 00122 getXPathEnvSupport() const 00123 { 00124 return m_xpathEnvSupport; 00125 } 00126 00127 /** 00128 * Set the XPathEnvSupport instance. 00129 * 00130 * @param theSupport a reference to the instance to use. 00131 */ 00132 void 00133 setXPathEnvSupport(XPathEnvSupport* theSupport) 00134 { 00135 m_xpathEnvSupport = theSupport; 00136 } 00137 00138 /** 00139 * Set the DOMSupport instance. 00140 * 00141 * @param theDOMSupport a reference to the instance to use. 00142 */ 00143 void 00144 setDOMSupport(DOMSupport* theDOMSupport) 00145 { 00146 m_domSupport = theDOMSupport; 00147 } 00148 00149 /** 00150 * Set the XObjectFactory instance. 00151 * 00152 * @param theFactory a reference to the instance to use. 00153 */ 00154 void 00155 setXObjectFactory(XObjectFactory* theXObjectFactory) 00156 { 00157 m_xobjectFactory = theXObjectFactory; 00158 } 00159 00160 /** 00161 * Get a reference to the scratch QNameByValue instance. 00162 * 00163 * @return A reference to a QNameByValue instance. 00164 */ 00165 XalanQNameByValue& 00166 getScratchQName() const 00167 { 00168 return m_scratchQName; 00169 } 00170 00171 virtual void doFormatNumber( 00172 double number, 00173 const XalanDOMString& pattern, 00174 const XalanDecimalFormatSymbols* theDFS, 00175 XalanDOMString& theResult, 00176 const XalanNode* context = 0, 00177 const Locator* locator = 0); 00178 00179 // These interfaces are inherited from XPathExecutionContext... 00180 00181 virtual void 00182 reset(); 00183 00184 virtual XalanNode* 00185 getCurrentNode() const; 00186 00187 virtual void 00188 pushCurrentNode(XalanNode* theCurrentNode); 00189 00190 virtual void 00191 popCurrentNode(); 00192 00193 virtual bool 00194 isNodeAfter( 00195 const XalanNode& node1, 00196 const XalanNode& node2) const; 00197 00198 virtual void 00199 pushContextNodeList(const NodeRefListBase& theList); 00200 00201 virtual void 00202 popContextNodeList(); 00203 00204 virtual const NodeRefListBase& 00205 getContextNodeList() const; 00206 00207 virtual size_type 00208 getContextNodeListLength() const; 00209 00210 virtual size_type 00211 getContextNodeListPosition(const XalanNode& contextNode) const; 00212 00213 virtual bool 00214 elementAvailable(const XalanQName& theQName) const; 00215 00216 virtual bool 00217 elementAvailable( 00218 const XalanDOMString& theName, 00219 const Locator* locator) const; 00220 00221 virtual bool 00222 functionAvailable(const XalanQName& theQName) const; 00223 00224 virtual bool 00225 functionAvailable( 00226 const XalanDOMString& theName, 00227 const Locator* locator) const; 00228 00229 virtual const XObjectPtr 00230 extFunction( 00231 const XalanDOMString& theNamespace, 00232 const XalanDOMString& functionName, 00233 XalanNode* context, 00234 const XObjectArgVectorType& argVec, 00235 const Locator* locator); 00236 00237 virtual XalanDocument* 00238 parseXML( 00239 MemoryManager& theManager, 00240 const XalanDOMString& urlString, 00241 const XalanDOMString& base, 00242 ErrorHandler* theErrorHandler = 0) const; 00243 00244 virtual MutableNodeRefList* 00245 borrowMutableNodeRefList(); 00246 00247 virtual bool 00248 returnMutableNodeRefList(MutableNodeRefList* theList); 00249 00250 virtual MutableNodeRefList* 00251 createMutableNodeRefList(MemoryManager& theManager) const; 00252 00253 virtual XalanDOMString& 00254 getCachedString(); 00255 00256 virtual bool 00257 releaseCachedString(XalanDOMString& theString); 00258 00259 virtual void 00260 getNodeSetByKey( 00261 XalanNode* context, 00262 const XalanQName& qname, 00263 const XalanDOMString& ref, 00264 const Locator* locator, 00265 MutableNodeRefList& nodelist); 00266 00267 virtual void 00268 getNodeSetByKey( 00269 XalanNode* context, 00270 const XalanDOMString& name, 00271 const XalanDOMString& ref, 00272 const Locator* locator, 00273 MutableNodeRefList& nodelist); 00274 00275 virtual const XObjectPtr 00276 getVariable( 00277 const XalanQName& name, 00278 const Locator* locator = 0); 00279 00280 virtual const PrefixResolver* 00281 getPrefixResolver() const; 00282 00283 virtual void 00284 setPrefixResolver(const PrefixResolver* thePrefixResolver); 00285 00286 virtual const XalanDOMString* 00287 getNamespaceForPrefix(const XalanDOMString& prefix) const; 00288 00289 virtual const XalanDOMString& 00290 findURIFromDoc(const XalanDocument* owner) const; 00291 00292 virtual const XalanDOMString& 00293 getUnparsedEntityURI( 00294 const XalanDOMString& theName, 00295 const XalanDocument& theDocument) const; 00296 00297 virtual XalanDocument* 00298 getSourceDocument(const XalanDOMString& theURI) const; 00299 00300 virtual void 00301 setSourceDocument( 00302 const XalanDOMString& theURI, 00303 XalanDocument* theDocument); 00304 00305 virtual void formatNumber( 00306 double number, 00307 const XalanDOMString& pattern, 00308 XalanDOMString& theResult, 00309 const XalanNode* context = 0, 00310 const Locator* locator = 0); 00311 00312 virtual void formatNumber( 00313 double number, 00314 const XalanDOMString& pattern, 00315 const XalanDOMString& dfsName, 00316 XalanDOMString& theResult, 00317 const XalanNode* context = 0, 00318 const Locator* locator = 0); 00319 00320 00321 // These interfaces are inherited from ExecutionContext... 00322 00323 virtual void 00324 problem( 00325 eSource source, 00326 eClassification classification, 00327 const XalanDOMString& msg, 00328 const Locator* locator, 00329 const XalanNode* sourceNode); 00330 00331 virtual void 00332 problem( 00333 eSource source, 00334 eClassification classification, 00335 const XalanDOMString& msg, 00336 const XalanNode* sourceNode); 00337 00338 virtual void 00339 error( 00340 const XalanDOMString& msg, 00341 const XalanNode* sourceNode = 0, 00342 const Locator* locator = 0) const; 00343 00344 virtual void 00345 warn( 00346 const XalanDOMString& msg, 00347 const XalanNode* sourceNode = 0, 00348 const Locator* locator = 0) const; 00349 00350 virtual void 00351 message( 00352 const XalanDOMString& msg, 00353 const XalanNode* sourceNode = 0, 00354 const Locator* locator = 0) const; 00355 00356 virtual bool 00357 shouldStripSourceNode(const XalanText& node); 00358 00359 protected: 00360 00361 typedef XalanObjectCache< 00362 MutableNodeRefList, 00363 DefaultCacheCreateFunctorMemMgr<MutableNodeRefList>, 00364 DeleteFunctor<MutableNodeRefList>, 00365 ClearCacheResetFunctor<MutableNodeRefList> > NodeListCacheType; 00366 00367 enum { eNodeListCacheListSize = 50 }; 00368 00369 struct ContextNodeListPositionCache 00370 { 00371 ContextNodeListPositionCache() : 00372 m_node(0), 00373 m_index(0) 00374 { 00375 } 00376 00377 void 00378 clear() 00379 { 00380 if (m_node != 0) 00381 { 00382 m_node = 0; 00383 } 00384 } 00385 00386 const XalanNode* m_node; 00387 00388 size_type m_index; 00389 }; 00390 00391 XPathEnvSupport* m_xpathEnvSupport; 00392 00393 DOMSupport* m_domSupport; 00394 00395 CurrentNodeStackType m_currentNodeStack; 00396 00397 ContextNodeListStackType m_contextNodeListStack; 00398 00399 const PrefixResolver* m_prefixResolver; 00400 00401 XalanDOMString m_currentPattern; 00402 00403 NodeListCacheType m_nodeListCache; 00404 00405 XalanDOMStringCache m_stringCache; 00406 00407 mutable ContextNodeListPositionCache m_cachedPosition; 00408 00409 mutable XalanQNameByValue m_scratchQName; 00410 00411 static const NodeRefList s_dummyList; 00412 }; 00413 00414 00415 00416 XALAN_CPP_NAMESPACE_END 00417 00418 00419 00420 #endif // XPATHEXECUTIONCONTEXTDEFAULT_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 |
|