[xml] error/warning messages related to context pointer



Hi,

 

I wrote a program which performs certain operations on an XML file (like reading attributes, setting their values, adding/deleting nodes etc) and in case of any modification, writes it back to the file. The node on which the operation is to be performed is specified using XPath. So before each such operation, I was using the API calls xmlParseFile() to create the DOM tree and xmlXPathNewContext() to create a new context. After the operation was done with, I was calling xmlSaveFormatFile(), xmlXPathFreeContext() and xmlFreeDoc() in that order to save the change to the XML file and to free the context and document handles. This was working fine but was slow because of the overhead of creating/freeing the handles before/after each operation.

 

To make it run faster, I changed my program to create the DOM tree and the context just once at the beginning, and free them at the end of the program (along with saving the DOM tree to the XML file). Throughout my program I use the handles for document and context created at the beginning for any operations performed on the tree. This seems to work (the outputs I got are correct so far), but throws some error/warning messages at the console. The messages are:

  1. ..\xpath.c:11683: XPath error : NULL context pointer
  2. I/O error : Permission denied
  3. I/O warning : failed to load external entity “%CD%CD…%CD%CD”

 

I looked at the source code and line #11683 in file xpath.c is the definition for the function xmlXPathEvalExpression(). Somehow it finds the context pointer to be NULL and shows message #1. I can’t understand how it’s NULL since my program does not modify the context pointer explicitly. I searched for the other two messages in the source files but could not locate them.

 

How can I get rid of these messages? Any help will be greatly appreciated.

 

Thank you.

 

Pinaki



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