Subject: [netmod] another XPath question

From: Andy Bierman <[email-masked]>
Date: Thu, 20 Feb 2014 11:38:53 -0800

Hi,

Here is some YANG text from 7.19.5:

   o  If the context node represents RPC input parameters, the tree is
      the RPC XML instance document.  The XPath root node has the
      element representing the RPC operation being defined as the only
      child.

This seems to say the docroot is the <rpc> node (right?)

  rpc foo {
     input {
       leaf type { type int8; }
       container num8-stuff {
           when "/nc:rpc/acme:foo/acme:input/acme:type = 8";
            ...
       }
     }
  }

Is this how an absolute expr for rpc-input would look?
Or does the tree start with acme:foo and not netconf:rpc?
The text is confusing.

thanks,
Andy

---

From: Martin Bjorklund <[email-masked]>
Date: Thu, 20 Feb 2014 21:00:45 +0100 (CET)

> This seems to say the docroot is the <rpc> node (right?)

No, it doesn't say the "rpc" element, it says the element representing
the RPC operation being defined.  In this, case which RPC is being
defined?  "foo".

The RPC XML instance looks like this:

  <rpc message-id...>
    <foo xmlns...>
      <type>...</type>
      <num8-stuff>...</num8-stuff>
    </foo>
  </rpc>

So the expression, starting from the operation being defined, would be:

  when "/acme:foo/acme:type = 8";

/martin

---

From: Andy Bierman <[email-masked]>
Date: Thu, 20 Feb 2014 12:12:56 -0800

> Or does the tree start with acme:foo and not netconf:rpc?

The intent of the first sentence is to say that only the <rpc>
message (input parameters only) are in the tree.
I think sentence 2 should say "rpc" statement instead of "RPC operation".
It seems to say  the tree is /acme:foo is a node that has to be named:

              when "/acme:foo/acme:input/acme:type = 8";

IMO the <input> node should be the document root for must/when
expressions for rpc input parameters.

           when "/acme:type = 8";

So what is the correct version of this when-stmt?

---

From: Martin Bjorklund <[email-masked]>
Date: Thu, 20 Feb 2014 21:40:25 +0100 (CET)

>               when "/acme:foo/acme:input/acme:type = 8";

Why do you think "input" should be there?  The text says:

   the tree is the RPC XML instance document

there is no "input" element here.

Now the question is which node is the top-level node.

The XML looks like this:

  <rpc message-id...>
    <foo xmlns...>
      <type>...</type>

The text says:

  The XPath root node has the element representing the RPC operation
  being defined as the only child.

Is this really unclear?  How could this text be interpreted to mean
that the root node has multiple children, one for each input
parameter?

/martin

---

From: Jernej Tuljak <[email-masked]>
Date: Fri, 21 Feb 2014 10:44:28 +0100

> that the root node has multiple children, one for each input

I do not think the text is confusing and is correct. I've recently 
implemented functionality related to the text in question and understood 
it as Martin explained.

Whenever XPath (must/when) is involved, you should think with data tree 
in mind, not schema node tree (only nodes that may be instantiated can 
be referred to in a must/when argument, root node being the only 
exception, I believe).

Also, "document root" (the invisible _root node_ of any XML document) 
and "document element" (_root element_, first element - "the only child" 
in text) are two terms that are never to be confused as per XPath spec. 
You refer to the root node with ("/") and to the root element with 
("/*") in XPath. In case of when statement and RPC input parameters, 
document root is the same as that of the RPC XML instance document and 
<rpc> is the root element, which in turn may have child data nodes, 
defined using the input statement in YANG.

Problems like this are why I'd like a clearer separation between schema 
and instance documents in YANG. It should be absolutely impossible to 
confuse data nodes with schema nodes throughout the entire RFC6020.

Jernej

> _______________________________________________
> netmod mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/netmod

---

From: Jernej Tuljak <[email-masked]>
Date: Fri, 21 Feb 2014 10:48:41 +0100

Dne 21.2.2014 10:44, piše Jernej Tuljak:
> implemented functionality related to the text in question and 
> understood it as Martin explained.
>
> Whenever XPath (must/when) is involved, you should think with data 
> tree in mind, not schema node tree (only nodes that may be 
> instantiated can be referred to in a must/when argument, root node 
> being the only exception, I believe).
>
> and "document element" (_root element_, first element - "the only 
> child" in text) are two terms that are never to be confused as per 
> XPath spec. You refer to the root node with ("/") and to the root 
> element with ("/*") in XPath. In case of when statement and RPC input 
> parameters, document root is the same as that of the RPC XML instance 
> document and <rpc> is the root element, which in turn may have child 
> data nodes, defined using the input statement in YANG.

Forgot about the rpc statement, but it doesn't matter. Children are 
defined with rpc + input statement in YANG.

Jernej

>
> Problems like this are why I'd like a clearer separation between 
> schema and instance documents in YANG. It should be absolutely 
> impossible to confuse data nodes with schema nodes throughout the 
> entire RFC6020.
>
> Jernej
>
>>
>> /martin
>>
>>
>>
>>>

---

From: Ladislav Lhotka <[email-masked]>
Date: Fri, 21 Feb 2014 11:42:29 +0100

> that the root node has multiple children, one for each input

I think it is pretty clear. The mapping to Schematron in pyang prepends “$root“ to every absolute XPath expression, and the “root” variable is defined as “/nc:rpc” if the target document is an RPC request, or "/nc:rpc-reply" if it is an RPC reply.

Lada

--
Ladislav Lhotka, CZ.NIC Labs
PGP Key ID: E74E8C0C

---

From: Andy Bierman <[email-masked]>
Date: Fri, 21 Feb 2014 08:53:22 -0800

> Why do you think "input" should be there?  The text says:

That was a mistake.
The text is clear enough.
It would be nice to add an example of a must or when statement
within the rpc-input, rpc-output, and notification statements.

> that the root node has multiple children, one for each input

I don't think I said that.
It is confusing because it seems to mix YANG statement (RPC
operation being defined) with the <rpc> message structure.

Andy