[xml] xmlXPathEval(*str,*ctxt)



It seems that in a document like:

<?xml version="1.0"?>
<xmlsysd>
  <proc>
  </proc>
</xmlsysd>

rgb lucifer|T:443>./testXPath -i xmlsysd.xml /xmlsysd/proc/uptime
Object is a Node Set :
Set contains 0 nodes:
rgb lucifer|T:444>./testXPath -i xmlsysd.xml /xmlsysd/proc/uptime/up
Object is a Node Set :
NodeSet is NULL !
rgb lucifer|T:457>./testXPath -i xmlsysd.xml /xmlsysd/proc
Object is a Node Set :
Set contains 1 nodes:
1  ELEMENT proc

In my own code the following fragment (either way -- one step or with a
segment copied from textXPath.c) does NOT return null in the second case
although the node obviously does not exist.  Is this not a bug?  Do I
have to test all segments of a path to a node?

In any event for my parsing code to be robust I need to be able to test
and avoid the segment violation that occurs afterwards for nonexistent
paths that pass the NULL test below:

 /* xp_op = my_xmlXPathEval(xpath, xp_doc); */
 /* res = xmlXPathEval(BAD_CAST str, ctxt); */

 comp = xmlXPathCompile(BAD_CAST xpath);
 if (comp != NULL) {
   xp_op = xmlXPathCompiledEval(comp, xp_doc);
   xmlXPathFreeCompExpr(comp);
 } else
   xp_op = NULL;
 xmlXPathDebugDumpObject(stdout, xp_op, 0);
 /* no such path in xp_doc */
 if( xp_op != NULL ) {
   printf("This non-NULL xp_op has %d nodes.\n",xp_op->nodesetval->nodeNr);
 }

Thanks,

   rgb

-- 
Robert G. Brown                        http://www.phy.duke.edu/~rgb/
Duke University Dept. of Physics, Box 90305
Durham, N.C. 27708-0305
Phone: 1-919-660-2567  Fax: 919-660-2525     email:rgb phy duke edu






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]