data FEATURE printer for YANG data in JSON format
diff --git a/src/printer_xml.c b/src/printer_xml.c
index 3a94406..d20bd0e 100644
--- a/src/printer_xml.c
+++ b/src/printer_xml.c
@@ -44,11 +44,6 @@
struct ly_set ns; /**< printed namespaces */
};
-#define LEVEL ctx->level /**< current level */
-#define INDENT ((LEVEL) ? (LEVEL)*2 : 0),"" /**< indentation parameters for printer functions */
-#define LEVEL_INC if (LEVEL) {LEVEL++;} /**< increase indentation level */
-#define LEVEL_DEC if (LEVEL) {LEVEL--;} /**< decrease indentation level */
-
#define LYXML_PREFIX_REQUIRED 0x01 /**< The prefix is not just a suggestion but a requirement. */
#define LYXML_PREFIX_DEFAULT 0x02 /**< The namespace is required to be a default (without prefix) */
@@ -257,7 +252,7 @@
static LY_ERR
xml_print_attr(struct xmlpr_ctx *ctx, const struct lyd_node_opaq *node)
{
- const struct ly_attr *attr;
+ const struct lyd_attr *attr;
const char *pref;
LY_ARRAY_COUNT_TYPE u;
@@ -324,11 +319,11 @@
ly_set_erase(&ns_list, NULL);
if (!value || !value[0]) {
- ly_print(ctx->out, "/>%s", LEVEL ? "\n" : "");
+ ly_print(ctx->out, "/>%s", DO_FORMAT ? "\n" : "");
} else {
ly_print(ctx->out, ">");
lyxml_dump_text(ctx->out, value, 0);
- ly_print(ctx->out, "</%s>%s", node->schema->name, LEVEL ? "\n" : "");
+ ly_print(ctx->out, "</%s>%s", node->schema->name, DO_FORMAT ? "\n" : "");
}
if (dynamic) {
free((void *)value);
@@ -351,12 +346,12 @@
xml_print_node_open(ctx, (struct lyd_node *)node);
if (!node->child) {
- ly_print(ctx->out, "/>%s", ctx->level ? "\n" : "");
+ ly_print(ctx->out, "/>%s", DO_FORMAT ? "\n" : "");
return LY_SUCCESS;
}
/* children */
- ly_print(ctx->out, ">%s", ctx->level ? "\n" : "");
+ ly_print(ctx->out, ">%s", DO_FORMAT ? "\n" : "");
LEVEL_INC;
LY_LIST_FOR(node->child, child) {
@@ -365,7 +360,7 @@
}
LEVEL_DEC;
- ly_print(ctx->out, "%*s</%s>%s", INDENT, node->schema->name, LEVEL ? "\n" : "");
+ ly_print(ctx->out, "%*s</%s>%s", INDENT, node->schema->name, DO_FORMAT ? "\n" : "");
return LY_SUCCESS;
}
@@ -383,7 +378,7 @@
if (!any->value.tree) {
/* no content */
no_content:
- ly_print(ctx->out, "/>%s", LEVEL ? "\n" : "");
+ ly_print(ctx->out, "/>%s", DO_FORMAT ? "\n" : "");
return LY_SUCCESS;
} else {
if (any->value_type == LYD_ANYDATA_LYB) {
@@ -409,7 +404,7 @@
ctx->options &= ~LYD_PRINT_WITHSIBLINGS;
LEVEL_INC;
- ly_print(ctx->out, ">%s", LEVEL ? "\n" : "");
+ ly_print(ctx->out, ">%s", DO_FORMAT ? "\n" : "");
LY_LIST_FOR(any->value.tree, iter) {
ret = xml_print_node(ctx, iter);
LY_CHECK_ERR_RET(ret, LEVEL_DEC, ret);
@@ -443,9 +438,9 @@
/* closing tag */
if (any->value_type == LYD_ANYDATA_DATATREE) {
- ly_print(ctx->out, "%*s</%s>%s", INDENT, node->schema->name, LEVEL ? "\n" : "");
+ ly_print(ctx->out, "%*s</%s>%s", INDENT, node->schema->name, DO_FORMAT ? "\n" : "");
} else {
- ly_print(ctx->out, "</%s>%s", node->schema->name, LEVEL ? "\n" : "");
+ ly_print(ctx->out, "</%s>%s", node->schema->name, DO_FORMAT ? "\n" : "");
}
}
@@ -475,7 +470,7 @@
if (node->child) {
/* children */
if (!node->value[0]) {
- ly_print(ctx->out, ">%s", ctx->level ? "\n" : "");
+ ly_print(ctx->out, ">%s", DO_FORMAT ? "\n" : "");
}
LEVEL_INC;
@@ -485,12 +480,12 @@
}
LEVEL_DEC;
- ly_print(ctx->out, "%*s</%s>%s", INDENT, node->name, LEVEL ? "\n" : "");
+ ly_print(ctx->out, "%*s</%s>%s", INDENT, node->name, DO_FORMAT ? "\n" : "");
} else if (node->value[0]) {
- ly_print(ctx->out, "</%s>%s", node->name, LEVEL ? "\n" : "");
+ ly_print(ctx->out, "</%s>%s", node->name, DO_FORMAT ? "\n" : "");
} else {
/* no value or children */
- ly_print(ctx->out, "/>%s", ctx->level ? "\n" : "");
+ ly_print(ctx->out, "/>%s", DO_FORMAT ? "\n" : "");
}
return LY_SUCCESS;