@@ -334,6 +334,7 @@ parse_data(const char *filepath, int options, struct lyd_node *val_tree, const c
334334 struct lyxml_elem * xml = NULL ;
335335 const struct lys_node * rpc_act = NULL ;
336336 struct lyd_node * data = NULL , * root , * next , * iter ;
337+ void * lydval_arg = NULL ;
337338
338339 /* detect input format according to file suffix */
339340 len = strlen (filepath );
@@ -366,18 +367,23 @@ parse_data(const char *filepath, int options, struct lyd_node *val_tree, const c
366367 if (!strcmp (xml -> name , "data" )) {
367368 fprintf (stdout , "Parsing %s as complete datastore.\n" , filepath );
368369 options = (options & ~LYD_OPT_TYPEMASK );
370+ lydval_arg = ctx ;
369371 } else if (!strcmp (xml -> name , "config" )) {
370372 fprintf (stdout , "Parsing %s as config data.\n" , filepath );
371373 options = (options & ~LYD_OPT_TYPEMASK ) | LYD_OPT_CONFIG ;
374+ lydval_arg = ctx ;
372375 } else if (!strcmp (xml -> name , "get-reply" )) {
373376 fprintf (stdout , "Parsing %s as <get> reply data.\n" , filepath );
374377 options = (options & ~LYD_OPT_TYPEMASK ) | LYD_OPT_GET ;
378+ lydval_arg = ctx ;
375379 } else if (!strcmp (xml -> name , "get-config-reply" )) {
376380 fprintf (stdout , "Parsing %s as <get-config> reply data.\n" , filepath );
377381 options = (options & ~LYD_OPT_TYPEMASK ) | LYD_OPT_GETCONFIG ;
382+ lydval_arg = ctx ;
378383 } else if (!strcmp (xml -> name , "edit-config" )) {
379384 fprintf (stdout , "Parsing %s as <edit-config> data.\n" , filepath );
380385 options = (options & ~LYD_OPT_TYPEMASK ) | LYD_OPT_EDIT ;
386+ lydval_arg = ctx ;
381387 } else if (!strcmp (xml -> name , "rpc" )) {
382388 fprintf (stdout , "Parsing %s as <rpc> data.\n" , filepath );
383389 options = (options & ~LYD_OPT_TYPEMASK ) | LYD_OPT_RPC ;
@@ -470,7 +476,7 @@ parse_data(const char *filepath, int options, struct lyd_node *val_tree, const c
470476 }
471477
472478 /* validate the result */
473- if (lyd_validate (& data , options , NULL )) {
479+ if (lyd_validate (& data , options , lydval_arg )) {
474480 fprintf (stderr , "Failed to parse data.\n" );
475481 lyd_free_withsiblings (data );
476482 return EXIT_FAILURE ;
0 commit comments