Hello,
On 12/6/10 6:09 PM, Andreas Granig wrote:
Hi Daniel,
How is this actually supposed to work? What I'd like to do in the end is extracting for example the "none" from the "basic"-tag by specifying "xpath:/presence/tuple/status/basic", which also returns an empty string now, also when appended with "/text()".
the problem is in between IETF and XML guys :-)
xpath require to use a prefix for namespaces. The SIMPLE guys liked to set a default one without prefix.
For this case, try:
modparam("presence_xml", "xml_ns", "pidf=urn:ietf:params:xml:ns:pidf")
then:
xlog("L_INFO", "tmp2=$xml(x=>xpath:/pidf:presence/pidf:tuple/pidf:status/pidf:basic)\n");
Got it. But what if it gets a bit more difficult than that? :)
I've an xml document where the namespace for some elements changes, like this:
<?xml version="1.0" encoding="utf-8"?>
<presence xmlns="urn:ietf:params:xml:ns:pidf" entity="sip:foo@mydomain.com">
<tuple id="86ae65b7-42de-4399-b635-295caad13aac"> <status> <basic>none</basic> <geopriv xmlns="urn:ietf:params:xml:ns:pidf:geopriv10"> <location-info> <location xmlns="http://www.opengis.net/gml"> [snip]
As you can see, the "geopriv" element changes the namespace from "pidf" to "pidf:geopriv10". Even giving the full namespace (".../urn:ietf:params:xml:ns:pidf:geopriv10:geopriv") to capture the "geopriv" element results in
ERROR: presence_xml [pv_xml.c:310]: unable to evaluate xpath expression [/pidf:presence/pidf:tuple/pidf:status/urn:ietf:params:xml:ns:pidf:geopriv10:geopriv/83]
Any ideas are highly appreciated :)
you can define many xml_ns parameters, each with different prefix. I guess the inner xmlns overwrites the other one in your sample xml document, so you have to use different prefix for that nodes:
modparam("presence_xml", "xml_ns", "pidf=urn:ietf:params:xml:ns:pidf") modparam("presence_xml", "xml_ns", "geop=urn:ietf:params:xml:ns:pidf:geopriv10")
Try a path like: /pidf:presence/pidf:tuple/pidf:status/geop:geopriv/...
Hope it works.
Daniel