Re: [netmod] default namespace in XPath
On Wed, 2018-03-07 at 14:06 +0100, Martin Bjorklund wrote: > Ladislav Lhotkawrote: > > Hi, > > > > sec. 6.4.1 in RFC 7950 says in the second bullet item: > > > > Names without a namespace prefix belong to the same namespace as > > the identifier of the current node. > > > > It is unclear what "current node" means: > > > > 1. Is it the context node of the XPath expression, or > > > > 2. is it the schema node corresponding to the parent statement of the > must/when > > statement? > > > > For example: > > > > module example-4-a { > > ... > > container bag { > > ... > > } > > } > > > > module example-4-b { > > ... > > import example-4-a { > > prefix "ex4a"; > > } > > > > augment "/ex4a:bag" { > > when "/quux = 0"; > > ... > > } > > } > > ... > > } > > > > What is the namespace of "quux" in the when expression? Is it "example-4-a" > > (option 1 above) or "example-4-b" (option 2)? > > Just like with all other unprefixed items (except in a > grouping/typedef), it is supposed to default to the prefix of the > module where it is defined (lexical scope). So it is supposed to be > "example-4-b". I agree that the term "current node" is misleading. But then you cannot refer to XPath 2.0 as being the model for this default namespace concept because in-scope namespaces defined in XPath 2.0 are bound to element (XPath) nodes. Lada > > > > > /martin -- Ladislav Lhotka Head, CZ.NIC Labs PGP Key ID: 0xB8F92B08A9F76C67 ___ netmod mailing list netmod@ietf.org https://www.ietf.org/mailman/listinfo/netmod
Re: [netmod] default namespace in XPath
Ladislav Lhotkawrote: > Hi, > > sec. 6.4.1 in RFC 7950 says in the second bullet item: > > Names without a namespace prefix belong to the same namespace as > the identifier of the current node. > > It is unclear what "current node" means: > > 1. Is it the context node of the XPath expression, or > > 2. is it the schema node corresponding to the parent statement of the > must/when > statement? > > For example: > > module example-4-a { > ... > container bag { > ... > } > } > > module example-4-b { > ... > import example-4-a { > prefix "ex4a"; > } > > augment "/ex4a:bag" { > when "/quux = 0"; > ... > } > } > ... > } > > What is the namespace of "quux" in the when expression? Is it "example-4-a" > (option 1 above) or "example-4-b" (option 2)? Just like with all other unprefixed items (except in a grouping/typedef), it is supposed to default to the prefix of the module where it is defined (lexical scope). So it is supposed to be "example-4-b". I agree that the term "current node" is misleading. /martin ___ netmod mailing list netmod@ietf.org https://www.ietf.org/mailman/listinfo/netmod
Re: [netmod] default namespace in XPath
Hi Michal, On Wed, 2018-03-07 at 10:18 +0100, Michal Vaško wrote: > Hello, > we have implemented it as option 1 based on the "current()" function Right, I have the same in my implementation. It is however counter-intuitive in cases like my example because unprefixed names normally receive the namespace of the module where they appear (I made a mistake myself:-). > definition (RFC 7950 sec. 10.1.1): > > The current() function takes no input parameters and returns a node >set with the initial context node as its only member. > > If this was not intended and actually option 2 is correct, the "current()" > function should probably be renamed or return a different node to be > consistent and not misleading. IMO the current() function should stay, but the text in sec. 6.4.1 has to be changed: OLD Names without a namespace prefix belong to the same namespace as the identifier of the current node. NEW Names without a namespace prefix belong to the same namespace as the identifier of the context node. If there are no objections, I will file an erratum. Lada > > Regards, > Michal > > On Wednesday, March 7, 2018 10:11 CET, Ladislav Lhotkawrote: > > > Hi, > > > > sec. 6.4.1 in RFC 7950 says in the second bullet item: > > > > Names without a namespace prefix belong to the same namespace as > > the identifier of the current node. > > > > It is unclear what "current node" means: > > > > 1. Is it the context node of the XPath expression, or > > > > 2. is it the schema node corresponding to the parent statement of the > > must/when > > statement? > > > > For example: > > > > module example-4-a { > > ... > > container bag { > > ... > > } > > } > > > > module example-4-b { > > ... > > import example-4-a { > > prefix "ex4a"; > > } > > > > augment "/ex4a:bag" { > > when "/quux = 0"; > > ... > > } > > } > > ... > > } > > > > What is the namespace of "quux" in the when expression? Is it "example-4-a" > > (option 1 above) or "example-4-b" (option 2)? > > > > Thanks, Lada > > > > -- > > Ladislav Lhotka > > Head, CZ.NIC Labs > > PGP Key ID: 0xB8F92B08A9F76C67 > > > > ___ > > netmod mailing list > > netmod@ietf.org > > https://www.ietf.org/mailman/listinfo/netmod > > > > -- Ladislav Lhotka Head, CZ.NIC Labs PGP Key ID: 0xB8F92B08A9F76C67 ___ netmod mailing list netmod@ietf.org https://www.ietf.org/mailman/listinfo/netmod
[netmod] default namespace in XPath
Hi, sec. 6.4.1 in RFC 7950 says in the second bullet item: Names without a namespace prefix belong to the same namespace as the identifier of the current node. It is unclear what "current node" means: 1. Is it the context node of the XPath expression, or 2. is it the schema node corresponding to the parent statement of the must/when statement? For example: module example-4-a { ... container bag { ... } } module example-4-b { ... import example-4-a { prefix "ex4a"; } augment "/ex4a:bag" { when "/quux = 0"; ... } } ... } What is the namespace of "quux" in the when expression? Is it "example-4-a" (option 1 above) or "example-4-b" (option 2)? Thanks, Lada -- Ladislav Lhotka Head, CZ.NIC Labs PGP Key ID: 0xB8F92B08A9F76C67 ___ netmod mailing list netmod@ietf.org https://www.ietf.org/mailman/listinfo/netmod
Re: [netmod] default namespace in XPath
> On 24 Nov 2016, at 14:46, Jernej Tuljak <jernej.tul...@mg-soft.si> wrote: > >> -Original Message- >> From: Ladislav Lhotka [mailto:lho...@nic.cz] >> Sent: Thursday, November 24, 2016 11:52 AM >> To: Jernej Tuljak <jernej.tul...@mg-soft.si> >> Cc: NETMOD WG <netmod@ietf.org> >> Subject: Re: [netmod] default namespace in XPath >> >> >>> On 24 Nov 2016, at 11:03, Jernej Tuljak <jernej.tul...@mg-soft.si> wrote: >>> >>>> -Original Message- >>>> From: netmod [mailto:netmod-boun...@ietf.org] On Behalf Of Ladislav >>>> Lhotka >>>> Sent: Thursday, November 24, 2016 10:14 AM >>>> To: NETMOD WG <netmod@ietf.org> >>>> Subject: [netmod] default namespace in XPath >>>> >>>> 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 >>> >>> I read it as the result of current(). It doesn't say "current XPath context >> _node set_". >> >> 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. 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 > > Jernej > >> >> Lada >> >>> >>> Jernej >>> >>>> >>>> "/x:foo/bar" >>>> >>>> is the namespace of "bar" the one corresponding to prefix "x"? >>>> >>>> Lada >>>> >>>> -- >>>> Ladislav Lhotka, CZ.NIC Labs >>>> PGP Key ID: E74E8C0C >>>> >>>> >>>> >>>> >>>> ___ >>>> netmod mailing list >>>> netmod@ietf.org >>>> https://www.ietf.org/mailman/listinfo/netmod >>> >> >> -- >> Ladislav Lhotka, CZ.NIC Labs >> PGP Key ID: E74E8C0C -- Ladislav Lhotka, CZ.NIC Labs PGP Key ID: E74E8C0C ___ netmod mailing list netmod@ietf.org https://www.ietf.org/mailman/listinfo/netmod
Re: [netmod] default namespace in XPath
> -Original Message- > From: Ladislav Lhotka [mailto:lho...@nic.cz] > Sent: Thursday, November 24, 2016 11:52 AM > To: Jernej Tuljak <jernej.tul...@mg-soft.si> > Cc: NETMOD WG <netmod@ietf.org> > Subject: Re: [netmod] default namespace in XPath > > > > On 24 Nov 2016, at 11:03, Jernej Tuljak <jernej.tul...@mg-soft.si> wrote: > > > >> -Original Message- > >> From: netmod [mailto:netmod-boun...@ietf.org] On Behalf Of Ladislav > >> Lhotka > >> Sent: Thursday, November 24, 2016 10:14 AM > >> To: NETMOD WG <netmod@ietf.org> > >> Subject: [netmod] default namespace in XPath > >> > >> 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 > > > > I read it as the result of current(). It doesn't say "current XPath context > _node set_". > > 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 > > Lada > > > > > Jernej > > > >> > >>"/x:foo/bar" > >> > >> is the namespace of "bar" the one corresponding to prefix "x"? > >> > >> Lada > >> > >> -- > >> Ladislav Lhotka, CZ.NIC Labs > >> PGP Key ID: E74E8C0C > >> > >> > >> > >> > >> ___ > >> netmod mailing list > >> netmod@ietf.org > >> https://www.ietf.org/mailman/listinfo/netmod > > > > -- > Ladislav Lhotka, CZ.NIC Labs > PGP Key ID: E74E8C0C > > > ___ netmod mailing list netmod@ietf.org https://www.ietf.org/mailman/listinfo/netmod
Re: [netmod] default namespace in XPath
> On 24 Nov 2016, at 11:05, wangzitao <wangzi...@huawei.com> wrote: > > 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; >} > > augment "/if:interfaces/if:interface"{ > list A{ > key "a"; > leaf a{ > type string; > } > } >} >grouping B{ > leaf b{ > type leafref{ > path "/if:interfaces/if:interface/A/a"; > } > } >} > > } > > module ietf-foo { > namespace "urn:ietf:params:xml:ns:yang:ietf-foo"; > prefix 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 OK, so how do you define "current module"? Lada > .\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:lho...@nic.cz] > 发送时间: 2016年11月24日 17:40 > 收件人: wangzitao > 抄送: NETMOD WG > 主题: Re: [netmod] default namespace in XPath > > >> On 24 Nov 2016, at 10:33, wangzitao <wangzi...@huawei.com> wrote: >> >> Hi Lada, >> >> In my understanding, it means to equal to current module's prefix. > > 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 > >> 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:netmod-boun...@ietf.org] 代表 Ladislav Lhotka >> 发送时间: 2016年11月24日 17:14 >> 收件人: NETMOD WG >> 主题: [netmod] default namespace in XPath >> >> 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 >> >> >> >> >> ___ >> netmod mailing list >> netmod@ietf.org >> https://www.ietf.org/mailman/listinfo/netmod > > -- > Ladislav Lhotka, CZ.NIC Labs > PGP Key ID: E74E8C0C > > > > -- Ladislav Lhotka, CZ.NIC Labs PGP Key ID: E74E8C0C ___ netmod mailing list netmod@ietf.org https://www.ietf.org/mailman/listinfo/netmod
Re: [netmod] default namespace in XPath
> On 24 Nov 2016, at 11:03, Jernej Tuljak <jernej.tul...@mg-soft.si> wrote: > >> -Original Message- >> From: netmod [mailto:netmod-boun...@ietf.org] On Behalf Of Ladislav >> Lhotka >> Sent: Thursday, November 24, 2016 10:14 AM >> To: NETMOD WG <netmod@ietf.org> >> Subject: [netmod] default namespace in XPath >> >> 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 > > I read it as the result of current(). It doesn't say "current XPath context > _node set_". 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 > > Jernej > >> >>"/x:foo/bar" >> >> is the namespace of "bar" the one corresponding to prefix "x"? >> >> Lada >> >> -- >> Ladislav Lhotka, CZ.NIC Labs >> PGP Key ID: E74E8C0C >> >> >> >> >> ___ >> netmod mailing list >> netmod@ietf.org >> https://www.ietf.org/mailman/listinfo/netmod > -- Ladislav Lhotka, CZ.NIC Labs PGP Key ID: E74E8C0C ___ netmod mailing list netmod@ietf.org https://www.ietf.org/mailman/listinfo/netmod
Re: [netmod] default namespace in XPath
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; } augment "/if:interfaces/if:interface"{ list A{ key "a"; leaf a{ type string; } } } grouping B{ leaf b{ type leafref{ path "/if:interfaces/if:interface/A/a"; } } } } module ietf-foo { namespace "urn:ietf:params:xml:ns:yang:ietf-foo"; prefix 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:lho...@nic.cz] 发送时间: 2016年11月24日 17:40 收件人: wangzitao 抄送: NETMOD WG 主题: Re: [netmod] default namespace in XPath > On 24 Nov 2016, at 10:33, wangzitao <wangzi...@huawei.com> wrote: > > Hi Lada, > > In my understanding, it means to equal to current module's prefix. 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 > 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:netmod-boun...@ietf.org] 代表 Ladislav Lhotka > 发送时间: 2016年11月24日 17:14 > 收件人: NETMOD WG > 主题: [netmod] default namespace in XPath > > 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 > > > > > ___ > netmod mailing list > netmod@ietf.org > https://www.ietf.org/mailman/listinfo/netmod -- Ladislav Lhotka, CZ.NIC Labs PGP Key ID: E74E8C0C ___ netmod mailing list netmod@ietf.org https://www.ietf.org/mailman/listinfo/netmod
Re: [netmod] default namespace in XPath
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:netmod-boun...@ietf.org] 代表 Ladislav Lhotka 发送时间: 2016年11月24日 17:14 收件人: NETMOD WG 主题: [netmod] default namespace in XPath 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 ___ netmod mailing list netmod@ietf.org https://www.ietf.org/mailman/listinfo/netmod ___ netmod mailing list netmod@ietf.org https://www.ietf.org/mailman/listinfo/netmod
[netmod] default namespace in XPath
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 ___ netmod mailing list netmod@ietf.org https://www.ietf.org/mailman/listinfo/netmod