mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
Add support for xpathRegisterVariable in Python
This commit is contained in:
committed by
Daniel Veillard
parent
483272f3f0
commit
519bc6a3ab
@ -2329,6 +2329,32 @@ libxml_xmlRegisterXPathFunction(ATTRIBUTE_UNUSED PyObject * self,
|
|||||||
return (py_retval);
|
return (py_retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PyObject *
|
||||||
|
libxml_xmlXPathRegisterVariable(ATTRIBUTE_UNUSED PyObject * self,
|
||||||
|
PyObject * args)
|
||||||
|
{
|
||||||
|
PyObject *py_retval;
|
||||||
|
int c_retval = 0;
|
||||||
|
xmlChar *name;
|
||||||
|
xmlChar *ns_uri;
|
||||||
|
xmlXPathContextPtr ctx;
|
||||||
|
xmlXPathObjectPtr val;
|
||||||
|
PyObject *pyobj_ctx;
|
||||||
|
PyObject *pyobj_value;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple
|
||||||
|
(args, (char *) "OszO:xpathRegisterVariable", &pyobj_ctx, &name,
|
||||||
|
&ns_uri, &pyobj_value))
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
ctx = (xmlXPathContextPtr) PyxmlXPathContext_Get(pyobj_ctx);
|
||||||
|
val = libxml_xmlXPathObjectPtrConvert(pyobj_value);
|
||||||
|
|
||||||
|
c_retval = xmlXPathRegisterVariableNS(ctx, name, ns_uri, val);
|
||||||
|
py_retval = libxml_intWrap(c_retval);
|
||||||
|
return (py_retval);
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
* Global properties access *
|
* Global properties access *
|
||||||
|
@ -10,6 +10,15 @@
|
|||||||
<arg name='ns_uri' type='xmlChar *' info='the namespace or NULL'/>
|
<arg name='ns_uri' type='xmlChar *' info='the namespace or NULL'/>
|
||||||
<arg name='f' type='pythonObject' info='the python function'/>
|
<arg name='f' type='pythonObject' info='the python function'/>
|
||||||
</function>
|
</function>
|
||||||
|
<function name='xmlXPathRegisterVariable' file='python'>
|
||||||
|
<cond>defined(LIBXML_XPATH_ENABLED)</cond>
|
||||||
|
<info>Register a variable with the XPath context</info>
|
||||||
|
<return type='int' info="1 in case of success, 0 or -1 in case of error"/>
|
||||||
|
<arg name='ctx' type='xmlXPathContextPtr' info='the xpathContext'/>
|
||||||
|
<arg name='name' type='xmlChar *' info='the variable name'/>
|
||||||
|
<arg name='ns_uri' type='xmlChar *' info='the namespace or NULL'/>
|
||||||
|
<arg name='value' type='pythonObject' info='the value'/>
|
||||||
|
</function>
|
||||||
<function name='xmlNewNode' file='python'>
|
<function name='xmlNewNode' file='python'>
|
||||||
<info>Create a new Node</info>
|
<info>Create a new Node</info>
|
||||||
<return type='xmlNodePtr' info="A new element node"/>
|
<return type='xmlNodePtr' info="A new element node"/>
|
||||||
|
@ -622,7 +622,6 @@ libxml_xmlXPathObjectPtrConvert(PyObject * obj)
|
|||||||
printf("Unable to convert Python Object to XPath");
|
printf("Unable to convert Python Object to XPath");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
Py_DECREF(obj);
|
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user