Dear netmod WG,
I have a question regarding RFC 7950 The YANG 1.1 Data Modeling
Language. [1]
In section 9.9. The leafref Built-In Type:
> The leafref built-in type is restricted to the value space of some
> leaf or leaf-list node in the schema tree and optionally further
> restricted by corresponding instance nodes in the data tree. The
> "path" substatement (Section 9.9.2) is used to identify the referred
> leaf or leaf-list node in the schema tree. The value space of the
> referring node is the value space of the referred node.
An overview implies single node path target.
In Section 9.9.2. The "path" statement
> The "path" statement, which is a substatement to the "type"
> statement, MUST be present if the type is "leafref". It takes as an
> argument a string that MUST refer to a leaf or leaf-list node.
>
> The syntax for a path argument is a subset of the XPath abbreviated
> syntax. Predicates are used only for constraining the values for the
> key nodes for list entries. Each predicate consists of exactly one
> equality test per key, and multiple adjacent predicates MAY be
> present if a list has multiple keys. The syntax is formally defined
> by the rule "path-arg" in Section 14.
>
> The predicates are only used when more than one key reference is
> needed to uniquely identify a leaf instance. This occurs if a list
> has multiple keys or a reference to a leaf other than the key in a
> list is needed. In these cases, multiple leafrefs are typically
> specified, and predicates are used to tie them together.
>
> The "path" expression evaluates to a node set consisting of zero,
> one, or more nodes. If the "require-instance" property is "true",
> this node set MUST be non-empty.
>
> The "path" XPath expression is conceptually evaluated in the
> following context, in addition to the definition in Section 6.4.1:
>
> o If the "path" statement is defined within a typedef, the context
> node is the leaf or leaf-list node in the data tree that
> references the typedef.
>
> o Otherwise, the context node is the node in the data tree for which
> the "path" statement is defined.
In the fourth paragraph, RFC explicitly says that it _IS_ possible to
target multiple schema nodes. The following formulation of the first
paragraph:
> It takes as an argument a string that MUST refer to a leaf or
leaf-list node.
Also talks about single node.
In Section 14. YANG ABNF Grammar
(Page 205-206)
> path-arg-str = < a string that matches the rule >
> < path-arg >
>
> path-arg = absolute-path / relative-path
> absolute-path = 1*("/" (node-identifier *path-predicate))
>
> relative-path = 1*("../") descendant-path
>
> descendant-path = node-identifier
> [*path-predicate absolute-path]
>
> path-predicate = "[" *WSP path-equality-expr *WSP "]"
>
> path-equality-expr = node-identifier *WSP "=" *WSP path-key-expr
>
> path-key-expr = current-function-invocation *WSP "/" *WSP
> rel-path-keyexpr
>
> rel-path-keyexpr = 1*(".." *WSP "/" *WSP)
> *(node-identifier *WSP "/" *WSP)
> node-identifier
(Page 190)
> leafref-specification =
> ;; these stmts can appear in any order
> path-stmt
> [require-instance-stmt]
>
> path-stmt = path-keyword sep path-arg-str stmtend
However I cannot think about any example that a) would match the
path-arg rule and b) would evaluate to node set with more than one
schema node.
The nonrestricted XPath syntax gives at least two ways to express
multiple nodes in single expression. By using the "|" node set union
operator or by using XPath axis. I might be wrong but I think that none
of those fulfill the path-arg syntax rule defined in RFC 7950.
My questions are:
Is it possible to create an path-arg expression evaluating to node set
with two nodes?
Is this a standard inconsistency? Because the description clearly says
that leafref
may target multiple leaf/leaf-list but path-arg rule does not allow it.
Best regards,
Vojtech Vilimek
CZ.NIC z. s. p. o.
[1]: https://datatracker.ietf.org/doc/html/rfc7950
_______________________________________________
netmod mailing list -- [email protected]
To unsubscribe send an email to [email protected]