Xalan-C++ API Reference  1.12.0
XPathExecutionContextDefault.hpp
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 #if !defined(XPATHEXECUTIONCONTEXTDEFAULT_HEADER_GUARD_1357924680)
19 #define XPATHEXECUTIONCONTEXTDEFAULT_HEADER_GUARD_1357924680
20 
21 
22 
23 // Base include file. Must be first.
25 
26 
27 
30 
31 
32 
34 
35 
36 
37 // Base class include file.
39 
40 
41 
43 
44 
45 
48 
49 
50 
51 namespace XALAN_CPP_NAMESPACE {
52 
53 
54 
55 class DOMSupport;
56 class XPathEnvSupport;
57 class XalanQName;
58 
59 
60 
61 /**
62  * A basic implementation of the class XPathExecutionContext.
63  */
65 {
66 public:
67 
70 
71  /**
72  * Construct an XPathExecutionContextDefault object
73  *
74  * @param theXPathEnvSupport XPathEnvSupport class instance
75  * @param theDOMSupport DOMSupport class instance
76  * @param theXobjectFactory factory class instance for XObjects
77  * @param theCurrentNode current node in the source tree
78  * @param theContextNodeList node list for current context
79  * @param thePrefixResolver pointer to prefix resolver to use
80  */
82  XPathEnvSupport& theXPathEnvSupport,
83  DOMSupport& theDOMSupport,
84  XObjectFactory& theXObjectFactory,
85  XalanNode* theCurrentNode = 0,
86  const NodeRefListBase* theContextNodeList = 0,
87  const PrefixResolver* thePrefixResolver = 0);
88 
89  /**
90  * Construct an XPathExecutionContextDefault object
91  *
92  * @param theXPathEnvSupport XPathEnvSupport class instance
93  * @param theXObjectFactory factory class instance for XObjects
94  * @param theCurrentNode current node in the source tree
95  * @param theContextNodeList node list for current context
96  * @param thePrefixResolver pointer to prefix resolver to use
97  */
98  explicit
100  MemoryManager& theManager,
101  XalanNode* theCurrentNode = 0,
102  const NodeRefListBase* theContextNodeList = 0,
103  const PrefixResolver* thePrefixResolver = 0);
104 
107  MemoryManager& theManager,
108  XalanNode* theCurrentNode = 0,
109  const NodeRefListBase* theContextNodeList = 0,
110  const PrefixResolver* thePrefixResolver = 0);
111 
112  virtual
114 
115 
116  /**
117  * Get the XPathEnvSupport instance.
118  *
119  * @return a pointer to the instance.
120  */
123  {
124  return m_xpathEnvSupport;
125  }
126 
127  /**
128  * Set the XPathEnvSupport instance.
129  *
130  * @param theSupport a reference to the instance to use.
131  */
132  void
134  {
135  m_xpathEnvSupport = theSupport;
136  }
137 
138  /**
139  * Set the DOMSupport instance.
140  *
141  * @param theDOMSupport a reference to the instance to use.
142  */
143  void
144  setDOMSupport(DOMSupport* theDOMSupport)
145  {
146  m_domSupport = theDOMSupport;
147  }
148 
149  /**
150  * Set the XObjectFactory instance.
151  *
152  * @param theFactory a reference to the instance to use.
153  */
154  void
155  setXObjectFactory(XObjectFactory* theXObjectFactory)
156  {
157  m_xobjectFactory = theXObjectFactory;
158  }
159 
160  /**
161  * Get a reference to the scratch QNameByValue instance.
162  *
163  * @return A reference to a QNameByValue instance.
164  */
167  {
168  return m_scratchQName;
169  }
170 
171  virtual void doFormatNumber(
172  double number,
173  const XalanDOMString& pattern,
174  const XalanDecimalFormatSymbols* theDFS,
175  XalanDOMString& theResult,
176  const XalanNode* context = 0,
177  const Locator* locator = 0);
178 
179  // These interfaces are inherited from XPathExecutionContext...
180 
181  virtual void
182  reset();
183 
184  virtual XalanNode*
185  getCurrentNode() const;
186 
187  virtual void
188  pushCurrentNode(XalanNode* theCurrentNode);
189 
190  virtual void
192 
193  virtual bool
195  const XalanNode& node1,
196  const XalanNode& node2) const;
197 
198  virtual void
200 
201  virtual void
203 
204  virtual const NodeRefListBase&
206 
207  virtual size_type
209 
210  virtual size_type
211  getContextNodeListPosition(const XalanNode& contextNode) const;
212 
213  virtual bool
214  elementAvailable(const XalanQName& theQName) const;
215 
216  virtual bool
218  const XalanDOMString& theName,
219  const Locator* locator) const;
220 
221  virtual bool
222  functionAvailable(const XalanQName& theQName) const;
223 
224  virtual bool
226  const XalanDOMString& theName,
227  const Locator* locator) const;
228 
229  virtual const XObjectPtr
231  const XalanDOMString& theNamespace,
232  const XalanDOMString& functionName,
233  XalanNode* context,
234  const XObjectArgVectorType& argVec,
235  const Locator* locator);
236 
237  virtual XalanDocument*
239  MemoryManager& theManager,
240  const XalanDOMString& urlString,
241  const XalanDOMString& base,
242  ErrorHandler* theErrorHandler = 0) const;
243 
244  virtual MutableNodeRefList*
246 
247  virtual bool
249 
250  virtual MutableNodeRefList*
251  createMutableNodeRefList(MemoryManager& theManager) const;
252 
253  virtual XalanDOMString&
255 
256  virtual bool
258 
259  virtual void
261  XalanNode* context,
262  const XalanQName& qname,
263  const XalanDOMString& ref,
264  const Locator* locator,
265  MutableNodeRefList& nodelist);
266 
267  virtual void
269  XalanNode* context,
270  const XalanDOMString& name,
271  const XalanDOMString& ref,
272  const Locator* locator,
273  MutableNodeRefList& nodelist);
274 
275  virtual const XObjectPtr
277  const XalanQName& name,
278  const Locator* locator = 0);
279 
280  virtual const PrefixResolver*
282 
283  virtual void
284  setPrefixResolver(const PrefixResolver* thePrefixResolver);
285 
286  virtual const XalanDOMString*
287  getNamespaceForPrefix(const XalanDOMString& prefix) const;
288 
289  virtual const XalanDOMString&
290  findURIFromDoc(const XalanDocument* owner) const;
291 
292  virtual const XalanDOMString&
294  const XalanDOMString& theName,
295  const XalanDocument& theDocument) const;
296 
297  virtual XalanDocument*
298  getSourceDocument(const XalanDOMString& theURI) const;
299 
300  virtual void
302  const XalanDOMString& theURI,
303  XalanDocument* theDocument);
304 
305  virtual void formatNumber(
306  double number,
307  const XalanDOMString& pattern,
308  XalanDOMString& theResult,
309  const XalanNode* context = 0,
310  const Locator* locator = 0);
311 
312  virtual void formatNumber(
313  double number,
314  const XalanDOMString& pattern,
315  const XalanDOMString& dfsName,
316  XalanDOMString& theResult,
317  const XalanNode* context = 0,
318  const Locator* locator = 0);
319 
320 
321  // These interfaces are inherited from ExecutionContext...
322 
323  virtual void
325  eSource source,
326  eClassification classification,
327  const XalanDOMString& msg,
328  const Locator* locator,
329  const XalanNode* sourceNode);
330 
331  virtual void
333  eSource source,
334  eClassification classification,
335  const XalanDOMString& msg,
336  const XalanNode* sourceNode);
337 
338  virtual void
340  const XalanDOMString& msg,
341  const XalanNode* sourceNode = 0,
342  const Locator* locator = 0) const;
343 
344  virtual void
346  const XalanDOMString& msg,
347  const XalanNode* sourceNode = 0,
348  const Locator* locator = 0) const;
349 
350  virtual void
352  const XalanDOMString& msg,
353  const XalanNode* sourceNode = 0,
354  const Locator* locator = 0) const;
355 
356  virtual bool
358 
359 protected:
360 
361  typedef XalanObjectCache<
366 
367  enum { eNodeListCacheListSize = 50 };
368 
370  {
372  m_node(0),
373  m_index(0)
374  {
375  }
376 
377  void
379  {
380  if (m_node != 0)
381  {
382  m_node = 0;
383  }
384  }
385 
387 
389  };
390 
392 
394 
396 
398 
400 
402 
404 
406 
408 
410 
411  static const NodeRefList s_dummyList;
412 };
413 
414 
415 
416 }
417 
418 
419 
420 #endif // XPATHEXECUTIONCONTEXTDEFAULT_HEADER_GUARD_1357924680
#define XALAN_XPATH_EXPORT
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Local implementation of MutableNodeRefList.
Local implementation of NodeRefList.
Local implementation of NodeRefList.
Definition: NodeRefList.hpp:44
This class defines an interface for classes that resolve namespace prefixes to their URIs.
This class handles the creation of XObjects and manages their lifetime.
Class to hold XObjectPtr return types.
Definition: XObject.hpp:884
A basic implementation of the class XPathExecutionContext.
virtual size_type getContextNodeListLength() const
virtual void formatNumber(double number, const XalanDOMString &pattern, const XalanDOMString &dfsName, XalanDOMString &theResult, const XalanNode *context=0, const Locator *locator=0)
Formats a number according to the specified pattern.
virtual const XalanDOMString * getNamespaceForPrefix(const XalanDOMString &prefix) const
Retrieve the URI corresponding to a namespace prefix.
XalanQNameByValue & getScratchQName() const
Get a reference to the scratch QNameByValue instance.
virtual const XObjectPtr getVariable(const XalanQName &name, const Locator *locator=0)
Given a name, locate a variable in the current context, and return a pointer to the object.
virtual const PrefixResolver * getPrefixResolver() const
Retrieve the resolver for namespaces.
virtual const XalanDOMString & getUnparsedEntityURI(const XalanDOMString &theName, const XalanDocument &theDocument) const
The getUnparsedEntityURI function returns the URI of the unparsed entity with the specified name in t...
XPathExecutionContextDefault(MemoryManager &theManager, XalanNode *theCurrentNode=0, const NodeRefListBase *theContextNodeList=0, const PrefixResolver *thePrefixResolver=0)
Construct an XPathExecutionContextDefault object.
virtual MutableNodeRefList * createMutableNodeRefList(MemoryManager &theManager) const
Create a MutableNodeRefList with the appropriate context.
virtual bool isNodeAfter(const XalanNode &node1, const XalanNode &node2) const
Determine if a node is after another node, in document order.
virtual void doFormatNumber(double number, const XalanDOMString &pattern, const XalanDecimalFormatSymbols *theDFS, XalanDOMString &theResult, const XalanNode *context=0, const Locator *locator=0)
virtual void formatNumber(double number, const XalanDOMString &pattern, XalanDOMString &theResult, const XalanNode *context=0, const Locator *locator=0)
Formats a number according to the specified pattern.
virtual MutableNodeRefList * borrowMutableNodeRefList()
Borrow a cached MutableNodeRefList instance.
static XPathExecutionContextDefault * create(MemoryManager &theManager, XalanNode *theCurrentNode=0, const NodeRefListBase *theContextNodeList=0, const PrefixResolver *thePrefixResolver=0)
virtual XalanDocument * parseXML(MemoryManager &theManager, const XalanDOMString &urlString, const XalanDOMString &base, ErrorHandler *theErrorHandler=0) const
Provides support for XML parsing service.
virtual bool shouldStripSourceNode(const XalanText &node)
Determine if a text node should be stripped from the source tree, as if it weren't there.
virtual void getNodeSetByKey(XalanNode *context, const XalanDOMString &name, const XalanDOMString &ref, const Locator *locator, MutableNodeRefList &nodelist)
Given a valid element key, return the corresponding node list.
virtual bool elementAvailable(const XalanDOMString &theName, const Locator *locator) const
Determine if an external element is available by resolving a string to a QName.
virtual void getNodeSetByKey(XalanNode *context, const XalanQName &qname, const XalanDOMString &ref, const Locator *locator, MutableNodeRefList &nodelist)
Given a valid element key, return the corresponding node list.
virtual bool returnMutableNodeRefList(MutableNodeRefList *theList)
Return a previously borrowed MutableNodeRefList instance.
virtual XalanNode * getCurrentNode() const
Retrieve the node currently being executed.
XalanVector< const NodeRefListBase * > ContextNodeListStackType
virtual bool functionAvailable(const XalanDOMString &theName, const Locator *locator) const
Determine if a function is available.
virtual void setSourceDocument(const XalanDOMString &theURI, XalanDocument *theDocument)
Associate a document with a given URI.
virtual bool elementAvailable(const XalanQName &theQName) const
Determine if an external element is available.
virtual void problem(eSource source, eClassification classification, const XalanDOMString &msg, const Locator *locator, const XalanNode *sourceNode)
Function that is called when a problem event occurs.
virtual void popContextNodeList()
Pop the node list for current context.
XalanObjectCache< MutableNodeRefList, DefaultCacheCreateFunctorMemMgr< MutableNodeRefList >, DeleteFunctor< MutableNodeRefList >, ClearCacheResetFunctor< MutableNodeRefList > > NodeListCacheType
XPathEnvSupport * getXPathEnvSupport() const
Get the XPathEnvSupport instance.
virtual const XObjectPtr extFunction(const XalanDOMString &theNamespace, const XalanDOMString &functionName, XalanNode *context, const XObjectArgVectorType &argVec, const Locator *locator)
Handle an extension function.
virtual const NodeRefListBase & getContextNodeList() const
Get the node list for current context.
virtual void pushCurrentNode(XalanNode *theCurrentNode)
Change the node currently being executed.
void setXObjectFactory(XObjectFactory *theXObjectFactory)
Set the XObjectFactory instance.
virtual void error(const XalanDOMString &msg, const XalanNode *sourceNode=0, const Locator *locator=0) const
virtual void pushContextNodeList(const NodeRefListBase &theList)
Push the node list for current context.
virtual void popCurrentNode()
Reset the node currently being executed.
virtual size_type getContextNodeListPosition(const XalanNode &contextNode) const
void setXPathEnvSupport(XPathEnvSupport *theSupport)
Set the XPathEnvSupport instance.
virtual void problem(eSource source, eClassification classification, const XalanDOMString &msg, const XalanNode *sourceNode)
Function that is called when a problem event occurs.
virtual void reset()
Reset the instance.
virtual void setPrefixResolver(const PrefixResolver *thePrefixResolver)
Change the resolver for namespaces.
virtual void message(const XalanDOMString &msg, const XalanNode *sourceNode=0, const Locator *locator=0) const
XPathExecutionContextDefault(XPathEnvSupport &theXPathEnvSupport, DOMSupport &theDOMSupport, XObjectFactory &theXObjectFactory, XalanNode *theCurrentNode=0, const NodeRefListBase *theContextNodeList=0, const PrefixResolver *thePrefixResolver=0)
Construct an XPathExecutionContextDefault object.
virtual XalanDocument * getSourceDocument(const XalanDOMString &theURI) const
Get the document associated with the given URI.
virtual void warn(const XalanDOMString &msg, const XalanNode *sourceNode=0, const Locator *locator=0) const
virtual bool releaseCachedString(XalanDOMString &theString)
Return a cached string.
virtual bool functionAvailable(const XalanQName &theQName) const
Determine if a function is available.
virtual const XalanDOMString & findURIFromDoc(const XalanDocument *owner) const
Given a DOM Document, tell what URI was used to parse it.
void setDOMSupport(DOMSupport *theDOMSupport)
Set the DOMSupport instance.
virtual XalanDOMString & getCachedString()
Get a cached string for temporary use.
NodeRefListBase::size_type size_type
Class to represent a qualified name.
Definition: XalanQName.hpp:71
Functor to delete objects, used in STL iteration algorithms.
Definition: STLHelper.hpp:101