tests CHANGE enhance xml test for getting string data
Includes small bugfixes in function itself to conform the test
diff --git a/src/xml.c b/src/xml.c
index 796fee1..78b259f 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -246,13 +246,15 @@
/**
* @brief Parse input as XML text (attribute's values and element's content).
*
- * Mixed content of XML elements is not allowed.
+ * Mixed content of XML elements is not allowed. Formating whitespaces before child element are ignored,
+ * LY_EINVAL is returned in such a case (buffer is not filled, no error is printed) and input is moved
+ * to the beginning of a child definition.
*
* In the case of attribute's values, the input string is expected to start on a quotation mark to
- * select which delimiter (single or double quote) is used. Otherwise, the element content is beeing
+ * select which delimiter (single or double quote) is used. Otherwise, the element content is being
* parsed expected to be terminated by '<' character.
*
- * If function succeedes, the string in output buffer is always NULL-terminated.
+ * If function succeeds, the string in output buffer is always NULL-terminated.
*
* @param[in] context XML context to track lines or store errors into libyang context.
* @param[in,out] input Input string to process, updated according to the processed/read data.
@@ -303,7 +305,7 @@
for (offset = 0; in[offset] && is_xmlws(in[offset]); ++offset);
LY_CHECK_ERR_RET(!in[offset], LOGVAL(ctx, LY_VLOG_LINE, &context->line, LY_VCODE_EOF), LY_EVALID);
if (in[offset] == '<') {
- in += offset;
+ (*input) = in + offset;
return LY_EINVAL;
}
} else {
@@ -357,8 +359,8 @@
buf[len++] = '\"';
in += 6; /* " */
} else {
- LOGVAL(ctx, LY_VLOG_LINE, &context->line, LY_VCODE_NSUPP,
- "entity references (except the predefined references)");
+ LOGVAL(ctx, LY_VLOG_LINE, &context->line, LYVE_SYNTAX,
+ "Entity reference \"%.*s\" not supported, only predefined references allowed.", 10, &in[offset-1]);
goto error;
}
offset = 0;
@@ -382,7 +384,7 @@
n = (16 * n) + u;
}
} else {
- LOGVAL(ctx, LY_VLOG_LINE, &context->line, LYVE_SYNTAX, "Invalid character reference %.*s", 12, p);
+ LOGVAL(ctx, LY_VLOG_LINE, &context->line, LYVE_SYNTAX, "Invalid character reference \"%.*s\".", 12, p);
goto error;
}