From b894c30bfb6fc74b2dfca46297eb1fd3e66ee092 Mon Sep 17 00:00:00 2001 From: Olof Hagsand Date: Fri, 20 Jul 2018 15:52:32 +0000 Subject: [PATCH] obsoleted xpath_each --- CHANGELOG.md | 50 ++++++++++++++++++++++------------------- lib/clixon/clixon_xsl.h | 3 ++- lib/src/clixon_xpath.c | 11 +++++++++ lib/src/clixon_xsl.c | 2 ++ 4 files changed, 42 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28c19d6b..44d6e9a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,36 +12,23 @@ * Example extended with inclusion of iana-if-type RFC 7224 interface identities * Applications which have not strictly enforced the identities may now have problems with validation and may need to be modified. +* Improved support for XPATH 1.0 according to https://www.w3.org/TR/xpath-10 using yacc/lex, see also API changes below. + ### API changes on existing features (you may need to change your code) * Conformance of restconf(RFC-8040) operations where prefix was used instead of module name. * Proper specification for an operation is POST /restconf/operations/: HTTP/1.1 * See https://github.com/clicon/clixon/issues/31, https://github.com/clicon/clixon/pull/32 and https://github.com/clicon/clixon/issues/30 * Thanks David Cornejo and Dmitry Vakhrushev of Netgate for pointing this out. +* New XPATH 1.0 leads to some API changes and corrections + * Due to an error in the previous implementation, all XPATH calls on the form `x[a=str]` where `str` is a string (not a number or XML symbol), must be changed to: `x[a='str'] or x[a="str"]` + * This includes all calls to `xpath_vec, xpath_first`, etc. + * In CLI specs, calls to cli_copy_config() must change 2nd argument from `x[%s=%s]` to `x[%s='%s']` + * In CLI specs, calls to cli_show_config() may need to change third argument, eg + * `cli_show_config("running","text","/profile[name=%s]","name")` to `cli_show_config("running","text","/profile[name='%s']","name")` + * xpath_each() is removed + * The old API can be enabled by setting COMPAT_XSL in include/clixon_custom.h and recompile. -* Improved support for XPATH 1.0 according to https://www.w3.org/TR/xpath-10 using yacc/lex - * NOTE: Due to an error in the previous implementation, all XPATH calls on the form `x[a=str]` where `str` is a string (not a number or XML symbol), must be changed to: `x[a='str'] or x[a="str"]` - * This includes all calls to `xpath_vec, xpath_first`, etc. - * All calls to cli_copy_config in CLI spec files must replace 2nd argument from `x[%s=%s]` to `x[%s='%s']` - * xpath_each() is removed - * The old API can be enabled by setting COMPAT_XSL in include/clixon_custom.h and recompile. - -### Minor changes - -* Added systemd example files under example/systemd -* Changed `plugin_init()` backend return semantics: If returns NULL, _without_ calling clicon_err(), the module is disabled. -* Added util subdir, with dedicated standalone xml,json,yang and xpath parser utility test programs. -* CDATA xml support (patch by David Cornejo, Netgate) - * Encode and decode (parsing) support -* Validation of yang bits type space-separated list value -* Added -U command line to clixon_cli and clixon_netconf for NACM pseudo-user tests -* Added a generated CLI show command that works on the generated parse tree with auto completion. - * A typical call is: show @datamodel:example, cli_show_auto("candidate", "json"); - * The example contains a more elaborate example. - * Thanks ngashok for request, see https://github.com/clicon/clixon/issues/24 -* Added xmlns validation - * for eg -* Added yang identityref runtime validation * Removed cli callback vector functions. Set COMPAT_CLIV if you need to keep these functions in include/clixon_custom.h. * Replace functions as follows in CLI SPEC files: * cli_setv --> cli_set @@ -63,6 +50,23 @@ * show_yangv --> show_yang * show_confv_xpath --> show_conf_xpath +### Minor changes + +* Added systemd example files under example/systemd +* Changed `plugin_init()` backend return semantics: If returns NULL, _without_ calling clicon_err(), the module is disabled. +* Added util subdir, with dedicated standalone xml,json,yang and xpath parser utility test programs. +* CDATA xml support (patch by David Cornejo, Netgate) + * Encode and decode (parsing) support +* Validation of yang bits type space-separated list value +* Added -U command line to clixon_cli and clixon_netconf for NACM pseudo-user tests +* Added a generated CLI show command that works on the generated parse tree with auto completion. + * A typical call is: show @datamodel:example, cli_show_auto("candidate", "json"); + * The example contains a more elaborate example. + * Thanks ngashok for request, see https://github.com/clicon/clixon/issues/24 +* Added xmlns validation + * for eg +* Added yang identityref runtime validation + * Added --enable-debug. * Added cligen variable translation. * See FAQ and example diff --git a/lib/clixon/clixon_xsl.h b/lib/clixon/clixon_xsl.h index 5f470fef..5d572528 100644 --- a/lib/clixon/clixon_xsl.h +++ b/lib/clixon/clixon_xsl.h @@ -43,7 +43,8 @@ int xpath_vec_xsl(cxobj *cxtop, char *xpath, cxobj ***vec, size_t *veclen); int xpath_vec_flag_xsl(cxobj *cxtop, char *xpath, uint16_t flags, cxobj ***vec, size_t *veclen); cxobj *xpath_first_xsl(cxobj *cxtop, char *xpath); +#ifdef COMPAT_XSL cxobj *xpath_each(cxobj *xn_top, char *xpath, cxobj *prev); - +#endif #endif /* _CLIXON_XSL_H */ diff --git a/lib/src/clixon_xpath.c b/lib/src/clixon_xpath.c index 0f0575e4..92c4e496 100644 --- a/lib/src/clixon_xpath.c +++ b/lib/src/clixon_xpath.c @@ -1162,6 +1162,17 @@ xpath_first(cxobj *xcur, * @param[out] veclen returns length of vector in return value * @retval 0 OK * @retval -1 Error + * @code + * cxobj **vec; + * size_t veclen; + * if (xpath_vec(xcur, "//symbol/foo", &vec, &veclen) < 0) + * goto err; + * for (i=0; i