@@ -370,7 +370,12 @@ ly_ctx_new_yl_legacy(struct ly_ctx *ctx, const struct lyd_node *yltree)
370370 LY_ERR ret = LY_SUCCESS ;
371371 uint32_t i , j ;
372372
373- LY_CHECK_RET (ret = lyd_find_xpath (yltree , "/ietf-yang-library:yang-library/modules-state/module" , & set ));
373+ LY_CHECK_RET (ret = lyd_find_xpath (yltree , "modules-state/module" , & set ));
374+
375+ if (!set -> count ) {
376+ ret = LY_ENOTFOUND ;
377+ goto cleanup ;
378+ }
374379
375380 /* process the data tree */
376381 for (i = 0 ; i < set -> count ; ++ i ) {
@@ -489,7 +494,7 @@ ly_ctx_new_yldata(const char *search_dir, const struct lyd_node *tree, int optio
489494 ly_bool no_expl_compile = 0 ;
490495 uint32_t i , j ;
491496
492- LY_CHECK_ARG_RET (NULL , tree , ctx , LY_EINVAL );
497+ LY_CHECK_ARG_RET (NULL , tree , ! strcmp ( LYD_NAME ( tree ), "yang-library" ), ctx , LY_EINVAL );
493498
494499 /* create a new context */
495500 if (* ctx == NULL ) {
@@ -504,7 +509,7 @@ ly_ctx_new_yldata(const char *search_dir, const struct lyd_node *tree, int optio
504509 no_expl_compile = 1 ;
505510 }
506511
507- LY_CHECK_GOTO (ret = lyd_find_xpath (tree , "/ietf-yang-library:yang-library/ module-set[1]/module" , & set ), cleanup );
512+ LY_CHECK_GOTO (ret = lyd_find_xpath (tree , "module-set[1]/module" , & set ), cleanup );
508513 if (set -> count == 0 ) {
509514 /* perhaps a legacy data tree? */
510515 LY_CHECK_GOTO (ret = ly_ctx_new_yl_legacy (ctx_new , tree ), cleanup );
0 commit comments