I searched the archives for "xpath result" (unquoted) and didn't get any
useful hits so:

The SimpleXPathAPI example does this after establishing the context
node:

// OK, let's evaluate the expression...
const XObjectPtr        theResult(
                                theEvaluator.evaluate(
                                theDOMSupport,
                                theContextNode,
                                XalanDOMString(argv[3]).c_str(),
                                thePrefixResolver));

assert(theResult.null() == false);

cout << "The string value of the result is:"
         << endl
         << theResult->str()
         << endl
         << endl;

It would appear from this that the test for an unsuccessful XPath
evaluation is theResult.null() returning true.  However, if I evaluate
an XPath expression containing an element or attribute that is not in
the file, that test fails - .null() returns false - and after converting
the result to a regular C char string, it is empty, zero length.  If I
give the SimpleXPathAPI sample program an expression that will not
match, it prints "The string value of the result is ", indicating that
it too got a zero length result instead of null.  

The API docs for XPathEvaluator::evaluate() just say that it returns the
result of the search.  To find out exactly what that is, I dug through
the XPathEvaluator::evaluate() code as far as I could but I got lost in
all the cases in XPath::executeMore().  Searched the archive but didn't
find anything.

Q: which test should I use for an unsuccessful match, null or zero
length, or could I get both and they mean different things?

Thanks in advance,

-will

Reply via email to