Subject: [netmod] tool to check XPath in YANG ?

From: "Tissa Senevirathne (tsenevir)" <[email-masked]>
Date: Sun, 13 Apr 2014 18:07:01 +0000

I am using pyang with --lax-xpath-checks to validate the XPath information. However for when and must key word it does only basic syntax validations.

Does anyone know a tool that I can use to validate the complete range of XPath within YANG. (including when and must)

Thanks in advance
Tissa

---

From: Ladislav Lhotka <[email-masked]>
Date: Sun, 13 Apr 2014 21:05:38 +0200

Hi Tissa,

> Does anyone know a tool that I can use to validate the complete range of XPath within YANG. (including when and must)

What exactly do you want to validate? Correctness of YANG modules, or validity of XML instance data with respect to “must” or “when” constraints?

Lada

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

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

---

From: "Tissa Senevirathne (tsenevir)" <[email-masked]>
Date: Sun, 13 Apr 2014 19:10:23 +0000

Hi Lada

I want to validate say for example.

When "../../f:foo-1/f:ffoo-2 = 'bar' "

I could enter the path wrong, how can I check this using a tool

 or I want to have multiple "or" combinations and want to check for the syntax of the XPath statement.

-----Original Message-----
From: Ladislav Lhotka [mailto:[email-masked]] 
Sent: Sunday, April 13, 2014 12:06 PM
To: Tissa Senevirathne (tsenevir)
Cc: [email-masked]
Subject: Re: [netmod] tool to check XPath in YANG ?

Hi Tissa,

> Does anyone know a tool that I can use to validate the complete range of XPath within YANG. (including when and must)

What exactly do you want to validate? Correctness of YANG modules, or validity of XML instance data with respect to "must" or "when" constraints?

Lada

---

From: Andy Bierman <[email-masked]>
Date: Sun, 13 Apr 2014 12:32:48 -0700

Hi,

You could try the yangdump-pro compiler online.
It checks must/when XPath path-stmts.

   http://www.netconfcentral.org/run_yangdump

Andy

On Sun, Apr 13, 2014 at 12:10 PM, Tissa Senevirathne (tsenevir) <
[email-masked]> wrote:

> > I am using pyang with --lax-xpath-checks to validate the XPath
> information. However for when and must key word it does only basic syntax
> validations.
> >
> > Does anyone know a tool that I can use to validate the complete range of
> XPath within YANG. (including when and must)
>
> What exactly do you want to validate? Correctness of YANG modules, or
> validity of XML instance data with respect to "must" or "when" constraints?
>
> Lada
>
> >
> > Thanks in advance
> > Tissa

---

From: "Tissa Senevirathne (tsenevir)" <[email-masked]>
Date: Sun, 13 Apr 2014 19:37:33 +0000

Thanks Andy, it does what I was looking for,

From: Andy Bierman [mailto:[email-masked]]
Sent: Sunday, April 13, 2014 12:33 PM
To: Tissa Senevirathne (tsenevir)
Cc: Ladislav Lhotka; [email-masked]
Subject: Re: [netmod] tool to check XPath in YANG ?

Hi,

Andy

On Sun, Apr 13, 2014 at 12:10 PM, Tissa Senevirathne (tsenevir) <[email-masked]<mailto:[email-masked]>> wrote:
Hi Lada

-----Original Message-----
From: Ladislav Lhotka [mailto:[email-masked]<mailto:[email-masked]>]
Sent: Sunday, April 13, 2014 12:06 PM
To: Tissa Senevirathne (tsenevir)
Cc: [email-masked]<mailto:[email-masked]>
Subject: Re: [netmod] tool to check XPath in YANG ?

Hi Tissa,

Lada

> [email-masked]<mailto:[email-masked]>

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

---

From: Ladislav Lhotka <[email-masked]>
Date: Mon, 14 Apr 2014 08:53:34 +0200

> or I want to have multiple "or" combinations and want to check for the syntax of the XPath statement.

As far as I can tell, pyang does check syntax of XPath expressions.

The problem with paths is that they are not a priori wrong, they just may evaluate to an empty nodeset - and the evaluation can be performed only in a context of an XML instance document, not at the time the YANG module is being validated. For example, an XPath expression may refer to a node that is defined in another module.

