[SR-Users] escape firt two lines from get_body_part to get xml only part

Daniel-Constantin Mierla miconda at gmail.com
Wed Apr 6 10:40:52 CEST 2022


It doesn't seem that element gml:pos is the root node, so the path to it
has to contain the parent tags. See the xpath specs to understand
betther how it has to be constructed.

Cheers,
Daniel

On 06.04.22 10:14, Artur Hovsepyan wrote:
> i have managed to escape first two lines assuming their length is
> constant:
>
>
> $var(pbody) = $(var(pbody){s.strip,115});
> defined the namespaces:
>
>     455 modparam("xmlops", "xml_ns", "pidf=urn:ietf:params:xml:ns:pidf")
>     456 modparam("xmlops", "xml_ns",
> "gp=urn:ietf:params:xml:ns:pidf:geopriv10")
>     457 modparam("xmlops", "xml_ns",
> "gs=http://www.opengis.net/pidflo/1.0")
>     458 modparam("xmlops", "xml_ns", "gml=http://www.opengis.net/gml")
>
> now i am trying to access the namespace "gml" from xml document but no
> luck:
>
>
> 593                 xinfo("GML_LOC: $xml(x=>xpath:/gml:pos)\n");
>
> trying to get the position from XML document:
>
> <?xml version="1.0"?>
> <presence xmlns="urn:ietf:params:xml:ns:pidf"
> xmlns:dm="urn:ietf:params:xml:ns:pidf:data-model"
> xmlns:gp="urn:ietf:params:xml:ns:pidf:geopriv10"
> xmlns:gml="http://www.opengis.net/gml"
> xmlns:gs="http://www.opengis.net/pidflo/1.0"
> xmlns:con="urn:ietf:params:xml:ns:geopriv:conf"
> entity="sip:+16478897789 at ims.mnc015.mcc302.3gppnetwork.org">
> <dm:device id="Wifi">
> <gp:geopriv>
> <gp:location-info>
> <gs:Circle srsName="urn:ogc:def:crs:EPSG::5524">
> *<gml:pos>31.204359 -44.512358</gml:pos>*
> <gs:radius uom="urn:ogc:def:uom:EPSG::8190">10.578000</gs:radius>
> </gs:Circle>
> <con:confidence pdf="normal">92</con:confidence>
> </gp:location-info>
> <gp:method>DBH_HELO</gp:method>
> <gp:usage-rules/>
> </gp:geopriv>
> <dm:timestamp>2022-04-05T19:16:34Z</dm:timestamp>
> </dm:device>
> </presence>
>
> any ideas how to correctly define the gml namespace to be able to
> access the "pos" ?
>
> thanks in advance,
>
>
> On Wednesday, April 6, 2022, 03:18:32 AM EDT, Artur Hovsepyan
> <hvspa at yahoo.com> wrote:
>
>
> sending third time the same message, if not formatted again, please
> excuse me and please let me know how to send so the message comes in
> formatted:
>
>
> hello everyone,
>  
> i am trying to parse the xml from the message body:
> get_body_part("application/pidf+xml", "$var(pbody)"); and i am getting
> the following in my pbody var:
>  
> Content-Disposition: render;handling=optional
> Content-ID: <sip:+6478897789 at ims.mnc0xx.mccxxx.3gppnetwork.org>
> <?xml version="1.0"?>
> <presence xmlns:dm="urn:ietf:params:xml:ns:pidf:data-model"
> xmlns:gp="urn:ietf:params:xml:ns:pidf:geopriv10"
> xmlns:gml="http://www.opengis.net/gml"
> xmlns:gs="http://www.opengis.net/pidflo/1.0"
> xmlns:con="urn:ietf:params:xml:ns:geopriv:conf"
> entity="sip:+6478897789 at ims.mnc0xx.mccxxx.3gppnetwork.org">
> <dm:device id="Wifi">
> <gp:geopriv>
> <gp:location-info>
> <gs:Circle srsName="urn:ogc:def:crs:EPSG::5524">
> <gml:pos>31.204359 -44.512358</gml:pos>
> <gs:radius uom="urn:ogc:def:uom:EPSG::8190">10.578000</gs:radius>
> </gs:Circle>
> <con:confidence pdf="normal">92</con:confidence>
> </gp:location-info>
> <gp:method>DBH_HELO</gp:method>
> <gp:usage-rules/>
> </gp:geopriv>
> <dm:timestamp>2022-04-05T19:16:34Z</dm:timestamp>
> </dm:device>
> </presence>
>  
>  
> how can i escape the first two lines in order to get the xml part of
> the content?
>  
> thanks in advance,
> Art
>
>
>
> On Wednesday, April 6, 2022, 03:16:51 AM EDT, Artur Hovsepyan
> <hvspa at yahoo.com> wrote:
>
>
> not sure why my first post is not formatted, sending it second time to
> make sure if it comes formatted or not:
>
> hello everyone,
>  
> i am trying to parse the xml from the message
> body: _get_body_part("application/pidf+xml", "$var(pbody)");_ and i am
> getting the following in my pbody var:
>  
> Content-Disposition: render;handling=optional
> Content-ID: <sip:+6478897789 at ims.mnc0xx.mccxxx.3gppnetwork.org>
> <?xml version="1.0"?>
> <presence xmlns:dm="urn:ietf:params:xml:ns:pidf:data-model"
> xmlns:gp="urn:ietf:params:xml:ns:pidf:geopriv10"
> xmlns:gml="http://www.opengis.net/gml"
> xmlns:gs="http://www.opengis.net/pidflo/1.0"
> xmlns:con="urn:ietf:params:xml:ns:geopriv:conf"
> entity="sip:+6478897789 at ims.mnc0xx.mccxxx.3gppnetwork.org">
> <dm:device id="Wifi">
> <gp:geopriv>
> <gp:location-info>
> <gs:Circle srsName="urn:ogc:def:crs:EPSG::5524">
> <gml:pos>31.204359 -44.512358</gml:pos>
> <gs:radius uom="urn:ogc:def:uom:EPSG::8190">10.578000</gs:radius>
> </gs:Circle>
> <con:confidence pdf="normal">92</con:confidence>
> </gp:location-info>
> <gp:method>DBH_HELO</gp:method>
> <gp:usage-rules/>
> </gp:geopriv>
> <dm:timestamp>2022-04-05T19:16:34Z</dm:timestamp>
> </dm:device>
> </presence>
>  
>  
> how can i escape the first two lines in order to get the xml part of
> the content?
>  
> thanks in advance,
> Art
>
>
>
> On Wednesday, April 6, 2022, 03:07:34 AM EDT, Artur Hovsepyan
> <hvspa at yahoo.com> wrote:
>
>
> hello everyone,
>  
> i am trying to parse the xml from the message
> body: _get_body_part("application/pidf+xml", "$var(pbody)");_ and i am
> getting the following in my pbody var:
>  
> Content-Disposition: render;handling=optional
> Content-ID: <sip:+6478897789 at ims.mnc0xx.mccxxx.3gppnetwork.org>
> <?xml version="1.0"?>
> <presence xmlns:dm="urn:ietf:params:xml:ns:pidf:data-model"
> xmlns:gp="urn:ietf:params:xml:ns:pidf:geopriv10"
> xmlns:gml="http://www.opengis.net/gml"
> xmlns:gs="http://www.opengis.net/pidflo/1.0"
> xmlns:con="urn:ietf:params:xml:ns:geopriv:conf"
> entity="sip:+6478897789 at ims.mnc0xx.mccxxx.3gppnetwork.org">
> <dm:device id="Wifi">
> <gp:geopriv>
> <gp:location-info>
> <gs:Circle srsName="urn:ogc:def:crs:EPSG::5524">
> <gml:pos>31.204359 -44.512358</gml:pos>
> <gs:radius uom="urn:ogc:def:uom:EPSG::8190">10.578000</gs:radius>
> </gs:Circle>
> <con:confidence pdf="normal">92</con:confidence>
> </gp:location-info>
> <gp:method>DBH_HELO</gp:method>
> <gp:usage-rules/>
> </gp:geopriv>
> <dm:timestamp>2022-04-05T19:16:34Z</dm:timestamp>
> </dm:device>
> </presence>
>  
>  
> how can i escape the first two lines in order to get the xml part of
> the content?
>  
> thanks in advance,
> Art
>
> __________________________________________________________
> 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
  * 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/20220406/9387f85e/attachment.htm>


More information about the sr-users mailing list