[xml] XPath/Document concurrency issue

Hi everybody,

I have a strange problem which I can only describe as a concurrency issue between the (xml) document content and the results I get from XPath queries. I'm working on a project where I plan to use the Model/Controller/View architecture, the model being a parsed xml tree and read/write access to it is mainly done via XPath queries. Therefore I'm quite worried by this issue.

Here's what I do:

- Read xml document
- Create an XPath context (xmlXPathNewContext)
- Run a query (xmlXPathEvalExpression), getting a result node
- Create a new node (xmlNewNode), set content (xmlEncodeSpecialChars, xmlNodeSetContent)
- Add new node as child to the result node (xmlAddChild)

- Create an XPath context (xmlXPathNewContext) with the same document
- Run a query (xmlXPathEvalExpression) which checks for the content of the node added above in a predicate.
- Get no result.

The curious thing is (and the reason why I bring it here rather than think it's an issue of the c++ wrapper around libxml2 I wrote) that after I save the document to disk and reload it, everything works as expected. The constructed XPath queries are identical before and after the save/reload, so I also don't think it's an issue elsewhere in my code.

I sincerely hope someone can help me with this issue as working around it could get awkward as the complexity of my application grows.


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