Subject: [netmod] 'predicate' production

From: Ladislav Lhotka <[email-masked]>
Date: Wed, 24 Feb 2016 14:31:30 +0100

Hi,

another ABNF issue:

   predicate           = "[" *WSP (predicate-expr / pos) *WSP "]"

   predicate-expr      = (node-identifier / ".") *WSP "=" *WSP
                         ((DQUOTE string DQUOTE) /
                          (SQUOTE string SQUOTE))

   pos                 = non-negative-integer-value

   non-negative-integer-value = "0" / positive-integer-value

The value of 0 shouldn't be allowed for 'pos' because context position in XPath is always positive, i.e. the first list entry is selected with "[1]".

Lada

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

---

From: Martin Bjorklund <[email-masked]>
Date: Wed, 24 Feb 2016 15:41:15 +0100 (CET)

Ladislav Lhotka <[email-masked]> wrote:
> The value of 0 shouldn't be allowed for 'pos' because context position
> in XPath is always positive, i.e. the first list entry is selected
> with "[1]".

You are right - I have changed this to:

   pos = positive-integer-value

/martin

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

---

From: Ladislav Lhotka <[email-masked]>
Date: Thu, 25 Feb 2016 11:05:41 +0100

>    pos = positive-integer-value

Actually, there is another problem: the ABNF allows, for example

/if:interfaces/if:interface[1][2]

which doesn't make sense. So a correct version could be

   instance-identifier = 1*("/" (node-identifier (*predicate / pos))

   predicate           = "[" *WSP predicate-expr *WSP "]"

   pos                 = "[" *WSP positive-integer-value *WSP "]"

Lada

---

From: Martin Bjorklund <[email-masked]>
Date: Thu, 25 Feb 2016 14:16:36 +0100 (CET)

Ladislav Lhotka <[email-masked]> wrote:
> which doesn't make sense.

Yes, you're right.

> So a correct version could be
> 

this would make pos mandatory after every node-identifier.  It should
be: 

  instance-identifier = 1*("/" (node-identifier (*predicate / *1pos)))

or, in order to match the style in the rest of the grammar:

  instance-identifier = 1*("/" (node-identifier [1*predicate / pos]))

/martin

---

From: Ladislav Lhotka <[email-masked]>
Date: Thu, 25 Feb 2016 14:27:58 +0100

> On 25 Feb 2016, at 14:16, Martin Bjorklund <[email-masked]> wrote:
> 

OK, agreed.

Lada

---

From: Ladislav Lhotka <[email-masked]>
Date: Thu, 25 Feb 2016 14:45:40 +0100

>  instance-identifier = 1*("/" (node-identifier [1*predicate / pos]))

If we want to be really precise, then the predicate for a leaf-list [ . = 'foo'] can also appear no more than once.

Lada

---

From: Martin Bjorklund <[email-masked]>
Date: Thu, 25 Feb 2016 14:51:02 +0100 (CET)

Ladislav Lhotka <[email-masked]> wrote:
> If we want to be really precise, then the predicate for a leaf-list [
> . = 'foo'] can also appear no more than once.

Correct.  But we can only do so much in the grammar... For example, we
cannot verify that the name and number of keys are correct.

It would be:

instance-identifier = 1*("/" (node-identifier [1*key-predicate /
                                               leaf-list-predicate /
                                               pos]))

key-predicate       = "[" *WSP key-predicate-expr *WSP "]"

key-predicate-expr  = node-identifier *WSP "=" *WSP
                      ((DQUOTE string DQUOTE) /
                       (SQUOTE string SQUOTE))

leaf-list-predicate = "[" *WSP leaf-list-predicate-expr *WSP "]"

leaf-list-predicate-expr = "." *WSP "=" *WSP
                      ((DQUOTE string DQUOTE) /
                       (SQUOTE string SQUOTE))

/martin

---

From: Ladislav Lhotka <[email-masked]>
Date: Thu, 25 Feb 2016 15:01:14 +0100

> On 25 Feb 2016, at 14:51, Martin Bjorklund <[email-masked]> wrote:
> 

Yes, but these are already semantic constraints. I think the new productions below are in fact easier to comprehend. Perhaps a production like

quoted-string = (DQUOTE string DQUOTE) / (SQUOTE string SQUOTE)

would also be an improvement.

Lada

---

From: Martin Bjorklund <[email-masked]>
Date: Thu, 25 Feb 2016 16:10:02 +0100 (CET)

Hi,

Here's a summary of the changes:

OLD:

   instance-identifier = 1*("/" (node-identifier *predicate))

NEW:

   instance-identifier = 1*("/" (node-identifier
                                 [1*key-predicate /
                                  leaf-list-predicate /
                                  pos]))

   key-predicate-expr  = node-identifier *WSP "=" *WSP quoted-string

   leaf-list-predicate-expr = "." *WSP "=" *WSP quoted-string

/martin

---

From: Ladislav Lhotka <[email-masked]>
Date: Thu, 25 Feb 2016 16:34:28 +0100

> On 25 Feb 2016, at 16:10, Martin Bjorklund <[email-masked]> wrote:
> 
> Hi,
> 

Looks great!

Thanks, Lada