bodewig 2003/09/23 07:33:43 Modified: . WHATSNEW src/etc/testcases/taskdefs/optional xmlvalidate.xml src/main/org/apache/tools/ant/types XMLCatalog.java src/testcases/org/apache/tools/ant/taskdefs/optional XmlValidateTest.java Log: Defer expansion of reference until the catalog gets used. PR: 20965 Revision Changes Path 1.505 +3 -0 ant/WHATSNEW Index: WHATSNEW =================================================================== RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.504 retrieving revision 1.505 diff -u -r1.504 -r1.505 --- WHATSNEW 22 Sep 2003 15:05:21 -0000 1.504 +++ WHATSNEW 23 Sep 2003 14:33:43 -0000 1.505 @@ -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 1.12 +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.12 diff -u -r1.11 -r1.12 --- xmlvalidate.xml 10 Dec 2002 07:39:22 -0000 1.11 +++ xmlvalidate.xml 23 Sep 2003 14:33:43 -0000 1.12 @@ -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"/> 1.33 +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.33 diff -u -r1.32 -r1.33 --- XMLCatalog.java 13 Aug 2003 15:14:31 -0000 1.32 +++ XMLCatalog.java 23 Sep 2003 14:33:43 -0000 1.33 @@ -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; 1.12 +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.12 diff -u -r1.11 -r1.12 --- XmlValidateTest.java 10 Feb 2003 14:14:52 -0000 1.11 +++ XmlValidateTest.java 23 Sep 2003 14:33:43 -0000 1.12 @@ -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"); } /**
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]