Subject: [netmod] current() ABNF

From: Andy Bierman <[email-masked]>
Date: Wed, 05 Nov 2008 09:08:16 -0800

Hi,

The 'current-function-invocation' is specified as 'current()'.
Section 3.7 of XPath 1.0 states that an ExprWhitespace may
be freely added before and after any ExprToken.

Is this ABNF an oversight or intentional?
Aren't 'current( )' and 'current ( )' also valid?

Andy

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

---

From: Andy Bierman <[email-masked]>
Date: Wed, 05 Nov 2008 10:01:12 -0800

> Aren't 'current( )' and 'current ( )' also valid?

The path-stmt ABNF also contradicts the normative XPath 1.0
grammar because it does not allow whitespace between
operators (see rule [28]).

Andy

---

From: Martin Bjorklund <[email-masked]>
Date: Wed, 05 Nov 2008 20:53:59 +0100 (CET)

> > Aren't 'current( )' and 'current ( )' also valid?

It's an oversight - I just happily replaced "$this" with "current()".

> operators (see rule [28]).

Section 3.7 of the XPath spec says:

  For readability, whitespace may be used in expressions even though
  not explicitly allowed by the grammar: ExprWhitespace may be freely
  added within patterns before or after any ExprToken.

Which means that if we want to be as flexible, we need to add *WSP on
a few more places, e.g. to allow pretty expressions like:

   "..     /  .. / name"

/martin

---

From: Andy Bierman <[email-masked]>
Date: Wed, 05 Nov 2008 13:19:24 -0800

> a few more places, e.g. to allow pretty expressions like:

Deviating from XPath 1.0 is a delicate subject.
I suggest doing it only if there's a really good reason.
Parsers need to follow the 'longest token match' rule
anyway, e.g:

    foo-bar == an identifier 'foo-bar'
    foo -bar == string 'foo' minus string 'bar'
    foo - bar == string 'foo' minus string 'bar'
    foo- bar == 2 identifiers 'foo-' and 'bar'

Whitespace is significant, but the grammar is clear where
is can go.

Andy

---

From: Phil Shafer <[email-masked]>
Date: Wed, 05 Nov 2008 16:29:47 -0500

>I suggest doing it only if there's a really good reason.

Why not use the exact working from the xpath spec?

Thanks,
 Phil

---

From: Andy Bierman <[email-masked]>
Date: Wed, 05 Nov 2008 17:57:18 -0800

Hi,

I previously thought a keyref could have references
to the data model in it, but I was wrong.
The examples and ABNF say otherwise.

This is not allowed:

     leaf my-addr {
        type keyref {
           path "../../interface[name='eth0']/address/ip";
        }
     }

The example on pg 118 uses only objects and the ABNF syntax:

      container default-address {
          leaf ifname {
              type keyref {
                  path "../../interface/name";
              }
          }
          leaf address {
              type keyref {
                  path "../../interface[name = current()/../ifname]"
                     + "/address/ip";
              }
          }
      }

Note that:
   * the 'ifname' sibling of 'address' is needed
     to store the outer key 'name', as the address keyref is for
     the inner key 'ip'.
      * the following is invalid because the specific interface entry
        is not specified (there are N instances of 'name', not 1)

       leaf address {
           type keyref {
               path "../../interface[name = current()/../../interface/name]"
                  + "/address/ip";
           }
       }

   * the evaluation of 'address' is dependent on
     the value of 'ifname' at the time.
   * evaluation of address against the target config value of 'ifname'
     will be incorrect if the PDU value of 'ifname' is present
     and has a different value.  This evaluation order is not
     obvious, but no different requirement than (e.g.) deleting
     the particular '/interface/address' subtree in the same PDU

Questions:
   * Why is the 'constant-based predicate' (e.g. [name='eth0'])
     illegal? Are we sure there are never going to be use cases?
   * When is the current() function call actually needed?
     * It is needed in the predicate since the context node
       is 'interface' not 'address' (result of current() fn),
       but is it needed anywhere else?  Perhaps a clarification
       in the draft would help.

Andy