You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by co...@apache.org on 2003/07/23 14:11:10 UTC
cvs commit: ant/src/etc/testcases/taskdefs xmlproperty_data.dtd xmlproperty_withdtd.xml xmlproperty.xml
conor 2003/07/23 05:11:09
Modified: src/main/org/apache/tools/ant/taskdefs XmlProperty.java
src/testcases/org/apache/tools/ant/taskdefs
XmlPropertyTest.java
src/etc/testcases/taskdefs xmlproperty.xml
Added: src/etc/testcases/taskdefs xmlproperty_data.dtd
xmlproperty_withdtd.xml
Log:
Handle relative DTDs in XMLProperty
PR: 14685
Submitted by: Kimbo Mundy
Revision Changes Path
1.17 +3 -16 ant/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java
Index: XmlProperty.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -w -u -r1.16 -r1.17
--- XmlProperty.java 19 Jul 2003 11:20:13 -0000 1.16
+++ XmlProperty.java 23 Jul 2003 12:11:08 -0000 1.17
@@ -65,6 +65,7 @@
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.util.FileUtils;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
@@ -260,23 +261,16 @@
throw new BuildException(msg);
}
- BufferedInputStream configurationStream = null;
-
try {
log("Loading " + src.getAbsolutePath(), Project.MSG_VERBOSE);
if (src.exists()) {
- configurationStream =
- new BufferedInputStream(new FileInputStream(src));
-
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-
factory.setValidating(validate);
factory.setNamespaceAware(false);
-
- Element topElement
- = factory.newDocumentBuilder().parse(configurationStream).getDocumentElement();
+ Document document = factory.newDocumentBuilder().parse(src);
+ Element topElement = document.getDocumentElement();
// Keep a hashtable of attributes added by this task.
// This task is allow to override its own properties
@@ -312,13 +306,6 @@
} catch (IOException ioe) {
// I/O error
throw new BuildException(ioe);
- } finally {
- if (configurationStream != null) {
- try {
- configurationStream.close();
- } catch (Exception e) {
- }
- }
}
}
1.8 +23 -18 ant/src/testcases/org/apache/tools/ant/taskdefs/XmlPropertyTest.java
Index: XmlPropertyTest.java
===================================================================
RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/XmlPropertyTest.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -w -u -r1.7 -r1.8
--- XmlPropertyTest.java 24 Jun 2003 11:33:48 -0000 1.7
+++ XmlPropertyTest.java 23 Jul 2003 12:11:09 -0000 1.8
@@ -94,6 +94,11 @@
"<test>", getProject().getProperty("root-tag.cdatatag"));
}
+ public void testDTD() {
+ executeTarget("testdtd");
+ assertEquals("Text", getProject().getProperty("root-tag.inner-tag"));
+ }
+
public void testNone () {
doTest("testNone", false, false, false, false, false);
}
1.2 +3 -0 ant/src/etc/testcases/taskdefs/xmlproperty.xml
Index: xmlproperty.xml
===================================================================
RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/xmlproperty.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -u -r1.1 -r1.2
--- xmlproperty.xml 19 Apr 2002 19:51:29 -0000 1.1
+++ xmlproperty.xml 23 Jul 2003 12:11:09 -0000 1.2
@@ -4,4 +4,7 @@
<xmlproperty file="xmlproperty_data.xml"/>
</target>
+ <target name="testdtd">
+ <xmlproperty file="xmlproperty_withdtd.xml"/>
+ </target>
</project>
1.1 ant/src/etc/testcases/taskdefs/xmlproperty_data.dtd
Index: xmlproperty_data.dtd
===================================================================
<!ELEMENT root-tag (inner-tag, a2, cdatatag)>
<!ATTLIST root-tag myattr CDATA "">
<!ELEMENT inner-tag (#PCDATA)>
<!ATTLIST inner-tag someattr CDATA "">
<!ELEMENT a2 (a3)>
<!ELEMENT a3 (a4)>
<!ELEMENT a4 (#PCDATA)>
<!ELEMENT cdatatag (#PCDATA)>
1.1 ant/src/etc/testcases/taskdefs/xmlproperty_withdtd.xml
Index: xmlproperty_withdtd.xml
===================================================================
<!DOCTYPE root-tag SYSTEM "xmlproperty_data.dtd">
<root-tag myattr="true">
<inner-tag someattr="val">Text</inner-tag>
<a2><a3><a4>false</a4></a3></a2>
<cdatatag><![CDATA[<test>]]></cdatatag>
</root-tag>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org