Re: [xml] XPath queries on document fragments without a document

while tracing a problem with XPath queries and document fragments
I found that it is not possible to XPath query an document
fragment, that is parsed by xmlParseBalancedChunkMemory(). this
means the fragment does not belong to a document tree ( node->doc
== NULL ).

now a xpath query run through xmlXPathCompiledEval() on such a
fragment will allways returns nothing. apart from i think it's
anoying ;) i wonder if there is a reason to refuse such queries.
[...]  my question is now: is there a reason to refuse xpath
queries on document fragments?

  yes, the XPath semantic is not defined. For example what does "/"
XPath evaluation should return ???  And an awful lot of XPath
queries use / , /foo or //foo to start a lookup, no really, having
element without a document breaks an awful lot of things in the XML
infrastructure, each time I suggest not to do it, people do it
anyway and have troubles, big surprise ...

Return NULL on all queries that start with / and node->doc == NULL?  -sc

Sean Chittenden

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