* Fixed union in XPATH [XPATH issues #219](https://github.com/clicon/clixon/issues/219)
This commit is contained in:
parent
783b0a4857
commit
5baf8642ea
8 changed files with 25 additions and 9 deletions
|
|
@ -65,6 +65,7 @@ Users may have to change how they access the system
|
||||||
|
|
||||||
### Corrected Bugs
|
### Corrected Bugs
|
||||||
|
|
||||||
|
* Fix Union in xpath [XPATH issues #219](https://github.com/clicon/clixon/issues/219)
|
||||||
* Fix: XPath:s used in netconf (eg get-config) did not correctly access default values
|
* Fix: XPath:s used in netconf (eg get-config) did not correctly access default values
|
||||||
* [RESTCONF GET request of single-key list with empty string returns all elements #213](https://github.com/clicon/clixon/issues/213)
|
* [RESTCONF GET request of single-key list with empty string returns all elements #213](https://github.com/clicon/clixon/issues/213)
|
||||||
* [RESTCONF GETof lists with empty string keys does not work #214](https://github.com/clicon/clixon/issues/214)
|
* [RESTCONF GETof lists with empty string keys does not work #214](https://github.com/clicon/clixon/issues/214)
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,6 @@ cli_expand_var_generate(clicon_handle h,
|
||||||
retval = 1;
|
retval = 1;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yang2api_path_fmt(ys, 1, &api_path_fmt) < 0)
|
if (yang2api_path_fmt(ys, 1, &api_path_fmt) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
cprintf(cb, "|<%s:%s", yang_argument_get(ys),
|
cprintf(cb, "|<%s:%s", yang_argument_get(ys),
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ discard("Discard edits (rollback 0)"), discard_changes();
|
||||||
compare("Compare running and candidate"), compare_dbs((int32)1);
|
compare("Compare running and candidate"), compare_dbs((int32)1);
|
||||||
|
|
||||||
show("Show a particular state of the system"){
|
show("Show a particular state of the system"){
|
||||||
|
auto("Show expand") @datamodel, cli_show_auto("candidate", "xml");
|
||||||
xpath("Show configuration") <xpath:string>("XPATH expression") <ns:string>("Namespace"), show_conf_xpath("candidate");
|
xpath("Show configuration") <xpath:string>("XPATH expression") <ns:string>("Namespace"), show_conf_xpath("candidate");
|
||||||
version("Show version"), cli_show_version("candidate", "text", "/");
|
version("Show version"), cli_show_version("candidate", "text", "/");
|
||||||
options("Show clixon options"), cli_show_options();
|
options("Show clixon options"), cli_show_options();
|
||||||
|
|
|
||||||
|
|
@ -488,10 +488,10 @@ text_modify(clicon_handle h,
|
||||||
|
|
||||||
/* If origin body has namespace definitions, copy them. The reason is that
|
/* If origin body has namespace definitions, copy them. The reason is that
|
||||||
* some bodies rely on namespace prefixes, such as NACM path, but there is
|
* some bodies rely on namespace prefixes, such as NACM path, but there is
|
||||||
* no way we can now this here.
|
* no way we can know this here.
|
||||||
* However, this may lead to namespace collisions if these prefixes are not
|
* However, this may lead to namespace collisions if these prefixes are not
|
||||||
* canonical, and may collide with the assign_namespace_element() above (but that
|
* canonical, and may collide with the assign_namespace_element() above (but that
|
||||||
* is for element sysmbols)
|
* is for element symbols)
|
||||||
* Oh well.
|
* Oh well.
|
||||||
*/
|
*/
|
||||||
if (assign_namespace_body(x1, x1bstr, x0) < 0)
|
if (assign_namespace_body(x1, x1bstr, x0) < 0)
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,14 @@
|
||||||
|
|
||||||
* Clixon XML XPATH 1.0 according to https://www.w3.org/TR/xpath-10
|
* Clixon XML XPATH 1.0 according to https://www.w3.org/TR/xpath-10
|
||||||
*
|
*
|
||||||
|
* Note on xcur parameter to most xpath functions:
|
||||||
|
* The W3 standard defines the document root / element as the top-level.
|
||||||
|
* In the clixon xpath API, the document root is defined as the top of the xml tree.
|
||||||
|
* The xcur argument of xpath_first and others is the "current" xml node (xcur) which can
|
||||||
|
* be any node in that tree, not necessarily the document root.
|
||||||
|
* This is convenient if you want to use relative xpaths from any location in the tree (eg ../../foo/bar).
|
||||||
|
* It may be confusing if you expect xcur to be the root node.
|
||||||
|
*
|
||||||
* Some notes on namespace extensions in Netconf/Yang
|
* Some notes on namespace extensions in Netconf/Yang
|
||||||
* 1) The xpath is not "namespace-aware" in the sense that if you look for a path, eg
|
* 1) The xpath is not "namespace-aware" in the sense that if you look for a path, eg
|
||||||
* "n:a/n:b", those must match the XML, so they need to match prefixes AND name in the xml
|
* "n:a/n:b", those must match the XML, so they need to match prefixes AND name in the xml
|
||||||
|
|
|
||||||
|
|
@ -387,7 +387,7 @@ addexpr : addexpr ADDOP unionexpr { $$=xp_new(XP_ADD,$2,NULL,NULL,NULL,$1, $
|
||||||
;
|
;
|
||||||
|
|
||||||
/* node-set */
|
/* node-set */
|
||||||
unionexpr : unionexpr '|' pathexpr { $$=xp_new(XP_UNION,A_NAN,NULL,NULL,NULL,$1, $3);clicon_debug(3,"unionexpr-> unionexpr | pathexpr"); }
|
unionexpr : unionexpr '|' pathexpr { $$=xp_new(XP_UNION,XO_UNION,NULL,NULL,NULL,$1, $3);clicon_debug(3,"unionexpr-> unionexpr | pathexpr"); }
|
||||||
| pathexpr { $$=xp_new(XP_UNION,A_NAN,NULL,NULL,NULL,$1, NULL);clicon_debug(3,"unionexpr-> pathexpr"); }
|
| pathexpr { $$=xp_new(XP_UNION,A_NAN,NULL,NULL,NULL,$1, NULL);clicon_debug(3,"unionexpr-> pathexpr"); }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,10 @@ expectpart "$($clixon_cli -1 -f $cfg show conf xml)" 0 "^<interfaces xmlns=\"htt
|
||||||
new "cli set interfaces interface <tab> complete: e"
|
new "cli set interfaces interface <tab> complete: e"
|
||||||
expectpart "$(echo "set interfaces interface " | $clixon_cli -f $cfg)" 0 "interface e"
|
expectpart "$(echo "set interfaces interface " | $clixon_cli -f $cfg)" 0 "interface e"
|
||||||
|
|
||||||
|
# XXX See https://github.com/clicon/clixon/issues/218
|
||||||
|
#new "cli set interfaces interface e <tab> complete: not ethernet"
|
||||||
|
#expectpart "$(echo "set interfaces interface e " | $clixon_cli -f $cfg)" 0 config hold-time subinterfaces --not-- ethernet
|
||||||
|
|
||||||
if [ $BE -ne 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
new "Kill backend"
|
new "Kill backend"
|
||||||
# Check if premature kill
|
# Check if premature kill
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,9 @@ new "xpath /aaa/bbb"
|
||||||
expecteof "$clixon_util_xpath -f $xml -p /aaa/bbb" 0 "" "^0:<bbb x=\"hello\"><ccc>42</ccc></bbb>
|
expecteof "$clixon_util_xpath -f $xml -p /aaa/bbb" 0 "" "^0:<bbb x=\"hello\"><ccc>42</ccc></bbb>
|
||||||
1:<bbb x=\"bye\"><ccc>99</ccc></bbb>$"
|
1:<bbb x=\"bye\"><ccc>99</ccc></bbb>$"
|
||||||
|
|
||||||
|
new "xpath /aaa/bbb union "
|
||||||
|
expecteof "$clixon_util_xpath -f $xml -p aaa/bbb[ccc=42]|aaa/ddd[ccc=22]" 0 "" '^nodeset:0:<bbb x="hello"><ccc>42</ccc></bbb>1:<ddd><ccc>22</ccc></ddd>$'
|
||||||
|
|
||||||
new "xpath //bbb"
|
new "xpath //bbb"
|
||||||
expecteof "$clixon_util_xpath -f $xml -p //bbb" 0 "" "0:<bbb x=\"hello\"><ccc>42</ccc></bbb>
|
expecteof "$clixon_util_xpath -f $xml -p //bbb" 0 "" "0:<bbb x=\"hello\"><ccc>42</ccc></bbb>
|
||||||
1:<bbb x=\"bye\"><ccc>99</ccc></bbb>"
|
1:<bbb x=\"bye\"><ccc>99</ccc></bbb>"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue