[SR-Users] XMLOPS xpath issues

Olle E. Johansson oej at edvina.net
Mon Feb 27 22:09:57 CET 2012


27 feb 2012 kl. 21:44 skrev Daniel-Constantin Mierla:

> 
> 
> On 2/27/12 9:28 PM, Olle E. Johansson wrote:
>> 27 feb 2012 kl. 21:07 skrev Daniel-Constantin Mierla:
>> 
>>> Hello,
>>> 
>>> an xpath invalid expression should be printed when the xpath expression is incorrect -- I cannot say what is wrong, not being an xpath expert by hart.
>>> 
>>> However, there is a mismatching between the xml standards and SIP/SIMPLE specs. In XML, the namespaces are bound to prefixes, while the guys at IETF added by their own so called default namespace, which has no prefix for it. That results in not being able to use directly xpath from libxml2 with SIMPLE bodies.
>>> 
>>> There were some discussions out there (you can google, iirc Inaki was in couple of them), in one side, the devs of libxml2 said they don't want to break XML standards by allowing bogus xpath queries with such namespaces. The workaround is to define xmlns prefix in xmlops module:
>>> 
>>> http://kamailio.org/docs/modules/devel/modules/xmlops.html#xml_ns
>>> 
>>> modparam("xmlops", "xml_ns", "ri=urn:ietf:params:xml:ns:reginfo")
>>> 
>>> and try:
>>> 
>>> $xml(pub=>xpath://ri:reginfo/ri:registration@aor)
>> Thanks!
>> 
>> The weird part is that I after adding that modparam get this error message:
>> loading modules under /usr/local/lib64/kamailio/modules_k/:/usr/local/lib64/kamailio/modules/
>>  0(65556) ERROR:<core>  [modparam.c:162]: set_mod_param_regex: No module matching<xmlops>  found
>>  0(65556) :<core>  [cfg.y:3504]: parse error in config file kam-modules.inc, line 86, column 65: Can't set module parameter
>> 
>> This is on FreeBSD.
>> 
>> If I raise the debug I see the module being loaded and that it registers PVs
>> 
>>  0(63596) DEBUG:<core>  [mem/q_malloc.c:369]: qm_malloc(0x800c00000, 40) called from xmlops: pv_xml.c: pv_parse_xml_name(448)
>> 
>> Weird stuff.
>> 
>> Kamailio 3.2.2
> there was a wrong internal module name, initially I added the xml manipulation function as part of presence_xml, but then spit them out and made a dedicated one. But the name was not updated. The patch is now in 3.2 branch:
> 
> http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=3259ef734158d9cd63ce3fa94565f5cd4260e3f6
> 
> If you cannot update right now, try:
> 
> modparam("presence_xml", "xml_ns", "ri=urn:ietf:params:xml:ns:reginfo")
> 
> Not sure if it works if presence_xml is loaded, but if not, it should.

I followed your ugly piece of advice (removing the xmlns: part from the text) and now everything works as expected. Thanks!

/O


More information about the sr-users mailing list