All,

I'm using Xalan-C++ to evaluate multiple xpath expressions on a single xml file. The 
first expression evaluates fine but the next call to the evaluate function causes my 
program to crash with the following message...

Assertion failed: m_referenceCount == 0, file 
xalan-c-src1_4_0\xml-xalan\c\src\PlatformSupport\XalanReferenceCountedObject.cpp, line 
80

Here's a code fragment

        expression = "//CityName";
        const XObjectPtr theResult1(theEvaluator.evaluate(theDOMSupport, 
theContextNode,
                XalanDOMString(expression.data()).c_str(), 
theDocument->getDocumentElement()));
                ...

        expression = "//CityName/@PostalCode";
        const XObjectPtr theResult2(theEvaluator.evaluate(theDOMSupport, 
theContextNode,
                XalanDOMString(expression.data()).c_str(), 
theDocument->getDocumentElement()));


Apparently some object is being destroyed while its refCount is not zero.  I'm 
assuming that it's the XObjectPtr. The documentation is somewhat confusing regarding 
how the return object from the XPathEvaluator::evaluate() is handled.

"The result is returned as a generalized object. The object will be destroyed when the 
returned when the user's copy of the returned XObjectPtr 
<http://xml.apache.org/xalan-c/apidocs/class_xobjectptr.html>  goes out of scope, or 
when the XPathEvaluator goes out of scope or another expression is evaluated."
Does this mean that theResult's destructor is called when I make the second call to 
evaluate()?
"The user's XObjectPtr <http://xml.apache.org/xalan-c/apidocs/class_xobjectptr.html>  
copy _must_ no longer be in scope when the XPathEvaluator instance goes out of scope, 
or another expression is evaluated." 
Does this mean that it's an error for theResult to remain in scope when I make the 
second call to evaluate()?

Can someone explain in a little more detail how this returned object is handled 
between successive calls to the evaluate function.  
Do I have to create a new pointer object for the return value of each evaluate()?
Why does this not work?

Thanks for the help...

Steve

Reply via email to