Subject: [netmod] default namespace in XPath

From: Ladislav Lhotka <[email-masked]>
Date: Thu, 24 Nov 2016 10:14:04 +0100

Hi,

second bullet in sec. 6.4.1 of RFC 7950 says:

    Names without a namespace prefix belong to the same namespace as the identifier of the current node.

But what is the current node? Is it the same as the result of the current() function or, if we have

    "/x:foo/bar"

is the namespace of "bar" the one corresponding to prefix "x"?

Lada

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

---

From: wangzitao <[email-masked]>
Date: Thu, 24 Nov 2016 09:33:41 +0000

Hi Lada,

In my understanding, it means to equal to current module's prefix. 
For example: 

module ietf-foo {
     namespace "urn:ietf:params:xml:ns:yang:ietf-foo";
     prefix foo;
	
	import ietf-interfaces {
    prefix if;
    }
	
    .....

	 augment "/if:interfaces/if:interface"{
	  list A{
	   key "a";
	   leaf a{
	    type string;
	   }
	  }
	 }
	 
	 list B{
	  key "b";
	  leaf b{
	   type leafref{
	    path "/if:interfaces/if:interface/A/a";
	   }
	  }
	 }
	 
}

In above example, the path "/if:interfaces/if:interface/A/a" equal to "/if:interfaces/if:interface/foo:A/foo:a".

BR!
-Michael

-----邮件原件-----
发件人: netmod [mailto:[email-masked]] 代表 Ladislav Lhotka
发送时间: 2016年11月24日 17:14
收件人: NETMOD WG
主题: [netmod] default namespace in XPath

Hi,

    "/x:foo/bar"

Lada

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

---

From: Ladislav Lhotka <[email-masked]>
Date: Thu, 24 Nov 2016 10:39:35 +0100

> On 24 Nov 2016, at 10:33, wangzitao <[email-masked]> wrote:
> 
> Hi Lada,
> 

No, it is not, because if the expression appears inside a grouping, then the next sentence of the same bullet says "that namespace is affected by where the grouping is used".

Lada

---

From: "Jernej Tuljak" <[email-masked]>
Date: Thu, 24 Nov 2016 11:03:40 +0100

> -----Original Message-----
> From: netmod [mailto:[email-masked]] On Behalf Of Ladislav
> Lhotka
> Sent: Thursday, November 24, 2016 10:14 AM
> To: NETMOD WG <[email-masked]>
> Subject: [netmod] default namespace in XPath
> 
> Hi,
> 

I read it as the result of current(). It doesn't say "current XPath context _node set_".
 
Jernej

---

From: wangzitao <[email-masked]>
Date: Thu, 24 Nov 2016 10:05:10 +0000

Hi Lada,

Look at below examples, 

module ietf-test {
   namespace "urn:ietf:params:xml:ns:yang:ietf-test";
   prefix itest;
	
	import ietf-interfaces {
    prefix if;
    }

	 grouping B{
	 
}

module ietf-foo {
	
	import ietf-test{
	prefix itest;
	}
		 
    container C{
	 uses itest:B;
	}
	 
}

when I run the "ietf-foo" module, the "current module's prefix" is "foo" and I receive a error report： .\ietf-test.yang:32: error: ietf-foo:A in the path for b at ietf-foo.yang:23 (at
 .\ietf-test.yang:30) is not found.
I believe it means, the path "/if:interfaces/if:interface/A/a" in module "ietf-foo" is equal to "/if:interfaces/if:interface/foo:A/foo:a"

-Michael

-----邮件原件-----
发件人: Ladislav Lhotka [mailto:[email-masked]] 
发送时间: 2016年11月24日 17:40
收件人: wangzitao
抄送: NETMOD WG
主题: Re: [netmod] default namespace in XPath

Lada

---

From: Ladislav Lhotka <[email-masked]>
Date: Thu, 24 Nov 2016 11:51:49 +0100

> On 24 Nov 2016, at 11:03, Jernej Tuljak <[email-masked]> wrote:
> 

Yes, that's my interpretation, too, so the text should say "initial context node" rather than "current node". But even then I don't know how to handle a choice that appears at the top level of a module, for example

    choice foo {
        when "/bar";
        ...
    }

In this case the initial context node for the XPtah is the root node that, according to XPath 1.0, has no expanded-name, i.e. no namespace either. So there is no default namespace to assign to "bar".

Lada

---

From: Ladislav Lhotka <[email-masked]>
Date: Thu, 24 Nov 2016 12:52:25 +0100

> On 24 Nov 2016, at 11:05, wangzitao <[email-masked]> wrote:
> 
> Hi Lada,
> 
> Look at below examples, 
> 
> module ietf-test {
> when I run the "ietf-foo" module, the "current module's prefix" is "foo" and I receive a error report： .\ietf-test.yang:32: error:ietf-foo:A in the path for b at ietf-foo.yang:23 (at

OK, so how do you define "current module"?

Lada

---

From: "Jernej Tuljak" <[email-masked]>
Date: Thu, 24 Nov 2016 14:46:23 +0100

> From: Ladislav Lhotka [mailto:[email-masked]]
> Sent: Thursday, November 24, 2016 11:52 AM
> To: Jernej Tuljak <[email-masked]>
> Cc: NETMOD WG <[email-masked]>
> Subject: Re: [netmod] default namespace in XPath
> 
> 
> >>    Names without a namespace prefix belong to the same namespace as
> the
> >> identifier of the current node.
> >>
> Yes, that's my interpretation, too, so the text should say "initial context
> node" rather than "current node". 

I agree.

> But even then I don't know how to handle
> a choice that appears at the top level of a module, for example
> 
>     choice foo {
>         when "/bar";
>         ...
>     }
> 
> In this case the initial context node for the XPtah is the root node that,
> according to XPath 1.0, has no expanded-name, i.e. no namespace either. So
> there is no default namespace to assign to "bar".

Good catch. There should be an errata for this. I don't think there's a simple fix though.

Jernej

---

From: Ladislav Lhotka <[email-masked]>
Date: Thu, 24 Nov 2016 16:28:23 +0100

> On 24 Nov 2016, at 14:46, Jernej Tuljak <[email-masked]> wrote:
> 

A prudent fix would be to get rid of this default namespace altogether, as it also makes namespace resolution so damn difficult.

Fast rewind right after IETF 72:

https://mailarchive.ietf.org/arch/msg/netmod/_l3t_HLcC0is2KXiYhBAgfSnxK4

So here we go, that guy Mikko had a point.

Lada