From 02eec9954cacb1a4b9460c3c45524ce383c7ce17 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 10 Sep 2018 21:43:43 +0300 Subject: [PATCH] XML: Do not add empty Value node for nodes with child nodes in TNDS This fixes some validation issues against DM_ddf DTD that were caused by the conversion from the internal tree structure to TNDS. Only the leaf nodes are supposed to have the Value node. Signed-off-by: Jouni Malinen --- src/utils/xml-utils.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils/xml-utils.c b/src/utils/xml-utils.c index a37a92d44..dae91fee4 100644 --- a/src/utils/xml-utils.c +++ b/src/utils/xml-utils.c @@ -246,7 +246,9 @@ static void node_to_tnds(struct xml_node_ctx *ctx, xml_node_t *out, xml_node_create_text(ctx, tnds, NULL, "Path", uri); val = get_val(ctx, node); - xml_node_create_text(ctx, tnds, NULL, "Value", val ? val : ""); + if (val || !xml_node_first_child(ctx, node)) + xml_node_create_text(ctx, tnds, NULL, "Value", + val ? val : ""); xml_node_get_text_free(ctx, val); new_uri = add_path(uri, name);