lyd_parse_op behavior
Hi,I'm running into some peculiar behavior about the leaf with identityref type while using lyd_parse_op() and I just want to check whether this is expected or not. My YANG model:
module test-1111 {
namespace "urn:test:params:xml:ns:yang:test-1111";
prefix tt-11;
identity basic-type {
description "The basic type";
}
identity current-type {
base basic-type;
description "The current type.";
}
rpc load-file {
input {
container loadfile {
list files {
key "name";
leaf name {
type string;
}
container file-parameters {
leaf type {
type identityref {
base basic-type ;
}
mandatory true ;
description "File type of load operation.";
}
}
}
}
}
}
}
I got three RPC Msgs: 1.
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="24">
<load-file xmlns="urn:test:params:xml:ns:yang:test-1111">
<loadfile>
<files>
<name>test</name>
<file-parameters>
<type>current-type</type>
</file-parameters>
</files>
</loadfile>
</load-file>
</rpc>
NO prefix both in tag and content, and lyd_parse_op returns successfully. 2.
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="24">
<tt-11:load-file xmlns:tt-11="urn:test:params:xml:ns:yang:test-1111">
<tt-11:loadfile>
<tt-11:files>
<tt-11:name>test</tt-11:name>
<tt-11:file-parameters>
<tt-11:type>tt-11:current-type</tt-11:type>
</tt-11:file-parameters>
</tt-11:files>
</tt-11:loadfile>
</tt-11:load-file>
</rpc>
Prefix both in tag and content, and lyd_parse_op returns successfully. 3.
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="24">
<tt-11:load-file
xmlns:tt-11="urn:test:params:xml:ns:yang:test-1111">
<tt-11:loadfile>
<tt-11:files>
<tt-11:name>test</tt-11:name>
<tt-11:file-parameters>
<tt-11:type>current-type</tt-11:type>
</tt-11:file-parameters>
</tt-11:files>
</tt-11:loadfile>
</tt-11:load-file>
</rpc>
It got prefix ONLY in tag and the content got no prefix, and lyd_parse_op returns as following: libyang[0]: Invalid identityref "current-type" value - identity not found in module "ietf-netconf". (path: Data location "/test-1111:load-file/loadfile/files[name='test']/file-parameters/type", line number 1.
So, I defined current-type in test-1111.yang,why it searches it in ietf-netconf module?,is there any bugs in lyd_parse_op or just RPC Msg 3 is illegal?
The XML namespaces are "inherited" from parent elements. In your first example, the <load-file xmlns="urn:huawei:params:xml:ns:yang:huawei-system-load"> statement overrides the default namespace, while your second and third examples only "assign" this namespace to the tt-11: prefix, and the empty prefix still refers to the xmlns="urn:ietf:params:xml:ns:netconf:base:1.0".
I would have to look up the YANG RFC to say whether these default/empty namespaces affect actual element values because that's surely out-of-scope for XML itself.
The XML namespaces are "inherited" from parent elements. In your first example, the
<load-file xmlns="urn:huawei:params:xml:ns:yang:huawei-system-load">statement overrides the default namespace, while your second and third examples only "assign" this namespace to thett-11:prefix, and the empty prefix still refers to thexmlns="urn:ietf:params:xml:ns:netconf:base:1.0".I would have to look up the YANG RFC to say whether these default/empty namespaces affect actual element values because that's surely out-of-scope for XML itself.
Sorry, I made a mistake, There is no huawei-system-load in xmlns.It'a all test-1111, the module name that defines the identity.I'v modified the module and RPCs,Would you check it again?
It seems the default XML namespace is used for identityref values without prefixes. I am not exactly sure why we implemented it this way (probably seemed most XML-like) but I see no reason to change. You can try to write to the netmod mailing list to learn how it is supposed to be interpreted exactly, I could find no clear definition in the YANG RFC.
It seems the default XML namespace is used for identityref values without prefixes. I am not exactly sure why we implemented it this way (probably seemed most XML-like) but I see no reason to change. You can try to write to the
netmodmailing list to learn how it is supposed to be interpreted exactly, I could find no clear definition in the YANG RFC.
OK,Got it.Thanks for the comment.