Dave, Thanks for clearing that up for me. I suspected that what I should have been doing was to release the XObjectPtr before my next call to evaluate(). I was looking for a release() function on the pointer object but couldn't find one. I guess that 's what lead to my confusion.
Thanks again... Steve -----Original Message----- From: David N Bertoni/Cambridge/IBM [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 22, 2003 6:51 PM To: [EMAIL PROTECTED] Subject: Re: XPathEvaluator question Hi Steve, I guess the documentation could be more explicit about this, but what it's trying to say is you must copy any information out of the XObject instance _before_ one of the following happens: 1. You make another call to any one of the member functions of the XPathEvaluator instance. 2. The XPathEvaluator instance goes out of scope. So you are correct in your guesses, and you must either plan your code so any result is no longer in scope, or you release the XObject instance by assigning a "null" XObjectPtr instance: theResult1 = XObjectPtr(); This protocol may seem strange, but it was done that way to make sure the entire execution environment is reset for the next evaluation. We could lift the first restriction, if you think it's that onerous. We can't lift the second one... Dave "Oliver, Steve" <Steve.Oliver@bestw To: "Xalan Dev" <[EMAIL PROTECTED]> estern.com> cc: (bcc: David N Bertoni/Cambridge/IBM) Subject: XPathEvaluator question 01/22/2003 05:22 PM Please respond to xalan-dev 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
