CESNET / libyang

YANG data modeling language library
BSD 3-Clause "New" or "Revised" License
364 stars 291 forks source link

lyd_new_path API not work with concat #2275

Open NextLitete opened 1 month ago

NextLitete commented 1 month ago

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"

jktjkt commented 1 month ago

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.