libxml2 是否提供了 XPath 语法错误的描述 (XML_XPATH_EXPR_ERROR)

does libxml2 have available a description of XPath syntax error (XML_XPATH_EXPR_ERROR)

我正在我的代码中实现 LibXML2 XPath。

MSEXPORT int GetXpathXML(xmlDocPtr doc, xmlNodePtr node, xmlChar* xpathExpr, NodeRefsHdl NodeRefs)
{
#define ERR_OUT(x) {xmlXPathFreeObject(xpathObj); xmlXPathFreeContext(xpathCtx); return x;}
  if (doc == NULL) return(-1);

  /* Create xpath evaluation context */
  xmlXPathContextPtr xpathCtx = xmlXPathNewContext(doc);
  if(xpathCtx == NULL) return(-2);

  /* Evaluate xpath expression. */
  xmlXPathObjectPtr xpathObj = xmlXPathNodeEval((node == NULL ? xmlDocGetRootElement(doc): node), xpathExpr, xpathCtx);

  if(xpathObj == NULL) {
      snprintf(dan, BUFSZ, "Error %d: unable to evaluate xpath expression \"%s\"\n", (int) (xpathCtx->error), xpathExpr); DEBUG_MSG(dan);
      ERR_OUT(-3);
  }

当我故意发送这个错误的 XPath 时:

/*/*(1

(xpathCtx->error) 产生 0 而 xmlGetLastError() 产生我 XML_XPATH_EXPR_ERROR

但是 oXygen 给了我:

XPath failed due to: expected ")", found "<eof>"

我可以从 LibXML2 中检索更多 XPath 语法错误信息吗?

相关部分源码可以在xmlXPathCompPrimaryExpr:

中找到
    if (CUR != ')') {
        XP_ERROR(XPATH_EXPR_ERROR);
    }

所以答案是否定的。错误代码是 libxml2 的 XPath 表达式解析器提供的所有信息。