XPath: refactored XPath match, documented localonly and prefixonly api

This commit is contained in:
Olof hagsand 2024-12-15 11:27:58 +01:00
parent 6c73c36fb7
commit 081a541c6b
13 changed files with 384 additions and 105 deletions

View file

@ -60,7 +60,10 @@
* of the xpath-tree, which is context-dependent.
* Best is to send it as a (read-only) parameter to the xp_eval family of functions
* as an exlicit namespace context.
*
* 3) localonly flag refers to https://www.w3.org/TR/REC-xml-names/, where :
* PrefixedName ::= Prefix ':' LocalPart
* "localonly" means to skip the "Prefix" part, ie namespaces
* see nodetest_eval_node() for the semantics of prefix/namespace processing
*/
#ifdef HAVE_CONFIG_H
#include "clixon_config.h" /* generated by config & autoconf */
@ -328,8 +331,8 @@ xpath_tree2cbuf(xpath_tree *xs,
cprintf(xcb, "%s", clicon_int2str(xpopmap, xs->xs_int));
break;
case XP_PATHEXPR:
/* [19] PathExpr ::= | FilterExpr '/' RelativeLocationPath
| FilterExpr '//' RelativeLocationPath
/* [19] PathExpr ::= | FilterExpr '/' RelativeLocationPath
| FilterExpr '//' RelativeLocationPath
*/
if (xs->xs_s0)
cprintf(xcb, "%s", xs->xs_s0);
@ -608,7 +611,7 @@ xpath_parse(const char *xpath,
* @param[in] xcur XML-tree where to search
* @param[in] nsc External XML namespace context, or NULL
* @param[in] xpath String with XPath 1.0 syntax
* @param[in] localonly Skip prefix and namespace tests (non-standard)
* @param[in] localonly Skip prefix and namespace tests
* @param[out] xrp Return XPath context
* @retval 0 OK
* @retval -1 Error