When parse a xml with CDATA , a syntax error will be occured at so.ver 2.33.3 .
If I use libyang.so.2.33.3 and libsysrepo.7.14.20 ,with command like "sysrepocfg -d "startup" --edit=test.xml" ,there should be one syntax error occured as belows:
libyang error: Text value "<xxxx" inside an anydata node "vsData" found. (Data location "/_xxxxx/xxxx/vsDataContainer[id='1']", line number xx.)
sysrepocfg error: Data parsing failed
And the test.xml used like this:
<?xml version="1.0" encoding="UTF-8"?>
<ME xmlns="xxxxxx">
<Gxxxxxx>
<vsDataContainer>
<id>0</id>
<vsData><![CDATA[
<vsData>
<gnbvs xmlns=xxxxxxx
.........
</gnbvs>
</vsData>
]]></vsData>
</vsDataContainer>
.........
Indeed, I think that CDATA should be realized in function [lyxml_parse_value],and the value of ws should not returned 0 ... thanks.
Our XML parser does not really support CDATA sections because they should not be needed in YANG data. Can you skip the CDATA declaration and just put the elements as standard descendants of the vsData element?
Our XML parser does not really support CDATA sections because they should not be needed in YANG data. Can you skip the CDATA declaration and just put the elements as standard descendants of the
vsDataelement?
I notice that the variable “ws” in CDATA process returns 0 in function 'lyxml_parse_value',which cause syntax in function 'lydxml_subtree_any' and then make sysrepo fatal. so can we comment the "ws = 0" in CDATA process and let it work? thanks!
/* skip CDATA tag */
in += ly_strlen_const("<![CDATA[");
assert(!offset);
/* analyze CDATA for non WS and newline chars */
for (n = 0; n < u; ++n) {
if (in[n] == '\n') {
LY_IN_NEW_LINE(xmlctx->in);
} else if (!is_xmlws(in[n])) {
ws = 0; ----------------------------------just here.
}
}
/* copy CDATA */
memcpy(buf + len, in, u);
len += u;
/* move input skipping the end tag */
in += u + ly_strlen_const("]]>");
Sorry, so it is supported just does not work in this case. You want libyang to just ignore the contents of the CDATA? Wouldn't it make more sense to parse the nested data as the value of the anydata node? That can be fixed and is actually what happens if you skip the CDATA tag.