libyang icon indicating copy to clipboard operation
libyang copied to clipboard

The lyd_parse_data_mem function cannot process data other than invalid data.

Open sicongPang opened this issue 1 year ago • 1 comments

module:

container testsdk {
    container TsdkTypeInners {
      list TsdkTypeInner {
        key "TestIndex TestName";
        config true;
        mo:global-max-elements "1000000";
        leaf TestIndex {
          type uint32 {
            range "0..4294967295";
          }
          mandatory true;
          mo:indexAssignMode "INC";
          mo:isIndexField "true";
        }
        leaf TestName {
          type string {
            length "0..50";
          }
          mandatory true;
        }
        leaf TestString2 {
          type string {
            length "0..20";
          }
          mandatory false;
        }
    }
}

When invalid data is constructed and the lyd_parse_data_mem function is invoked for parsing, subsequent data parsing is ignored:

image

    LY_ERR ret = lyd_parse_data_mem(pstLocal->stServer.pstYang, xmlStr, LYD_XML, LYD_PARSE_ONLY | LYD_PARSE_NO_STATE,
        LYD_VALIDATE_PRESENT | LYD_VALIDATE_NO_STATE, &pstTree1);

Is this as expected? Which of the following options can be used to skip only invalid data to ensure that subsequent valid data can be parsed?

sicongPang avatar Dec 24 '24 07:12 sicongPang

You have mixed the options, when using LYD_PARSE_ONLY, validation options should be 0, so try that.

michalvasko avatar Jan 06 '25 10:01 michalvasko