Skip to content

Commit 1512332

Browse files
committed
xpath CHANGE count function accepts leaf-list or nodes with list parents nodes
1 parent 3439808 commit 1512332

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/xpath.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3012,15 +3012,19 @@ static int
30123012
xpath_count(struct lyxp_set **args, uint16_t UNUSED(arg_count), struct lyd_node *UNUSED(cur_node),
30133013
struct lys_module *UNUSED(local_mod), struct lyxp_set *set, int options)
30143014
{
3015-
struct lys_node *snode;
3015+
struct lys_node *snode, *sparent;
30163016
int ret = EXIT_SUCCESS;
30173017

30183018
if (options & LYXP_SNODE_ALL) {
30193019
if ((args[0]->type != LYXP_SET_SNODE_SET) || !(snode = warn_get_snode_in_ctx(args[0]))) {
30203020
LOGWRN("Argument #1 of %s not a node-set as expected.", __func__);
30213021
ret = EXIT_FAILURE;
3022-
} else if (!(snode->nodetype & (LYS_LIST | LYS_LEAFLIST))) {
3023-
LOGWRN("Argument #1 of %s is a %s node \"%s\".", __func__, strnodetype(snode->nodetype), snode->name);
3022+
}
3023+
3024+
for (sparent = snode; sparent && !(sparent->nodetype & (LYS_LIST | LYS_LEAFLIST)); sparent = lys_parent(sparent));
3025+
if (!sparent) {
3026+
LOGWRN("Argument #1 of %s is a %s node \"%s\" without a list node parent.",
3027+
__func__, strnodetype(snode->nodetype), snode->name);
30243028
ret = EXIT_FAILURE;
30253029
}
30263030
set_snode_clear_ctx(set);

0 commit comments

Comments
 (0)