libyang icon indicating copy to clipboard operation
libyang copied to clipboard

lyd_new_path API not work with concat

Open NextLitete opened this issue 1 year ago • 1 comments

The concat function is used to correctly process the single quotation mark (') and double quotation mark (") in the node value. But the lyd_new_path API doesn't seem to support it. Do you have any better suggestions? Thanks!

uint32_t options = LYD_NEW_PATH_CANON_VALUE | LYD_NEW_PATH_OUTPUT | LYD_NEW_PATH_UPDATE;
lyErr = lyd_new_path(root, ctx, path.c_str(), value, options, nullptr);

err_path: lyd_new_path err[7], path:/openconfig-telemetry:telemetry-system/destination-groups/destination-group[group-id=concat("'",'"')]/config/group-id err_msg: lyd_new_path err[7], errmsg:Unexpected XPath token "FunctionName" ("concat("'",'"')"), expected "Literal"

NextLitete avatar Aug 02 '24 08:08 NextLitete

These functions are documented to take a path, not an XPath. The grammar for path follows the instance-identifier from the grammar in RFC 7950. No XPath functions are allowed in there, so you cannot use concat().

Are you maybe looking for a way of allowing list key values with both " and '? That's just not possible in the YANG ecosystem I'm afraid.

jktjkt avatar Aug 05 '24 09:08 jktjkt