David Bertoni wrote:
> 
>> 1. Can I use an XPath after its XPathConstructionContext is deleted? if
>> not,
>> can i use one global XPathConstructionContext to construct all my XPath
>> objects?
> 
> No.  You can use a global XPathConstructionContext, but you will need to 
> serialize access to it if you are using multiple threads. 
> 
So I reckon I can have a global XPathConstructionContext and a global
XPathProcessorImpl, and protect initXPath() with a mutex; destroy the XPaths
only in the end.


David Bertoni wrote:
> 
> 
>  
>> 2. What is the difference between XPathProcessor::initXPath and
>> XPathProcessor::initMatchPattern ?
> One creates an XPath instance from an XPath expression, and the other 
> creates an XPath instance from a match pattern, which is a limited 
> subset of XPath.
> 
Thanks. I'll use initXPath(), then.


David Bertoni wrote:
> 
>> 3. Why does XPathEvaluator::evaluate calls reset() for its
>> executionContext
>> and XObjectFactory, and why does it sets the executionContext's
>> EnvSupport,
>> DOMSupport and XObjectFactory? What happens if I set it only once? 
>> (assuming there is one evaluator for each input document)
> 
> It resets these for various reasons:
> 
> 1. It resets the XPathExecutionContext and the XPathEnvSupport instance 
> because it doesn't make sense for state from one evaluation to leak into 
> another one.
> 

Makes sense.


David Bertoni wrote:
> 
> 
> 2. It resets the XObjectFactory to prevent a large number of XObject 
> instances from accumulating.  You can certainly change this if you want 
> to.  For example, you might want to reset only after a certain number of 
> XPath expressions have been evaluated.  This would mean you could keep a 
> number of evaluation results around between evaluations.  The current 
> model forces the user to copy the result of the evaluation before 
> evaluating another expression.
> 
> 
Let me rephrase to make sure I understand:
XObjectFactory is one-per-thread, and when I reset it, it deletes all the
XObject instances it had created. If I want to keep the instance after the
reset, i need to copy it (using copy constructor, i presume) and keep it in
another place.

I guess I can use two factories: one for temporary results (which I reset
frequently) and one for the results I need to keep.



David Bertoni wrote:
> 
> 
> Dave
> 
> 

Thank you.
-- 
View this message in context: 
http://www.nabble.com/Questions-about-XPATH-API-tp22303292p22323531.html
Sent from the Xalan - C - Users mailing list archive at Nabble.com.

Reply via email to