Friends, I'm having issues with the xpath support. If I run Daniel's example in the XMLOPS, xpath works as documented. But if I take the body of a PUBLISH from the and run xpath, I don't get expected results. Now, I'm no XPATH guru so I may be totally off the markup here...
Here's the test script:
$xml(pub=>doc) = $rb; $var(contact)=$xml(pub=>xpath:registration/contact@event); xlog("--- Publish contact $var(contact) \n"); xlog("--- Publish aor $xml(pub=>xpath:registration@aor) \n"); xlog("--- Publish aor: $xml(pub=>xpath://@aor) \n"); xlog("--- Publish reg state: $xml(pub=>xpath://reginfo@state) \n"); xlog("--- Publish uri: $xml(pub=>xpath:contact/uri/text()) \n");
I've tested with various paths, orginating from /reginfo or just picking an attribute.
Here's the XML from Carsten's PUA_REGINFO module:
<?xml version="1.0"?> <reginfo xmlns="urn:ietf:params:xml:ns:reginfo" version="0" state="full"> <registration aor="sip:oej@testnamn.se" id="0x80590a590" state="terminated"/> </reginfo>
I wonder if it's something with using the request body that doesn't parse properly in the XMLOPS module?
Error messages are a series of "XPath error : Invalid expression"
/O
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)
Cheers, Daniel
On 2/27/12 8:50 PM, Olle E. Johansson wrote:
Friends, I'm having issues with the xpath support. If I run Daniel's example in the XMLOPS, xpath works as documented. But if I take the body of a PUBLISH from the and run xpath, I don't get expected results. Now, I'm no XPATH guru so I may be totally off the markup here...
Here's the test script:
$xml(pub=>doc) = $rb; $var(contact)=$xml(pub=>xpath:registration/contact@event); xlog("--- Publish contact $var(contact) \n"); xlog("--- Publish aor $xml(pub=>xpath:registration@aor) \n"); xlog("--- Publish aor: $xml(pub=>xpath://@aor) \n"); xlog("--- Publish reg state: $xml(pub=>xpath://reginfo@state) \n"); xlog("--- Publish uri: $xml(pub=>xpath:contact/uri/text()) \n");
I've tested with various paths, orginating from /reginfo or just picking an attribute.
Here's the XML from Carsten's PUA_REGINFO module:
<?xml version="1.0"?>
<reginfo xmlns="urn:ietf:params:xml:ns:reginfo" version="0" state="full"> <registration aor="sip:oej@testnamn.se" id="0x80590a590" state="terminated"/> </reginfo>
I wonder if it's something with using the request body that doesn't parse properly in the XMLOPS module?
Error messages are a series of "XPath error : Invalid expression"
/O _______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
I forgot to mention another option, a dirty workaround, use subst transformation to replace "xmlns=" with something else like "xmlxx=". Then practically there will be no more a xmlns without prefix and limxml2 xpath implementation is working fine without need to add xml_ns parameter to xmlops module.
Cheers, Daniel
On 2/27/12 9:07 PM, Daniel-Constantin Mierla wrote:
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)
Cheers, Daniel
On 2/27/12 8:50 PM, Olle E. Johansson wrote:
Friends, I'm having issues with the xpath support. If I run Daniel's example in the XMLOPS, xpath works as documented. But if I take the body of a PUBLISH from the and run xpath, I don't get expected results. Now, I'm no XPATH guru so I may be totally off the markup here...
Here's the test script:
$xml(pub=>doc) = $rb; $var(contact)=$xml(pub=>xpath:registration/contact@event); xlog("--- Publish contact $var(contact) \n"); xlog("--- Publish aor $xml(pub=>xpath:registration@aor) \n"); xlog("--- Publish aor: $xml(pub=>xpath://@aor) \n"); xlog("--- Publish reg state: $xml(pub=>xpath://reginfo@state) \n"); xlog("--- Publish uri: $xml(pub=>xpath:contact/uri/text()) \n");
I've tested with various paths, orginating from /reginfo or just picking an attribute.
Here's the XML from Carsten's PUA_REGINFO module:
<?xml version="1.0"?>
<reginfo xmlns="urn:ietf:params:xml:ns:reginfo" version="0" state="full"> <registration aor="sip:oej@testnamn.se" id="0x80590a590" state="terminated"/>
</reginfo>
I wonder if it's something with using the request body that doesn't parse properly in the XMLOPS module?
Error messages are a series of "XPath error : Invalid expression"
/O _______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
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
/O
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=3259ef73...
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.
Cheers, Daniel
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=3259ef73...
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
2012/2/27 Daniel-Constantin Mierla daniel@kamailio.org:
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.
Right. IETF SIMPLE group decided to break xpath 1.0 compatibility (what libxml2 implements) to save just a fews bytes in the XML ! Really annoying.
Some time ago I did an ugly workaround in a C project to "fix" it. What Daniel suggests is similar and unfortunately is the way to go in this century.