* Fixed: [when condition error under augment in restconf #227](https://github.com/clicon/clixon/issues/227)

* As part of this fix added custom constant XML_PARENT_CANDIDATE
This commit is contained in:
Olof hagsand 2021-05-25 15:21:45 +02:00
parent 5b39418e92
commit 1ef7a280d7
8 changed files with 178 additions and 31 deletions

View file

@ -392,7 +392,12 @@ xp_eval_step(xp_ctx *xc0,
xc->xc_nodeset = NULL;
for (i=0; i<veclen; i++){
x = vec[i];
if ((xp = xml_parent(x)) != NULL)
if ((xp = xml_parent(x)) != NULL
#ifdef XML_PARENT_CANDIDATE
/* Also check "candidate" parent for special when use-case */
|| (xp = xml_parent_candidate(x)) != NULL
#endif /* XML_PARENT_CANDIDATE */
)
if (cxvec_append(xp, &xc->xc_nodeset, &xc->xc_size) < 0)
goto done;
}
@ -979,8 +984,13 @@ xp_eval(xp_ctx *xc,
case XP_ABSPATH:
/* Set context node to top node, and nodeset to that node only */
x = xc->xc_node;
#ifdef XML_PARENT_CANDIDATE
while (xml_parent(x) != NULL || xml_parent_candidate(x) != NULL)
x = xml_parent(x)?xml_parent(x):xml_parent_candidate(x);
#else
while (xml_parent(x) != NULL)
x = xml_parent(x);
#endif
xc->xc_node = x;
xc->xc_nodeset[0] = x;
xc->xc_size=1;