[xml] XPath, document without a document element



Hi,

In xpath.c, line 3949 the macro CHECK_CONTEXT raises
an error if the given document has no document
element. I wonder if this should be handled as an error,
since the root node is the document node itself and an
XPath expression like "/foo" should simple return an empty
node-set.
If the error is OK, then a comparison for
doc->children == NULL needs an additional comparison for
XML_ELEMENT_NODE as well.

The macro:
#define CHECK_CONTEXT(ctxt)                                                \
    if ((ctxt == NULL) || (ctxt->doc == NULL) ||                        \
        (ctxt->doc->children == NULL)) {                                 \
xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_INVALID_CTXT); \ return(NULL); \
    }

Greetings,

Kasimier



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