Browse Source

PR: 17195

Submitted by:	Markku Saarela


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274698 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 22 years ago
parent
commit
cdd1db5a99
4 changed files with 21 additions and 2 deletions
  1. +5
    -0
      WHATSNEW
  2. +1
    -0
      src/etc/testcases/taskdefs/xmlproperty_data.xml
  3. +13
    -2
      src/main/org/apache/tools/ant/taskdefs/XmlProperty.java
  4. +2
    -0
      src/testcases/org/apache/tools/ant/taskdefs/XmlPropertyTest.java

+ 5
- 0
WHATSNEW View File

@@ -172,6 +172,8 @@ Fixed bugs:
* <fixcrlf> will now create the parent directories for the destination
files if necessary. Bugzilla Report 20840.

* <xmlproperty> now handles CDATA sections. BugZilla Report 17195
Other changes:
--------------
* Six new Clearcase tasks added.
@@ -434,6 +436,9 @@ Other changes:

* <mapper> has an "unpackage" mapper
Bugzilla Report 18908
* Added <scriptdef> task allowing tasks to be defined using any BSF-supported
scripting language.

Changes from Ant 1.5.2 to Ant 1.5.3
===================================


+ 1
- 0
src/etc/testcases/taskdefs/xmlproperty_data.xml View File

@@ -1,4 +1,5 @@
<root-tag myattr="true">
<inner-tag someattr="val">Text</inner-tag>
<a2><a3><a4>false</a4></a3></a2>
<cdatatag><![CDATA[<test>]]></cdatatag>
</root-tag>

+ 13
- 2
src/main/org/apache/tools/ant/taskdefs/XmlProperty.java View File

@@ -450,14 +450,25 @@ public class XmlProperty extends org.apache.tools.ant.Task {
}
}

String nodeText = null;
if (node.getNodeType() == Node.TEXT_NODE) {
// For the text node, add a property.
nodeText = getAttributeValue(node);
} else if ((node.getNodeType() == Node.ELEMENT_NODE)
&& (node.getChildNodes().getLength() == 1)
&& (node.getFirstChild().getNodeType() == Node.CDATA_SECTION_NODE)) {

nodeText = node.getFirstChild().getNodeValue();
}
if (nodeText != null) {
// If the containing object was a String, then use it as the ID.
if (semanticAttributes && id == null
&& container instanceof String) {
id = (String) container;
System.out.println("Setting id = " + id);
}
// For the text node, add a property.
String nodeText = getAttributeValue(node);

if (nodeText.trim().length() != 0) {
addProperty(prefix, nodeText, id);
}


+ 2
- 0
src/testcases/org/apache/tools/ant/taskdefs/XmlPropertyTest.java View File

@@ -90,6 +90,8 @@ public class XmlPropertyTest extends BuildFileTest {
assertEquals("val",
getProject().getProperty("root-tag.inner-tag(someattr)"));
assertEquals("false", getProject().getProperty("root-tag.a2.a3.a4"));
assertEquals("CDATA failed",
"<test>", getProject().getProperty("root-tag.cdatatag"));
}

public void testNone () {


Loading…
Cancel
Save