Shahar Havivi
2014-Aug-26 14:19 UTC
[Libguestfs] [PATCH 1/3] v2v: add xmlXPathRegisterNs for libxml2 binding
Signed-off-by: Shahar Havivi <shaharh@redhat.com> --- v2v/xml-c.c | 15 +++++++++++++++ v2v/xml.ml | 1 + v2v/xml.mli | 2 ++ 3 files changed, 18 insertions(+) diff --git a/v2v/xml-c.c b/v2v/xml-c.c index 4c9bc77..aea62ae 100644 --- a/v2v/xml-c.c +++ b/v2v/xml-c.c @@ -141,6 +141,21 @@ v2v_xml_xpath_new_context (value docv) } value +v2v_xml_xpath_register_ns (value xpathctxv, value prefix, value uri) +{ + CAMLparam3 (xpathctxv, prefix, uri); + xmlXPathContextPtr xpathctx; + int r; + + xpathctx = Xpathctx_val (xpathctxv); + r = xmlXPathRegisterNs (xpathctx, BAD_CAST String_val (prefix), BAD_CAST String_val (uri)); + if (r == -1) + caml_invalid_argument ("xpath_register_ns: unable to register namespace"); + + CAMLreturn (Val_unit); +} + +value v2v_xml_xpath_eval_expression (value xpathctxv, value exprv) { CAMLparam2 (xpathctxv, exprv); diff --git a/v2v/xml.ml b/v2v/xml.ml index 78cb022..fea8784 100644 --- a/v2v/xml.ml +++ b/v2v/xml.ml @@ -31,6 +31,7 @@ type node = doc * node_ptr external parse_memory : string -> doc = "v2v_xml_parse_memory" external xpath_new_context : doc -> xpathctx = "v2v_xml_xpath_new_context" external xpath_eval_expression : xpathctx -> string -> xpathobj = "v2v_xml_xpath_eval_expression" +external xpath_register_ns : xpathctx -> string -> string -> unit = "v2v_xml_xpath_register_ns" external xpathobj_nr_nodes : xpathobj -> int = "v2v_xml_xpathobj_nr_nodes" external xpathobj_get_node_ptr : xpathobj -> int -> node_ptr = "v2v_xml_xpathobj_get_node_ptr" diff --git a/v2v/xml.mli b/v2v/xml.mli index 38bb9cd..8eefecc 100644 --- a/v2v/xml.mli +++ b/v2v/xml.mli @@ -29,6 +29,8 @@ val xpath_new_context : doc -> xpathctx (** xmlXPathNewContext *) val xpath_eval_expression : xpathctx -> string -> xpathobj (** xmlXPathEvalExpression *) +val xpath_register_ns : xpathctx -> string -> string -> unit +(** xmlXPathRegisterNs *) val xpathobj_nr_nodes : xpathobj -> int (** Get the number of nodes in the node set of the xmlXPathObjectPtr. *) -- 1.9.3
Richard W.M. Jones
2014-Aug-26 15:06 UTC
Re: [Libguestfs] [PATCH 1/3] v2v: add xmlXPathRegisterNs for libxml2 binding
On Tue, Aug 26, 2014 at 05:19:36PM +0300, Shahar Havivi wrote:> Signed-off-by: Shahar Havivi <shaharh@redhat.com> > --- > v2v/xml-c.c | 15 +++++++++++++++ > v2v/xml.ml | 1 + > v2v/xml.mli | 2 ++ > 3 files changed, 18 insertions(+)Thanks - I have pushed this upstream. Note I had to include <libxml/xpathInternals.h> in order to silence a warning, so you will need to delete your (now conflicting) copy of the patch and rebase on top of current HEAD. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top