[SR-Users] Publish XML and xpath

Daniel-Constantin Mierla miconda at gmail.com
Thu Feb 10 16:52:56 CET 2022


Hello,

actually the problem is the mess SIMPLE RFC authors made with XML
namespaces, by not setting and not using a prefix for them, otherwise
the #012 is end-of-line printed by syslog as octal character.

The solutions:

1) replace "xmlns=" with something else like "xyzwq=":

$xml(body=>doc) = $(rb{s.replace,xmlns=,xyzwq=})

and use xpath without concerning of xml namespaces prefix.

2) register a prefix for the namespace using xml_ns parameter from
xmlops module and use that prefix in xpath expressions.

See a past discussion on the mailing list:

   - https://lists.kamailio.org/pipermail/sr-users/2010-December/066690.html

Cheers,
Daniel

On 10.02.22 16:25, Igor Olhovskiy wrote:
>
> Hello
>
> Just to add, when I'm trying to dump $rb to logs, I'm getting this line
>
> <?xml version="1.0"?>#012<dialog-info xmlns="urn:ietf:params:xml:ns:dialog-info" version="0" state="full" entity="sip:88881 at dev.company">#012  <dialog id="f-XGMVyeO0" direction="recipient">#012    <state>terminated</state>#012  </dialog>#012</dialog-info>
>
> So, I expect problem is in this #012 + extra spaces. Is there a way to
> clean it up in an easy way?
>
> Regards,
> Igor
> Le 10.02.2022 à 16:01, Igor Olhovskiy a écrit :
>>
>> Hello,
>>
>> I'm trying to get state of endpoint from PUBLISH message in a most
>> simple way using xmlops module
>>
>> Trying to make this
>>
>> $xml(body=>doc) = $rb;
>> log("L_ERR", "$rU is now in state $xml(body=>xpath:/dialog-info/dialog/state)\n");
>>
>> XML in PUBLISH itself
>>
>> <?xml version="1.0"?>
>> <dialog-info xmlns="urn:ietf:params:xml:ns:dialog-info" version="0" state="full" entity="sip:88881 at dev.company">
>>   <dialog id="v6qmEYf5yI" direction="initiator">
>>     <state>confirmed</state>
>>   </dialog>
>> </dialog-info>
>>
>>
>> Actual text in log is
>>
>> ... <script>: 88881 is now in state
>>
>> Means it's empty. xmlops module is loaded with no parameters. Tried
>> also string
>>
>> $xml(body=>xpath:/dialog-info/dialog/state/text())
>>
>> -> same result
>>
>> What am I missing here?
>>
>> kamailio 5.4.6
>>
>> -- 
>> Thanks in advance,
>> Igor
>
> __________________________________________________________
> Kamailio - Users Mailing List - Non Commercial Discussions
>   * sr-users at lists.kamailio.org
> Important: keep the mailing list in the recipients, do not reply only to the sender!
> Edit mailing list options or unsubscribe:
>   * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training - Online
  Feb 21-24, 2022 (America Timezone)
  * https://www.asipto.com/sw/kamailio-advanced-training-online/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20220210/4daee770/attachment.htm>


More information about the sr-users mailing list