MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlXPathCtxtCompile

Function xmlXPathCtxtCompile

ThirdParty/libxml2/vtklibxml2/xpath.c:13031–13103  ·  view source on GitHub ↗

* xmlXPathCtxtCompile: * @ctxt: an XPath context * @str: the XPath expression * * Compile an XPath expression * * Returns the xmlXPathCompExprPtr resulting from the compilation or NULL. * the caller has to free the object. */

Source from the content-addressed store, hash-verified

13029 * the caller has to free the object.
13030 */
13031xmlXPathCompExprPtr
13032xmlXPathCtxtCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
13033 xmlXPathParserContextPtr pctxt;
13034 xmlXPathContextPtr tmpctxt = NULL;
13035 xmlXPathCompExprPtr comp;
13036 int oldDepth = 0;
13037
13038#ifdef XPATH_STREAMING
13039 comp = xmlXPathTryStreamCompile(ctxt, str);
13040 if (comp != NULL)
13041 return(comp);
13042#endif
13043
13044 xmlInitParser();
13045
13046 /*
13047 * We need an xmlXPathContext for the depth check.
13048 */
13049 if (ctxt == NULL) {
13050 tmpctxt = xmlXPathNewContext(NULL);
13051 if (tmpctxt == NULL)
13052 return(NULL);
13053 ctxt = tmpctxt;
13054 }
13055
13056 pctxt = xmlXPathNewParserContext(str, ctxt);
13057 if (pctxt == NULL) {
13058 if (tmpctxt != NULL)
13059 xmlXPathFreeContext(tmpctxt);
13060 return NULL;
13061 }
13062
13063 oldDepth = ctxt->depth;
13064 xmlXPathCompileExpr(pctxt, 1);
13065 ctxt->depth = oldDepth;
13066
13067 if( pctxt->error != XPATH_EXPRESSION_OK )
13068 {
13069 xmlXPathFreeParserContext(pctxt);
13070 if (tmpctxt != NULL)
13071 xmlXPathFreeContext(tmpctxt);
13072 return(NULL);
13073 }
13074
13075 if (*pctxt->cur != 0) {
13076 /*
13077 * aleksey: in some cases this line prints *second* error message
13078 * (see bug #78858) and probably this should be fixed.
13079 * However, we are not sure that all error messages are printed
13080 * out in other places. It's not critical so we leave it as-is for now
13081 */
13082 xmlXPatherror(pctxt, __FILE__, __LINE__, XPATH_EXPR_ERROR);
13083 comp = NULL;
13084 } else {
13085 comp = pctxt->comp;
13086 if ((comp->nbStep > 1) && (comp->last >= 0)) {
13087 if (ctxt != NULL)
13088 oldDepth = ctxt->depth;

Callers 5

xmlXPathCompileFunction · 0.85
xmlSchematronAddTestFunction · 0.85
xmlSchematronParseRuleFunction · 0.85

Calls 10

xmlXPathTryStreamCompileFunction · 0.85
xmlInitParserFunction · 0.85
xmlXPathNewContextFunction · 0.85
xmlXPathNewParserContextFunction · 0.85
xmlXPathFreeContextFunction · 0.85
xmlXPathCompileExprFunction · 0.85
xmlXPatherrorFunction · 0.85
xmlStrdupFunction · 0.85

Tested by

no test coverage detected