[sysrepo-devel] is an apostrophe not an allowed character in a key?

Joan Landry JoLandry at advaoptical.com
Mon Dec 19 17:11:14 UTC 2016


Thanks so much!!

-----Original Message-----
From: Lukas Macko -X (lmacko - PANTHEON TECHNOLOGIES at Cisco) [mailto:lmacko at cisco.com] 
Sent: Monday, December 19, 2016 2:10 AM
To: Joan Landry <JoLandry at advaoptical.com>; Michal Vaško <mvasko at cesnet.cz>
Cc: sysrepo-devel at sysrepo.org
Subject: RE: [sysrepo-devel] is an apostrophe not an allowed character in a key?

Hi,

rc = sr_set_item(sess, "/ietf-interfaces:interfaces/interface[name=\"giga'eth0\"]/type", &value, SR_EDIT_DEFAULT);

in the example there is more issue: The identity value should be prefixed by module name   
value.data.string_val = "iana-if-type:ethernetCsmacd";

Regards,
Lukas

> -----Original Message-----
> From: sysrepo-devel [mailto:sysrepo-devel-bounces at sysrepo.org] On 
> Behalf Of Joan Landry
> Sent: Friday, December 16, 2016 10:38 PM
> To: Michal Vaško <mvasko at cesnet.cz>
> Cc: sysrepo-devel at sysrepo.org
> Subject: Re: [sysrepo-devel] is an apostrophe not an allowed character in a key?
> 
> I am sorry I am not sure I fully understand your suggestion on how to 
> correct this issue.
> 
> In the sr_set_item_example.c  example code
> 
>     rc = sr_set_item(sess, "/ietf-
> interfaces:interfaces/interface[name='gigaeth0']/type", &value, 
> SR_EDIT_DEFAULT);
> 
> what should be entered if the name of the interface is gig'123
> 
> I have tried the following combinations and none of them work.
> 
>     rc = sr_set_item(sess, "/ietf-
> interfaces:interfaces/interface[name='gig'123']/type", &value, 
> SR_EDIT_DEFAULT);
>     rc = sr_set_item(sess, "/ietf-
> interfaces:interfaces/interface[name='gig\'123']/type", &value, 
> SR_EDIT_DEFAULT);
>     rc = sr_set_item(sess, "/ietf-
> interfaces:interfaces/interface[name='gig\"'\"123']/type", &value, 
> SR_EDIT_DEFAULT);
> 
> any info on this would be greatly appreciated.
> thanks
> 
> -----Original Message-----
> From: Michal Vaško [mailto:mvasko at cesnet.cz]
> Sent: Thursday, December 15, 2016 3:14 AM
> To: Joan Landry <JoLandry at advaoptical.com>
> Cc: sysrepo-devel at sysrepo.org
> Subject: Re: [sysrepo-devel] is an apostrophe not an allowed character in a key?
> 
> Hi,
> XPath defines [1] that a literal (which is a string value, such as 
> your key value) enclosed in single-quotes cannot contain a 
> single-quote and in double-quotes cannot contain a double-quote. Hence use double-quotes.
> 
> Regards,
> Michal
> 
> [1] https://www.w3.org/TR/xpath/#NT-Literal
> 
> On Wednesday, December 14, 2016 20:20 CET, Joan Landry 
> <JoLandry at advaoptical.com> wrote:
> 
> > I am seeing that if the key name of something includes and 
> > apostrophe libyang
> sees it as an error.
> >
> > Is the apostrophe not allowed as a character of a key leaf?
> >
> > To set the name my code does the following:
> >       snprintf(xpath_buf, 256,
> > "/ensemble-config:ensemble-config/abc-ensemble-domains:domains/domai
> > n[
> > name='%s']/owner-tag", name);
> >
> > where if name has normal characters there is no issue - but if name 
> > contains
> an apostrophe I get an error:
> > example: abcd'efg
> >
> > INF] (rp_dt_set_item_wrapper:559) Set item request running 
> > datastore,
> > xpath:
> > /ensemble-config:ensemble-config/ensemble-
> domains:domains/domain[name=
> > 'abcd'efg']/persistence [DBG] (dm_ly_log_cb:853) libyang error:
> > Unexpected character(s) 'e' (efg']/persisten).
> > [DBG] (dm_ly_log_cb:853) libyang error: Resolving XPath expression
> "/ensemble-config:ensemble-config/ensemble-
> domains:domains/domain[name='abcd'efg']/persistence" failed.
> > [ERR] (rp_dt_set_item:323) Requested node is not valid
> > /adva-ensemble-config:ensemble-config/adva-ensemble-
> domains:domains/do
> > main[name='abcd'efg']/persistence [ERR] (rp_dt_set_item_wrapper:574) 
> > Set item failed [ERR] (rp_set_item_req_process:939) Set item failed 
> > for '/ensemble-config:ensemble-config/ensemble-
> domains:domains/domain[name='abcd'efg']/persistence', session 
> id=602346779.
> >
> > In case above name is defined as a string.
> >
> >     list domain {
> >       key "name";
> >       leaf name {
> >         type string;
> >       }
> 
> 
> 
> _______________________________________________
> sysrepo-devel mailing list
> sysrepo-devel at sysrepo.org
> http://lists.sysrepo.org/listinfo/sysrepo-devel


More information about the sysrepo-devel mailing list