Subject: [netmod] derived-from issue

From: Martin Bjorklund <[email-masked]>
Date: Mon, 23 Nov 2015 13:19:15 +0100 (CET)

Hi,

derived-from is defined as:

    boolean derived-from(node-set nodes,
                         string module-name,
                         string identity-name)
  
  The derived-from() function returns true if the first node in
  document order in the argument "nodes" is a node of type
  identityref, and its value is an identity that is derived from the
  identity "identity-name" defined in the YANG module "module-name";
  otherwise it returns false.

The "first node in the node set" doesn't work well with leaf lists.  I
suggest this change:

NEW:

  The derived-from() function returns true if any node in
  the argument "nodes" is a node of type
  identityref, and its value is an identity that is derived from the
  identity "identity-name" defined in the YANG module "module-name";
  otherwise it returns false.

(and similar for derived-from-or-self)

As an example, consider this model:

   leaf-list yang-protocol {
     type identityref {
       base yang-protocol;
     }
  }

and this query:

   /modules/module[not derived-from-or-self(restricted-protocol,
                                            "ietf-yang-library",
                                            "netconf-1.1")]

/martin

---

From: Ladislav Lhotka <[email-masked]>
Date: Mon, 23 Nov 2015 13:39:47 +0100

> On 23 Nov 2015, at 13:19, Martin Bjorklund <[email-masked]> wrote:
> 
> Hi,
> 

This makes sense. In fact, other XPath functions (deref() and enum-value()) are also defined using "the first node in document order". This seems to be at odds with sec. 6.4 that says: "This means that XPath expressions in YANG modules SHOULD not rely on any specific document order." Is it OK that the result of such functions is undefined if the node-set argument contains multiple nodes?

Lada 

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

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

---

From: Martin Bjorklund <[email-masked]>
Date: Mon, 23 Nov 2015 13:57:40 +0100 (CET)

Ladislav Lhotka <[email-masked]> wrote:
> This makes sense.

Good.

> In fact, other XPath functions (deref() and
> enum-value()) are also defined using "the first node in document
> order". This seems to be at odds with sec. 6.4 that says: "This means
> that XPath expressions in YANG modules SHOULD not rely on any specific
> document order." Is it OK that the result of such functions is
> undefined if the node-set argument contains multiple nodes?

I think so.  These functions are intended for single leafs (what is
the enum value of a leaf-list?).  The alternative would be to say that
it is an error if the node set contains more than one node, but XPath
functions rarely returns errors.

/martin

---

From: Ladislav Lhotka <[email-masked]>
Date: Mon, 23 Nov 2015 14:05:06 +0100

> On 23 Nov 2015, at 13:57, Martin Bjorklund <[email-masked]> wrote:
> 

I don't think it should be an error but it might be useful to explicitly state that the result of deref() and enum-value() is undefined if the node-set involves multiple nodes, with reference to sec. 6.4.

Lada