| 2083 | } |
| 2084 | |
| 2085 | static void doXPathQuery(xmlDocPtr doc, const char *query) { |
| 2086 | xmlXPathContextPtr ctxt; |
| 2087 | xmlXPathObjectPtr res; |
| 2088 | |
| 2089 | ctxt = xmlXPathNewContext(doc); |
| 2090 | if (ctxt == NULL) { |
| 2091 | fprintf(ERR_STREAM, "Out of memory for XPath\n"); |
| 2092 | progresult = XMLLINT_ERR_MEM; |
| 2093 | return; |
| 2094 | } |
| 2095 | ctxt->node = (xmlNodePtr) doc; |
| 2096 | res = xmlXPathEval(BAD_CAST query, ctxt); |
| 2097 | xmlXPathFreeContext(ctxt); |
| 2098 | |
| 2099 | if (res == NULL) { |
| 2100 | fprintf(ERR_STREAM, "XPath evaluation failure\n"); |
| 2101 | progresult = XMLLINT_ERR_XPATH; |
| 2102 | return; |
| 2103 | } |
| 2104 | doXPathDump(res); |
| 2105 | xmlXPathFreeObject(res); |
| 2106 | } |
| 2107 | #endif /* LIBXML_XPATH_ENABLED */ |
| 2108 | |
| 2109 | /************************************************************************ |
no test coverage detected