Subject: [Simple] XCAP: Issues with document/application default namespace

From: Iñaki Baz Castillo <[email-masked]>
Date: Thu, 19 Nov 2009 11:02:52 +0100

Hi, let imagine this XML document stored in XCAP server:

----test.xml------------------------
  <?xml version="1.0"?>
  <foo xmlns="urn:default-namespace">
  </foo>
------------------------------------

Which would be the correct XCAP query to get the <foo> node?:

1)
/test/users/sip:[email-masked]/test.xml/~~/foo

2)
/test/users/sip:[email-masked]/test.xml/~~/foo?xmlns(xmlns=urn:default-namespace)

3)
/test/users/sip:[email-masked]/test.xml/~~/a:foo?xmlns(a=urn:default-namespace)

I'm sure that case 3) is valid and works.

About case 1) I'm not sure if it should work.

Case 2) seems incorrect to me. However I don't know how the client can
indicate which is the default namespace used in the query (IMHO it cannot 
according to XCAP specs so it must use namespaces with prefix).
AFAIK XCAP specifies that when no prefix is used in the query Xpath the auid 
default namespace must be used (let's suppose "urn:default-namespace"), but 
what about if the XML document declares a different default namespace 
(different than the XCAP application default namespace)?

XCAP seems to "extend" this specs by allowing a Xpath query with no 
namespaces matching a XML document node in which the default document 
namespaces matches the XCAP app default namespace (ugly however).

According to XML namespaces and Xpath specs, cases 1) and 2) shouldn't work 
since the <foo> node has a namespace "urn:default-namespace" and it's not 
specified in the Xpath query. This is, in Xpath specs if the document declares 
a namespace then it must be included in the Xpath query even if it's the 
default namespace (so "xmlns='xxxxxxxxxx'" should appear in the Xpath query). 
Since XCAP query doesn't allow indicating a default namespace the client 
should use namespace prefix for the default namespace (so case 3 is valid).

What I mean is that XCAP violates Xpath and XML namespaces spects. Opinions?

Other question 100% related to this issue:

https://lists.cs.columbia.edu/pipermail/sip-implementors/2008-
April/018952.html

Thanks for any help. Regards.

-- 
Iñaki Baz Castillo <[email-masked]>

---

From: Iñaki Baz Castillo <[email-masked]>
Date: Thu, 19 Nov 2009 13:28:04 +0100

El Jueves, 19 de Noviembre de 2009, Iñaki Baz Castillo escribió:
> AFAIK XCAP specifies that when no prefix is used in the query Xpath the
>  auid default namespace must be used (let's suppose
>  "urn:default-namespace"), but what about if the XML document declares a
>  different default namespace (different than the XCAP application default
>  namespace)?
> 
> specified in the Xpath query. This is, in Xpath specs if the document
>  declares a namespace then it must be included in the Xpath query even if
>  it's the default namespace (so "xmlns='xxxxxxxxxx'" should appear in the
>  Xpath query). Since XCAP query doesn't allow indicating a default
>  namespace the client should use namespace prefix for the default namespace
>  (so case 3 is valid).
> 

After readin 5-6 times RFC 4825 section 5.2 "Default Document Namespace" I 
think I got the response. Please correct me if I'm wrong:

- Each XCAP auid has a "default auid document namespace" (AKA "default 
document namespace").

- This is just valid for the XCAP Xpath query and refers to the default used 
in evaluation of XCAP URIs, so if the Xpath contains nodes with no prefix (so 
no namespace association) then the server must assume that those nodes belong 
to the "default auid document namespace".

- The XML document itself can contain a "default namespace" in root node or 
childs (this means: <foo xmlns="org.lalala">. This namespace can match the 
"default auid document namespace" or *not*.

- If the XML document or node contains a default namespace then the XCAP Xpath 
query *MUST* contain a namespace definition matching it.

So, XML/Xpath specs are not violated by XCAP :)

To explain it with examples:

Example 1:
**********

Assume default auid document namespace = "urn:default-namespace":
----test1.xml------------------------
  <?xml version="1.0"?>
 
Client XCAP Xpath queries:

1)
/test/users/sip:[email-masked]/test1.xml/~~/foo

Not valid since the XML document contains a default namespace in node "foo" 
but the query doesn't declare it.

2)
/test/users/sip:[email-masked]/test1.xml/~~/a:foo?xmlns(a=urn:default-namespace)

Valid since the Xpath query declares a namespace with prefix "a" matching the 
namespace used in the server for same node, and the query uses it in the node 
selector ("a:foo").

Example 2:
**********

Assume default auid document namespace = "urn:default-namespace":
----test2.xml------------------------
  <?xml version="1.0"?>
  <foo>
  </foo>
 
Client XCAP Xpath queries:

1)
/test/users/sip:[email-masked]/test2.xml/~~/foo

Valid since the XML document doesn't declare a namespace for "foo" node so the 
Xpath query has no namespaces.

2)
/test/users/sip:[email-masked]/test2.xml/~~/a:foo?xmlns(a=urn:default-namespace)

Invalid since the XML document doesn't declare namespace for node "foo" but 
the XCAP Xpath query declares it.

Example 3:
**********

Assume default auid document namespace = "urn:default-namespace":
----test1.xml------------------------
  <?xml version="1.0"?>
  <foo xmlns="org.lalala">
  </foo>
 
Client XCAP Xpath queries:

1)
/test/users/sip:[email-masked]/test1.xml/~~/foo