By the way, --lax-xpath-checks flag results in *weaker* XPath checks, which is not what you normally want.

Lada

---

From: Martin Bjorklund <[email-masked]>
Date: Mon, 14 Apr 2014 08:58:26 +0200 (CEST)

> As far as I can tell, pyang does check syntax of XPath expressions.

Not really, it performs some very trivial syntax checks (runs a
scanner) but it doesn't check the grammar.

> The problem with paths is that they are not a priori wrong, they just
> may evaluate to an empty nodeset - and the evaluation can be performed
> only in a context of an XML instance document, not at the time the
> YANG module is being validated. For example, an XPath expression may
> refer to a node that is defined in another module.

+1

... but the compiler should be able to warn about these situations.

/martin

---

From: Ladislav Lhotka <[email-masked]>
Date: Mon, 14 Apr 2014 09:14:53 +0200

> ... but the compiler should be able to warn about these situations.

Yes, that would be useful, but either only on request or at least it should be possible to turn this check off. It needs a complete data model, and for multi-module models it could generate bogus warnings.

Lada

---

From: Jernej Tuljak <[email-masked]>
Date: Mon, 14 Apr 2014 09:20:13 +0200

> Yes, that would be useful, but either only on request or at least it should be possible to turn this check off. It needs a complete data model, and for multi-module models it could generate bogus w…

Why would this need a complete data model? An XPath expression can only 
reference names in the local an imported modules, right? All this 
requires is "cooked YANG".

A compiler would be able to predict when an expression evaluates to an 
empty nodeset, but it cannot - not always. The reason is that 
expressions within reusable definitions (grouping, typedef) are poorly 
restricted in YANG. Any expression within a grouping should only be able 
to reference nodes defined within a grouping and typedefs should only be 
able to use absolute leafref paths. I wanted to raise a 1.1 issue about 
this, but it appears to be a 2.0 issue.

Jernej

---

From: Ladislav Lhotka <[email-masked]>
Date: Mon, 14 Apr 2014 09:39:38 +0200

On 14 Apr 2014, at 09:20, Jernej Tuljak <[email-masked]> wrote:

> Why would this need a complete data model? An XPath expression can only reference names in the local an imported modules, right? All this requires is "cooked YANG”.

You are right, unless the expression uses wildcards like

*[local-name()=‘foo’]

But this should be very rare, so paths can be checked by default.

> 
> A compiler would be able to predict when an expression evaluates to an empty nodeset, but it cannot - not always. The reason is that expressions within reusable definitions (grouping, typedef) are poorly restricted in YANG. Any expression within a grouping should only be able to reference nodes defined within a grouping and typedefs should only be able to use absolute leafref paths. I wanted to raise a 1.1 issue about this, but it appears to be a 2.0 issue.

Moreover, global typedefs (defined at the top level of a module) should always use explicit prefixes.

This could be added as a guideline in 6087bis.

Lada

---

From: Andy Bierman <[email-masked]>
Date: Mon, 14 Apr 2014 07:41:46 -0700

On Mon, Apr 14, 2014 at 12:39 AM, Ladislav Lhotka <[email-masked]> wrote:

> >>>>> or I want to have multiple "or" combinations and want to check for
> the
> >>>>> syntax of the XPath statement.
> >> Yes, that would be useful, but either only on request or at least it
> should be possible to turn this check off. It needs a complete data model,
> and for multi-module models it could generate bogus warnings.
> >
> reference names in the local an imported modules, right? All this requires
> is "cooked YANG".
>
> *[local-name()='foo']
> empty nodeset, but it cannot - not always. The reason is that expressions
> within reusable definitions (grouping, typedef) are poorly restricted in
> YANG. Any expression within a grouping should only be able to reference
> nodes defined within a grouping and typedefs should only be able to use
> absolute leafref paths. I wanted to raise a 1.1 issue about this, but it
> appears to be a 2.0 issue.
>
This is too restrictive.  These are intermediate results.
YANG allows complex constructs that need to be used correctly.
Only the expanded usage in the 'cooked' YANG can be fully validated.

Lada

Andy