bodewig 2003/09/23 08:03:36
Modified: . Tag: ANT_16_BRANCH WHATSNEW
src/etc/testcases/taskdefs/optional Tag: ANT_16_BRANCH
xmlvalidate.xml
src/main/org/apache/tools/ant/types Tag: ANT_16_BRANCH
XMLCatalog.java
src/testcases/org/apache/tools/ant/taskdefs/optional Tag:
ANT_16_BRANCH XmlValidateTest.java
src/testcases/org/apache/tools/ant/types Tag: ANT_16_BRANCH
XMLCatalogTest.java
Log:
Merge fix for PR 20965 from HEAD
Revision Changes Path
No revision
No revision
1.503.2.2 +3 -0 ant/WHATSNEW
Index: WHATSNEW
===================================================================
RCS file: /home/cvs/ant/WHATSNEW,v
retrieving revision 1.503.2.1
retrieving revision 1.503.2.2
diff -u -r1.503.2.1 -r1.503.2.2
--- WHATSNEW 22 Sep 2003 15:02:01 -0000 1.503.2.1
+++ WHATSNEW 23 Sep 2003 15:03:36 -0000 1.503.2.2
@@ -248,6 +248,9 @@
* <splash> could fail on JVMs that use null to indicate the system
classloader.
Bugzilla Report 23320.
+* <xmlcatalog>s only worked when defined inside of tasks. Bugzilla
+ Report 20965.
+
Other changes:
--------------
* All tasks can be used outside of <target>s. Note that some tasks
No revision
No revision
1.11.2.1 +10 -0 ant/src/etc/testcases/taskdefs/optional/xmlvalidate.xml
Index: xmlvalidate.xml
===================================================================
RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/optional/xmlvalidate.xml,v
retrieving revision 1.11
retrieving revision 1.11.2.1
diff -u -r1.11 -r1.11.2.1
--- xmlvalidate.xml 10 Dec 2002 07:39:22 -0000 1.11
+++ xmlvalidate.xml 23 Sep 2003 15:03:36 -0000 1.11.2.1
@@ -25,6 +25,16 @@
</xmlvalidate>
</target>
+ <target name="xmlcatalogViaRefid">
+ <xmlcatalog classpath="xml" id="cat">
+ <dtd publicID="-//stevo//DTD doc 1.0//EN" location="doc.dtd"/>
+ </xmlcatalog>
+ <xmlvalidate warn="false">
+ <xmlcatalog refid="cat"/>
+ <fileset dir="xml" includes="**/about.xml"/>
+ </xmlvalidate>
+ </target>
+
<target name="xmlcatalognested">
<xmlvalidate warn="false">
<fileset dir="xml" includes="**/about.xml"/>
No revision
No revision
1.32.2.1 +23 -17 ant/src/main/org/apache/tools/ant/types/XMLCatalog.java
Index: XMLCatalog.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/XMLCatalog.java,v
retrieving revision 1.32
retrieving revision 1.32.2.1
diff -u -r1.32 -r1.32.2.1
--- XMLCatalog.java 13 Aug 2003 15:14:31 -0000 1.32
+++ XMLCatalog.java 23 Sep 2003 15:03:36 -0000 1.32.2.1
@@ -208,7 +208,7 @@
* @return the elements of the catalog - ResourceLocation objects
*/
private Vector getElements() {
- return elements;
+ return getRef().elements;
}
/**
@@ -217,7 +217,7 @@
* @return the classpath
*/
private Path getClasspath() {
- return classpath;
+ return getRef().classpath;
}
/**
@@ -335,7 +335,7 @@
* @return the catalog path
*/
public Path getCatalogPath() {
- return this.catalogPath;
+ return getRef().catalogPath;
}
@@ -421,17 +421,6 @@
if (!elements.isEmpty()) {
throw tooManyAttributes();
}
- // change this to get the objects from the other reference
- Object o = r.getReferencedObject(getProject());
- // we only support references to other XMLCatalogs
- if (o instanceof XMLCatalog) {
- // set all elements from referenced catalog to this one
- XMLCatalog catalog = (XMLCatalog) o;
- setElements(catalog.getElements());
- } else {
- String msg = r.getRefId() + " does not refer to an XMLCatalog";
- throw new BuildException(msg);
- }
super.setRefid(r);
}
@@ -443,6 +432,10 @@
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException, IOException {
+ if (isReference()) {
+ return getRef().resolveEntity(publicId, systemId);
+ }
+
if (!isChecked()) {
// make sure we don't have a circular reference here
Stack stk = new Stack();
@@ -472,6 +465,10 @@
public Source resolve(String href, String base)
throws TransformerException {
+ if (isReference()) {
+ return getRef().resolve(href, base);
+ }
+
if (!isChecked()) {
// make sure we don't have a circular reference here
Stack stk = new Stack();
@@ -516,6 +513,16 @@
}
/**
+ * @since Ant 1.6
+ */
+ private XMLCatalog getRef() {
+ if (!isReference()) {
+ return this;
+ }
+ return (XMLCatalog) getCheckedRef(XMLCatalog.class, "xmlcatalog");
+ }
+
+ /**
* The instance of the CatalogResolver strategy to use.
*/
private CatalogResolver catalogResolver = null;
@@ -576,9 +583,8 @@
&& getCatalogPath().list().length != 0) {
log("Warning: catalogpath listing external catalogs"
+ " will be ignored", Project.MSG_WARN);
- log("Failed to load Apache resolver: "
- + ex, Project.MSG_DEBUG);
}
+ log("Failed to load Apache resolver: " + ex,
Project.MSG_DEBUG);
}
}
return catalogResolver;
No revision
No revision
1.11.2.1 +8 -1
ant/src/testcases/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java
Index: XmlValidateTest.java
===================================================================
RCS file:
/home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java,v
retrieving revision 1.11
retrieving revision 1.11.2.1
diff -u -r1.11 -r1.11.2.1
--- XmlValidateTest.java 10 Feb 2003 14:14:52 -0000 1.11
+++ XmlValidateTest.java 23 Sep 2003 15:03:36 -0000 1.11.2.1
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -123,6 +123,13 @@
*/
public void testXmlCatalog() {
executeTarget("xmlcatalog");
+ }
+
+ /**
+ *
+ */
+ public void testXmlCatalogViaRefid() {
+ executeTarget("xmlcatalogViaRefid");
}
/**
No revision
No revision
1.4.2.1 +1 -9
ant/src/testcases/org/apache/tools/ant/types/XMLCatalogTest.java
Index: XMLCatalogTest.java
===================================================================
RCS file:
/home/cvs/ant/src/testcases/org/apache/tools/ant/types/XMLCatalogTest.java,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- XMLCatalogTest.java 10 Feb 2003 14:14:55 -0000 1.4
+++ XMLCatalogTest.java 23 Sep 2003 15:03:36 -0000 1.4.2.1
@@ -172,14 +172,6 @@
}
public void testEmptyElementIfIsReference() {
- try {
- catalog.setRefid(new Reference("dummyref"));
- fail("Can add reference to nonexistent XMLCatalog");
- } catch (BuildException be) {
- assertEquals("Reference dummyref not found.",
- be.getMessage());
- }
-
ResourceLocation dtd = new ResourceLocation();
dtd.setPublicId("PUBLIC ID ONE");
dtd.setLocation("i/dont/exist.dtd");
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]