Martin Bjorklund <[email protected]> writes:

> Hi,
>
> Jernej Tuljak <[email protected]> wrote:
>> Hi,
>> 
>> I'm trying to determine who is at fault, our YANG validator
>> implementation or the module ietf-netconf-nmda in RFC8526 .
>> 
>> There is a "when" expression at line 193 within this module
>> 
>> when 'derived-from-or-self(datastore, "ds:operational") ';
>> 
>> which is under this pseudo-branch within the module: / get-data
>> ("rpc") / input ("input") / origin-filters ("choice").
>> 
>> Our implementation claims that the initial context node of the
>> expression does not contain a "datastore" child, resulting in a
>> warning for this expression, which seemed like an obvious bug at
>> first, but does not anymore.
>> 
>> The accessible tree for this expression is built using the following
>> bullet in Section 6.4.1:
>> 
>>    o  If the XPath expression is defined in a substatement to an "input"
>>       statement in an "rpc" or "action" statement, the accessible tree
>>       is the RPC or action operation instance, all state data in the
>>       server, and the running configuration datastore.  The root node
>>       has top-level data nodes in all modules as children.
>>       Additionally, for an RPC, the root node also has the node
>>       representing the RPC operation being defined as a child.  The node
>>       representing the operation being defined has the operation's input
>>       parameters as children.
>> 
>> 
>> "origin-filters" for which the "when" expression is defined is clearly
>> a substatement to an "input" statement in an "rpc" statement. Pseudo-
>> accessible tree below (matches what our implementation does).
>> 
>> <root>
>>     +- get-data
>>         +- datastore
>>         +- // other data node siblings of datastore
>>     +- // top-level data nodes of all modules

The rules may be easier to describe if we define schema root nodes (or similar 
name) as a special category of schema nodes. It makes sense also because all 
these schema root nodes have a corresponding instance node in the XPath tree - 
the invisible XPath root, rpc, input, output and notification.

Lada

>> 
>> The initial context node is determined by using the following bullet
>> in Section 7.21.5:
>> 
>>    o  If the "when" statement is a child of a "uses", "choice", or
>>       "case" statement, then the context node is the closest ancestor
>>       node to the node with the "when" statement that is also a data
>>       node.  If no such node exists, the context node is the root node.
>>       The accessible tree is tentatively altered during the processing
>>       of the XPath expression by removing all instances (if any) of the
>>       nodes added by the "uses", "choice", or "case" statement.
>> 
>> 
>> The "when" statement in question is clearly a child of a "choice"
>> statement without a data node ancestor. Neither "input" nor "rpc"
>> represent data nodes, as per Terminology section:
>> 
>>    o  data node: A node in the schema tree that can be instantiated in a
>>       data tree.  One of container, leaf, leaf-list, list, anydata, and
>>       anyxml.
>> 
>> 
>> To our implementation this means that the initial context node is the
>> root node of the accessible tree, not the node that represents the
>> "rpc". Therefore the expression is attempting to refer to a node that
>> is undefined. It is expecting
>> 
>> when 'derived-from-or-self(get-data/datastore, "ds:operational") ';
>> 
>> or something along those lines instead.
>> 
>> Either way, something doesn't add up between RFC7950 and RFC8526.
>> 
>> There is a suspicious verified RFC7950 errata
>> (https://www.rfc-editor.org/errata/eid4794) dealing with initial
>> context nodes under augments, but there's nothing for the UCC ("uses",
>> "choice", "case") corner case. Perhaps there should be? Should Section
>> 7.21.5 say
>> 
>> NEW:
>> 
>>    o  If the "when" statement is a child of a "uses", "choice", or
>>       "case" statement, then the context node is the closest ancestor
>>       node to the node with the "when" statement that is also a data
>>       node, rpc, action or notification.  If no such node exists, the
>>       context node is the root node. The accessible tree is tentatively
>>       altered during the processing of the XPath expression by removing
>>       all instances (if any) of the nodes added by the "uses",
>>       "choice", or "case" statement.
>> 
>> OLD:
>> 
>>    o  If the "when" statement is a child of a "uses", "choice", or
>>       "case" statement, then the context node is the closest ancestor
>>       node to the node with the "when" statement that is also a data
>>       node.  If no such node exists, the context node is the root node.
>>       The accessible tree is tentatively altered during the processing
>>       of the XPath expression by removing all instances (if any) of the
>>       nodes added by the "uses", "choice", or "case" statement.
>> 
>> ?
>
> I think this matches the intent.  As you note above, since the
> accessible tree is:
>
>   <root>
>       +- get-data
>           +- datastore
>           +- // other data node siblings of datastore
>       +- // top-level data nodes of all modules
>
> the context node for the "when" statement in the "choice" is supposed
> to be "get-data".
>
> This also makes it consistent with augment:
>
>   augment /get-data/input {
>     choice origin-filters {
>       when 'derived-from-or-self(datastore, "ds:operational")';
>       ...
>     }
>   }
>
>
>
> /martin
>
> _______________________________________________
> netmod mailing list
> [email protected]
> https://www.ietf.org/mailman/listinfo/netmod

-- 
Ladislav Lhotka 
Head, CZ.NIC Labs
PGP Key ID: 0xB8F92B08A9F76C67

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

Reply via email to