Hi, I am trying to add xmlXPathRegisterNs() to v2v/xml-c.c but I get a seg fault, the signature should be: http://xmlsoft.org/html/libxml-xpathInternals.html#xmlXPathRegisterNs I think I am wrong in CAMLparam and CAMLlocal..., Following is the patch: =================================================================================== diff --git a/v2v/xml-c.c b/v2v/xml-c.c index 4c9bc77..a917c24 100644 --- a/v2v/xml-c.c +++ b/v2v/xml-c.c @@ -141,6 +141,16 @@ v2v_xml_xpath_new_context (value docv) } value +v2v_xml_xpath_register_ns (value prefix, value uri, value xpathctx) +{ + CAMLparam3 (prefix, uri, xpathctx); + CAMLlocal1 (retval); + retval = xmlXPathRegisterNs (BAD_CAST String_val (prefix), BAD_CAST String_val (uri), xpathctx); + + CAMLreturn (retval); +} + +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..2e4d222 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 : string -> string -> xpathctx -> int = "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..cab4395 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 : string -> string -> xpathctx -> int +(** xmlXPathRegisterNs *) val xpathobj_nr_nodes : xpathobj -> int (** Get the number of nodes in the node set of the xmlXPathObjectPtr. *) ===================================================================================