From ffc467b126ec5f41e0d4114a7683f384885e4108 Mon Sep 17 00:00:00 2001 From: Peter Reilly Date: Sat, 23 Sep 2006 21:35:39 +0000 Subject: [PATCH] Bugzilla 26286: allow empty leaf nodes to be properties git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@449309 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 3 +++ src/main/org/apache/tools/ant/taskdefs/XmlProperty.java | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 3308d1b82..ae34ab1af 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -24,6 +24,9 @@ Fixed bugs: * created junitvmwatcher*.properties files but did not close and delete them. +* did not create properties for empty leaf elements. + Bugzilla report 26286. + Other changes: -------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java b/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java index 5af01f4f5..7ec448d26 100644 --- a/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java +++ b/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java @@ -430,6 +430,9 @@ public class XmlProperty extends org.apache.tools.ant.Task { && (node.getFirstChild().getNodeType() == Node.CDATA_SECTION_NODE)) { nodeText = node.getFirstChild().getNodeValue(); + } else if ((node.getNodeType() == Node.ELEMENT_NODE) + && (node.getChildNodes().getLength() == 0)) { + nodeText = ""; } if (nodeText != null) { @@ -439,9 +442,7 @@ public class XmlProperty extends org.apache.tools.ant.Task { id = (String) container; } - if (nodeText.trim().length() != 0) { - addProperty(prefix, nodeText, id); - } + addProperty(prefix, nodeText, id); } // Return the Path we added or the ID of this node for