* Fixed: [xpath // abbreviation does not work other than on the top-level](https://github.com/clicon/clixon/issues/435)

This commit is contained in:
Olof hagsand 2023-06-21 11:45:49 +02:00
parent 0460c093cc
commit 79d1d2e95a
3 changed files with 24 additions and 5 deletions

View file

@ -75,6 +75,7 @@ Developers may need to change their code
### Corrected Bugs
* Fixed: [xpath // abbreviation does not work other than on the top-level](https://github.com/clicon/clixon/issues/435)
* Fixed: [if-feature always negative if imported from another module](https://github.com/clicon/clixon/issues/429)
* Fixed autocli edit modes for schema mounts

View file

@ -1287,8 +1287,12 @@ xp_eval(xp_ctx *xc,
break;
case XP_RELLOCPATH:
use_xr0++;
if (xs->xs_int == A_DESCENDANT_OR_SELF)
if (xs->xs_int == A_DESCENDANT_OR_SELF){
if (use_xr0)
xr0->xc_descendant = 1; /* XXX need to set to 0 in sub */
else
xc->xc_descendant = 1; /* XXX need to set to 0 in sub */
}
break;
case XP_NODE:
break;
@ -1347,6 +1351,9 @@ xp_eval(xp_ctx *xc,
break;
}
}
if (use_xr0)
xr0->xc_descendant = 0;
else
xc->xc_descendant = 0;
if (xr0 == NULL && xr1 == NULL && xr2 == NULL){
clicon_err(OE_XML, EFAULT, "Internal error: no result produced");

View file

@ -176,8 +176,19 @@ new "xpath /aaa/bbb union "
expectpart "$($clixon_util_xpath -D $DBG -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"
expectpart "$($clixon_util_xpath -D $DBG -f $xml -p //bbb)" 0 "0:<bbb x=\"hello\"><ccc>42</ccc></bbb>
1:<bbb x=\"bye\"><ccc>99</ccc></bbb>"
expectpart "$($clixon_util_xpath -D $DBG -f $xml -p //bbb)" 0 "0:<bbb x=\"hello\"><ccc>42</ccc></bbb>" "1:<bbb x=\"bye\"><ccc>99</ccc></bbb>"
new "xpath //ccc"
expectpart "$($clixon_util_xpath -D $DBG -f $xml -p //ccc)" 0 "0:<ccc>42</ccc>" "1:<ccc>99</ccc>" "2:<ccc>22</ccc>"
new "xpath /descendant-or-self::node()/ccc"
expectpart "$($clixon_util_xpath -D $DBG -f $xml -p /descendant-or-self::node\(\)/ccc)" 0 "0:<ccc>42</ccc>" "1:<ccc>99</ccc>" "2:<ccc>22</ccc>"
new "xpath /aaa//ccc"
expectpart "$($clixon_util_xpath -D $DBG -f $xml -p /aaa//ccc)" 0 "0:<ccc>42</ccc>" "1:<ccc>99</ccc>" "2:<ccc>22</ccc>"
new "xpath /aaa/descendant-or-self::node()/ccc"
expectpart "$($clixon_util_xpath -D $DBG -f $xml -p /aaa/descendant-or-self::node\(\)/ccc)" 0 "0:<ccc>42</ccc>" "1:<ccc>99</ccc>" "2:<ccc>22</ccc>"
new "xpath //b?b"
#expecteof "$clixon_util_xpath -D $DBG -f $xml" 0 "//b?b" ""