peterreilly 2004/09/10 01:55:55 Modified: . Tag: ANT_16_BRANCH WHATSNEW CONTRIBUTORS src/main/org/apache/tools/ant/taskdefs Tag: ANT_16_BRANCH XmlProperty.java docs/manual/CoreTasks Tag: ANT_16_BRANCH xmlproperty.html src/etc/testcases/taskdefs Tag: ANT_16_BRANCH xmlproperty.xml src/testcases/org/apache/tools/ant/taskdefs Tag: ANT_16_BRANCH XmlPropertyTest.java Added: src/etc/testcases/taskdefs Tag: ANT_16_BRANCH xmlproperty_needscat.xml skinconfig.dtd Log: sync Revision Changes Path No revision No revision 1.503.2.133 +2 -0 ant/WHATSNEW Index: WHATSNEW =================================================================== RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.503.2.132 retrieving revision 1.503.2.133 diff -u -r1.503.2.132 -r1.503.2.133 --- WHATSNEW 6 Sep 2004 09:18:50 -0000 1.503.2.132 +++ WHATSNEW 10 Sep 2004 08:55:54 -0000 1.503.2.133 @@ -15,6 +15,8 @@ * Allow file attribute of <move> to rename a directory. Bugzilla Report 22863. +* Add xmlcatalog nested element to XmlProperty. Bugzilla report 27053. + Fixed bugs: ----------- 1.1.2.22 +1 -0 ant/CONTRIBUTORS Index: CONTRIBUTORS =================================================================== RCS file: /home/cvs/ant/CONTRIBUTORS,v retrieving revision 1.1.2.21 retrieving revision 1.1.2.22 diff -u -r1.1.2.21 -r1.1.2.22 --- CONTRIBUTORS 17 Jul 2004 15:13:47 -0000 1.1.2.21 +++ CONTRIBUTORS 10 Sep 2004 08:55:54 -0000 1.1.2.22 @@ -39,6 +39,7 @@ Danno Ferrin Davanum Srinivas David A. Herman +David Crossley David Kavanagh David Maclean David Rees No revision No revision 1.18.2.5 +66 -4 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.18.2.4 retrieving revision 1.18.2.5 diff -u -r1.18.2.4 -r1.18.2.5 --- XmlProperty.java 9 Mar 2004 17:01:34 -0000 1.18.2.4 +++ XmlProperty.java 10 Sep 2004 08:55:54 -0000 1.18.2.5 @@ -21,10 +21,12 @@ import java.io.IOException; import java.util.Hashtable; import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.ParserConfigurationException; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.XMLCatalog; import org.apache.tools.ant.util.FileUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -32,6 +34,7 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; +import org.xml.sax.EntityResolver; /** * Loads property values from a valid XML file, generating the @@ -178,6 +181,7 @@ private File rootDirectory = null; private FileUtils fileUtils = FileUtils.newFileUtils(); private Hashtable addedAttributes = new Hashtable(); + private XMLCatalog xmlCatalog = new XMLCatalog(); private static final String ID = "id"; private static final String REF_ID = "refid"; @@ -202,6 +206,15 @@ public void init() { super.init(); + xmlCatalog.setProject(getProject()); + } + + + /** + * @return the xmlCatalog as the entityresolver. + */ + protected EntityResolver getEntityResolver() { + return xmlCatalog; } /** @@ -226,7 +239,9 @@ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(validate); factory.setNamespaceAware(false); - Document document = factory.newDocumentBuilder().parse(src); + DocumentBuilder builder = factory.newDocumentBuilder(); + builder.setEntityResolver(getEntityResolver()); + Document document = builder.parse(src); Element topElement = document.getDocumentElement(); // Keep a hashtable of attributes added by this task. @@ -571,48 +586,95 @@ this.collapseAttributes = collapseAttributes; } - public void setSemanticAttributes (boolean semanticAttributes) { + /** + * Attribute to enable special handling of attributes - see ant manual. + * @param semanticAttributes if true enable the special handling. + */ + public void setSemanticAttributes(boolean semanticAttributes) { this.semanticAttributes = semanticAttributes; } - public void setRootDirectory (File rootDirectory) { + /** + * The directory to use for resolving file references. + * Ignored if semanticAttributes is not set to true. + * @param rootDirectory the directory. + */ + public void setRootDirectory(File rootDirectory) { this.rootDirectory = rootDirectory; } - public void setIncludeSemanticAttribute (boolean includeSemanticAttribute) { + /** + * Include the semantic attribute name as part of the property name. + * Ignored if semanticAttributes is not set to true. + * @param includeSemanticAttribute if true include the sematic attribute + * name. + */ + public void setIncludeSemanticAttribute(boolean includeSemanticAttribute) { this.includeSemanticAttribute = includeSemanticAttribute; } + /** + * add an XMLCatalog as a nested element; optional. + * @param catalog the XMLCatalog to use + */ + public void addConfiguredXMLCatalog(XMLCatalog catalog) { + xmlCatalog.addConfiguredXMLCatalog(catalog); + } + /* Expose members for extensibility */ + /** + * @return the file attribute. + */ protected File getFile () { return this.src; } + /** + * @return the prefix attribute. + */ protected String getPrefix () { return this.prefix; } + /** + * @return the keeproot attribute. + */ protected boolean getKeeproot () { return this.keepRoot; } + /** + * @return the validate attribute. + */ protected boolean getValidate () { return this.validate; } + /** + * @return the collapse attributes attribute. + */ protected boolean getCollapseAttributes () { return this.collapseAttributes; } + /** + * @return the semantic attributes attribute. + */ protected boolean getSemanticAttributes () { return this.semanticAttributes; } + /** + * @return the root directory attribute. + */ protected File getRootDirectory () { return this.rootDirectory; } + /** + * @return the include semantic attribute. + */ protected boolean getIncludeSementicAttribute () { return this.includeSemanticAttribute; } No revision No revision 1.4.2.5 +5 -0 ant/docs/manual/CoreTasks/xmlproperty.html Index: xmlproperty.html =================================================================== RCS file: /home/cvs/ant/docs/manual/CoreTasks/xmlproperty.html,v retrieving revision 1.4.2.4 retrieving revision 1.4.2.5 diff -u -r1.4.2.4 -r1.4.2.5 --- xmlproperty.html 9 Feb 2004 22:12:07 -0000 1.4.2.4 +++ xmlproperty.html 10 Sep 2004 08:55:54 -0000 1.4.2.5 @@ -132,6 +132,11 @@ </tr> </table> +<h3><a name="nested">Nested Elements</a></h3> +<h4>xmlcatalog</h4> +<p>The <a href="../CoreTypes/xmlcatalog.html"><tt><xmlcatalog></tt></a> +element is used to perform entity resolution.</p> + <a name="examples"> <h3>Examples</h3> </a> No revision No revision 1.2.2.1 +10 -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.2 retrieving revision 1.2.2.1 diff -u -r1.2 -r1.2.2.1 --- xmlproperty.xml 23 Jul 2003 12:11:09 -0000 1.2 +++ xmlproperty.xml 10 Sep 2004 08:55:54 -0000 1.2.2.1 @@ -7,4 +7,14 @@ <target name="testdtd"> <xmlproperty file="xmlproperty_withdtd.xml"/> </target> + + <target name="testneedscat"> + <xmlproperty file="xmlproperty_needscat.xml"> + <xmlcatalog> + <dtd publicId="-//FOO//DTD Skin Configuration V0.1//EN" + location="skinconfig.dtd"/> + </xmlcatalog> + </xmlproperty> + </target> + </project> No revision Index: xmlproperty.xml =================================================================== RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/xmlproperty.xml,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -r1.2 -r1.2.2.1 --- xmlproperty.xml 23 Jul 2003 12:11:09 -0000 1.2 +++ xmlproperty.xml 10 Sep 2004 08:55:54 -0000 1.2.2.1 @@ -7,4 +7,14 @@ <target name="testdtd"> <xmlproperty file="xmlproperty_withdtd.xml"/> </target> + + <target name="testneedscat"> + <xmlproperty file="xmlproperty_needscat.xml"> + <xmlcatalog> + <dtd publicId="-//FOO//DTD Skin Configuration V0.1//EN" + location="skinconfig.dtd"/> + </xmlcatalog> + </xmlproperty> + </target> + </project> No revision Index: xmlproperty.xml =================================================================== RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/xmlproperty.xml,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -r1.2 -r1.2.2.1 --- xmlproperty.xml 23 Jul 2003 12:11:09 -0000 1.2 +++ xmlproperty.xml 10 Sep 2004 08:55:54 -0000 1.2.2.1 @@ -7,4 +7,14 @@ <target name="testdtd"> <xmlproperty file="xmlproperty_withdtd.xml"/> </target> + + <target name="testneedscat"> + <xmlproperty file="xmlproperty_needscat.xml"> + <xmlcatalog> + <dtd publicId="-//FOO//DTD Skin Configuration V0.1//EN" + location="skinconfig.dtd"/> + </xmlcatalog> + </xmlproperty> + </target> + </project> 1.1.2.1 +0 -0 ant/src/etc/testcases/taskdefs/xmlproperty_needscat.xml Index: xmlproperty_needscat.xml =================================================================== RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/xmlproperty_needscat.xml,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 1.1.2.1 +0 -0 ant/src/etc/testcases/taskdefs/skinconfig.dtd Index: skinconfig.dtd =================================================================== RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/skinconfig.dtd,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 No revision No revision 1.8.2.5 +5 -0 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.8.2.4 retrieving revision 1.8.2.5 diff -u -r1.8.2.4 -r1.8.2.5 --- XmlPropertyTest.java 9 Mar 2004 17:02:02 -0000 1.8.2.4 +++ XmlPropertyTest.java 10 Sep 2004 08:55:55 -0000 1.8.2.5 @@ -104,6 +104,11 @@ doTest("testSemanticInclude", false, false, true, false, true); } + public void testNeedsCatalog() { + executeTarget("testneedscat"); + assertEquals("true", getProject().getProperty("skinconfig.foo")); + } + /** * Actually run a test, finding all input files (and corresponding * goldfile)
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]