Subject: [Simple] XCAP: Unique node selector but non unique path => HTTP 409 Conflict ?

From: Iñaki Baz Castillo <[email-masked]>
Date: Thu, 12 Nov 2009 19:45:55 +0100

Hi, please consider the following pres-rules document in which there
are two rules:
- id = "pres_whitelilst"
- id = "black_whitelist"

<?xml version='1.0' encoding='UTF-8'?>
<cp:ruleset xmlns:pr="urn:ietf:params:xml:ns:pres-rules"
xmlns:cp="urn:ietf:params:xml:ns:common-policy">
  <cp:rule id="pres_whitelist">
    <cp:conditions>
      <cp:identity>
        <cp:one id="sip:[email-masked]"/>
      </cp:identity>
    </cp:conditions>
    <cp:actions>
      <pr:sub-handling>allow</pr:sub-handling>
    </cp:actions>
  </cp:rule>
  <cp:rule id="pres_blacklist">
    <cp:conditions>
      <cp:identity>
         <cp:one id="sip:[email-masked]"/>
      </cp:identity>
    </cp:conditions>
    <cp:actions>
      <pr:sub-handling>block</pr:sub-handling>
    </cp:actions>
  </cp:rule>
</cp:ruleset>

What should be the XCAP server response when receiving the following request?

GET /pres-rules/users/sip:[email-masked]/pres-rules/~~/cp:ruleset/cp:rule/cp:conditions/cp:identity/cp:one[@id="sip:[email-masked]"]

Note that the path is not unique when arriving to
"cp:ruleset/cp:rule/" as there are two <cp:rule> nodes so it's not
unique.
However, the final selector is unique as there is noly one <cp:one>
node with id="sip:[email-masked]".

My XML parser allows it and finds the node. I think (but I'm not sure)
that Xpath specifications allows it. However I don't know if XCAP
protocol overrides it so the request should get a "409 Conflict".

I do know that XCAP doesn't allow a Xpath selector getting more than
one node, but it's not the case of the above request as I've
explained. However the first portion of the Xpath
"cp:ruleset/cp:rule/" is not unique (as there are two <cp:rule>
nodes).

So, should the XCAP server reply 409? or should accept the request and
reply 200 with the fetched node in the body?

Thanks a lot.

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

---

From: Iñaki Baz Castillo <[email-masked]>
Date: Sat, 14 Nov 2009 23:24:43 +0100

> reply 200 with the fetched node in the body?

Hi, as nobody replies to questions about SIMPLE/XCAP in this maillist I just 
would like to know if this is not the appropriate place to ask such questions.

Perhaps this maillist is focused on comments about new drafts or specification 
proposals. If so, could I know a good maillist in which I could ask about 
SIMPLE/XCAP as implementor? Is sip-implementors the appropriate place?

Thanks a lot.

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

---

From: Jari Urpalainen <[email-masked]>
Date: Mon, 16 Nov 2009 15:13:52 +0200

> SIMPLE/XCAP as implementor? Is sip-implementors the appropriate place?

Section 6.3:
"Each step in a node selector MUST produce a single element to form the
context for the next step.  This is more restrictive than general XPath
expressions, which allow a context to contain multiple nodes."

So 409/error is the right answer. That being said, I would have
preferred the more liberal XPath model, but it was argued that it could
have performance implications. At least in my implementation though, it
would be faster to use the XPath model (the difference is very small
however). But I've no clue how many implementations actually obey this
rule.

br, jari

---

From: Iñaki Baz Castillo <[email-masked]>
Date: Mon, 16 Nov 2009 14:36:08 +0100

El Lunes, 16 de Noviembre de 2009, Jari Urpalainen escribió:
> > Hi, as nobody replies to questions about SIMPLE/XCAP in this maillist I
> > just would like to know if this is not the appropriate place to ask such
> > questions.
> >
> > Perhaps this maillist is focused on comments about new drafts or
> > specification proposals. If so, could I know a good maillist in which I
> > could ask about SIMPLE/XCAP as implementor? Is sip-implementors the
> > appropriate place?
> >
> > Thanks a lot.
> 
> Section 6.3:

Thanks. However I also asked in sip-implementors and got a reply in which 
returning 200 OK is the correct reply:

----------------------------------------------------------------
The response should be 200 OK with the queried node.

During the selection process, you can have a result with a list of matching 
context. The uniqueness is only considered AFTER the whole criteria has been 
applied. As per RFC 4825 (Para 6.3), emphasis of mine:
 
"The selection operation operates as follows.  Within the current
   document context, the children of that context are enumerated in
   document order.  If the context is the root node of the document, its
   child element is the root element of the document.  If the context is
   an element, its children are all of the children of that element
   (naturally).  Next, those elements whose name is not a match for
   NameorAny are discarded.  An element name is a match if NameorAny is
   the wildcard, or if it is not a wildcard, the element name matches
   NameorAny.  Matching is discussed below.  The result is an ordered
   list of elements.

The elements in the list are further filtered by the predicates,
   which are the expressions in square brackets following NameorAny.
   Each predicate further prunes the elements from the current ordered
   list.  These predicates are evaluated in order.  If the content of
   the predicate is a position, the position-th element is selected
   (that is, treat "position" as a variable, and take the element whose
   position equals that variable), and all others are discarded.  If
   there are fewer elements in the list than the value of position, the
   result is a no-match."

...

After the predicates have been applied, the result will be a
   no-match, one element, or multiple elements.  If the result is
   multiple elements, the node selector is invalid.  Each step in a node
   selector MUST produce a single element to form the context for the
   next step.  This is more restrictive than general XPath expressions,
   which allow a context to contain multiple nodes.  If the result is a
   no-match, the node selector is invalid.  The node selector is only
   valid if a single element was selected.  This element becomes the
   context for the evaluation of the next step in the node selector
   expression."
----------------------------------------------------------------

However I also read "Each step in a node selector MUST produce a single 
element to form the context for the next step" which doesn't clarify me if 200 
is correct.

Thanks.