Not valid since the XML document contains a default namespace in node "foo" 
("org.lalala") but the query doesn't declare it.

2)
/test/users/sip:[email-masked]/test1.xml/~~/a:foo?xmlns(a=org.lalala)

Valid since the Xpath query declares a namespace with prefix "a" matching the 
namespace used in the server for same node, and the query uses it in the node 
selector ("a:foo").

Unfortunatelly I don't understand yet the real purpose of the "default auid 
document namespace" :(

---

From: Jari Urpalainen <[email-masked]>
Date: Thu, 19 Nov 2009 15:40:02 +0200

> query *MUST* contain a namespace definition matching it.
not exactly since if prefix is "empty" default document namespace must
be applied.

> So, XML/Xpath specs are not violated by XCAP :)
I wouldn't call it a violation, but there's definitely different
interpretations between XPath 1 / XPath 2 / XCAP / Patch-Ops
selections. 

> To explain it with examples:
as default document namespace URI for this AU is indeed
"urn:default-namespace" a match occurs. This _is_ the use-case for
default document namespace, i.e. to avoid the query parameter. 

> namespace used in the server for same node, and the query uses it in the node 
right.

> Example 2:
not valid since the spec says that without prefixes you apply default
document namespace to elements. In practice, this is not a big deal
since at least all existing AUs use some namespace and don't define
unqualified elements.

> the XCAP Xpath query declares it.
right.

> Example 3:
so implementation looks for a <foo> element with namespace
"urn:default-namespace" and match isn't found.

> namespace used in the server for same node, and the query uses it in the node 
right.

> Unfortunatelly I don't understand yet the real purpose of the "default auid 

As said, it was defined to avoid those long URIs. If the model were
according to XPath 1.0 spec, you'd always need query parameters with
requests (with qualified element conventions). So there's indeed a
deficiency with selections if default document namespace is defined for
an AU, i.e. you can't select unqualified elements then, but this is a
minor issue. 

Note also that XPath 2 selects also qualified elements (default
namespace) with a selection like "foo", so XPath 2 is closer to XCAP
interpretation, but it's not the same. If you still insist on having
more XPath like selection logic look section 4.2.1 and 4.2.2 of
rfc5261 ;-)

br, Jari

---

From: Iñaki Baz Castillo <[email-masked]>
Date: Thu, 19 Nov 2009 14:54:39 +0100

El Jueves, 19 de Noviembre de 2009, Jari Urpalainen escribió:
> > > indicate which is the default namespace used in the query (IMHO it
> > > cannot according to XCAP specs so it must use namespaces with prefix).
> > >  "urn:default-namespace"), but what about if the XML document declares
> > > a different default namespace (different than the XCAP application
> > > default namespace)?
> > >
> > > According to XML namespaces and Xpath specs, cases 1) and 2) shouldn't
> > > work since the <foo> node has a namespace "urn:default-namespace" and
> > > it's not specified in the Xpath query. This is, in Xpath specs if the
> > > document declares a namespace then it must be included in the Xpath
> > > query even if it's the default namespace (so "xmlns='xxxxxxxxxx'"
> > > should appear in the Xpath query). Since XCAP query doesn't allow
> > > indicating a default namespace the client should use namespace prefix
> > > for the default namespace (so case 3 is valid).
> > >
> > After readin 5-6 times RFC 4825 section 5.2 "Default Document Namespace"
> > I think I got the response. Please correct me if I'm wrong:
> >
> >
> > - This is just valid for the XCAP Xpath query and refers to the default
> > used in evaluation of XCAP URIs, so if the Xpath contains nodes with no
> > prefix (so no namespace association) then the server must assume that
> > those nodes belong to the "default auid document namespace".
> >
> > - The XML document itself can contain a "default namespace" in root node
> > or childs (this means: <foo xmlns="org.lalala">. This namespace can match
> > the "default auid document namespace" or *not*.
> >
> > - If the XML document or node contains a default namespace then the XCAP
> > Xpath query *MUST* contain a namespace definition matching it.
> 
> > Not valid since the XML document contains a default namespace in node
> > "foo" but the query doesn't declare it.
> 
> > Valid since the Xpath query declares a namespace with prefix "a" matching
> > the namespace used in the server for same node, and the query uses it in
> > the node selector ("a:foo").
> 
> right.
> 
> > Example 2:
> > **********
> >
> > Valid since the XML document doesn't declare a namespace for "foo" node
> > so the Xpath query has no namespaces.
> 
> > Invalid since the XML document doesn't declare namespace for node "foo"
> > but the XCAP Xpath query declares it.
> 
> right.
> 
> > Example 3:
> > **********
> >
> > Not valid since the XML document contains a default namespace in node
> > "foo" ("org.lalala") but the query doesn't declare it.
> 
> > Valid since the Xpath query declares a namespace with prefix "a" matching
> > the namespace used in the server for same node, and the query uses it in
> > the node selector ("a:foo").
> 
> right.
> 
> > Unfortunatelly I don't understand yet the real purpose of the "default
> > auid document namespace" :(
> 

Really thanks for your great response. Please let me some time to study it :)

---

From: Iñaki Baz Castillo <[email-masked]>
Date: Thu, 19 Nov 2009 16:20:34 +0100

> Really thanks for your great response. Please let me some time to study it

Ok, 100% understood. However this is the reply I didn't desire as it requires 
a modification in the XML parser I'm using...  :-D

Really thanks a lot.