Browse Source

remove catalogfiles from xmlcatalog

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273638 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
ef9539bad9
3 changed files with 14 additions and 78 deletions
  1. +2
    -9
      docs/manual/CoreTypes/xmlcatalog.html
  2. +6
    -2
      src/etc/testcases/taskdefs/optional/xmlvalidate.xml
  3. +6
    -67
      src/main/org/apache/tools/ant/types/XMLCatalog.java

+ 2
- 9
docs/manual/CoreTypes/xmlcatalog.html View File

@@ -84,8 +84,8 @@ href="http://oasis-open.org/committees/entity/background/9401.html">
plain text format</a> or <a
href="http://www.oasis-open.org/committees/entity/spec-2001-08-06.html">
XML format</a>. If the xml-commons resolver library is not found in the
classpath, external catalog files, specified in <code>catalogpath</code> (or
the deprecated <code>catalogfiles</code>) , will be ignored and a warning
classpath, external catalog files, specified in <code>catalogpath</code>,
will be ignored and a warning
will be logged. In this case, however, processing of inline entries will
proceed normally.</p>
<p>Currently, only <code>&lt;dtd&gt;</code> and
@@ -221,13 +221,6 @@ XML format</a>. Entries specifying nonexistent files will be ignored. If the
resolver library from xml-commons is not available in the classpath, all
<code>catalogpaths</code> will be ignored and a warning will be logged.
</p>
<h4>catalogfiles (deprecated)</h4>
<p>
The nested <code>catalogfiles</code> element specifies a <a
href="../CoreTypes/fileset.html">FileSet</a>. This is equivalent to
specifying a <code>&lt;fileset&gt;</code> inside a <code>catalogpath</code>,
and is retained for backwards-compatibility.
</p>
<h3>Examples</h3>
<p>Set up an XMLCatalog with a single dtd referenced locally in a user's
home


+ 6
- 2
src/etc/testcases/taskdefs/optional/xmlvalidate.xml View File

@@ -44,7 +44,9 @@
<xmlvalidate warn="false">
<fileset dir="xml" includes="**/about.xml"/>
<xmlcatalog classpath="xml">
<catalogfiles dir="xml" includes="catalog"/>
<catalogpath>
<fileset dir="xml" includes="catalog"/>
</catalogpath>
<dtd publicID="-//stevo//DTD doc 1.0//EN"
location="doc.dtd"/>
</xmlcatalog>
@@ -68,7 +70,9 @@
<xmlvalidate warn="false">
<fileset dir="xml" includes="**/about.xml"/>
<xmlcatalog classpath="xml">
<catalogfiles dir="xml" includes="catalog"/>
<catalogpath>
<fileset dir="xml" includes="catalog"/>
</catalogpath>
</xmlcatalog>
</xmlvalidate>
</target>


+ 6
- 67
src/main/org/apache/tools/ant/types/XMLCatalog.java View File

@@ -104,13 +104,9 @@ import org.xml.sax.XMLReader;
* href="http://www.oasis-open.org/committees/entity/spec-2001-08-06.html">
* XML format</a>. If the xml-commons resolver library is not found
* in the classpath, external catalog files, specified in
* <code>&lt;catalogfiles&gt;</code> filesets and
* <code>&lt;catalogpath&gt;</code> paths, will be ignored and a warning will
* be logged. In this case, however, processing of inline entries will proceed
* normally.</p>
* <p>Note that, as <code>&lt;catalogpath&gt;</code> can contain nested
* filesets, it is more general than <code>&lt;catalogfiles&gt;</code>, which
* should be considered deprecated.</p>
*
* <p>Currently, only <code>&lt;dtd&gt;</code> and
* <code>&lt;entity&gt;</code> elements may be specified inline; these
@@ -168,7 +164,7 @@ public class XMLCatalog extends DataType

//-- Fields ----------------------------------------------------------------

/** Holds dtd/entity objects and catalog filesets until needed. */
/** Holds dtd/entity objects until needed. */
private Vector elements = new Vector();

/**
@@ -196,11 +192,9 @@ public class XMLCatalog extends DataType
}

/**
* Returns the elements of the catalog - ResourceLocation and FileSet
* objects.
* Returns the elements of the catalog - ResourceLocation objects.
*
* @return the elements of the catalog - ResourceLocation and FileSet
* objects
* @return the elements of the catalog - ResourceLocation objects
*/
private Vector getElements() {
return elements;
@@ -216,12 +210,12 @@ public class XMLCatalog extends DataType
}

/**
* Set the list of ResourceLocation objects and FileSets in the catalog.
* Set the list of ResourceLocation objects in the catalog.
* Not allowed if this catalog is itself a reference to another catalog --
* that is, a catalog cannot both refer to another <em>and</em> contain
* elements or other attributes.
*
* @param aVector the new list of ResourceLocations and FileSets
* @param aVector the new list of ResourceLocations
* to use in the catalog.
*/
private void setElements(Vector aVector) {
@@ -280,30 +274,11 @@ public class XMLCatalog extends DataType
setChecked( false );
}

/**
* Creates the nested <code>&lt;catalogfiles&gt;</code> element.
* Not allowed if this catalog is itself a reference to another
* catalog -- that is, a catalog cannot both refer to another
* <em>and</em> contain elements or other attributes.
*
* @param fs the fileset of external catalogs.
* @exception BuildException
* if this is a reference and no nested elements are allowed.
*/
public void addCatalogfiles(FileSet fs) throws BuildException {
if (isReference()) {
throw noChildrenAllowed();
}
getElements().addElement(fs);
}


/** Creates a nested <code>&lt;catalogpath&gt;</code> element.
* Not allowed if this catalog is itself a reference to another
* catalog -- that is, a catalog cannot both refer to another
* <em>and</em> contain elements or other attributes.
*
* @param fs the fileset of external catalogs.
* @exception BuildException
* if this is a reference and no nested elements are allowed.
*/
@@ -559,19 +534,6 @@ public class XMLCatalog extends DataType
// available, so we can't use it.
//
catalogResolver = new InternalResolver();
//
// If any <catalogfiles> are specified, warn that they
// will be ignored.
//
Enumeration enum = getElements().elements();
while (enum.hasMoreElements()) {
Object o = enum.nextElement();
if (o instanceof FileSet) {
log("Warning: External catalogfiles will be ignored",
Project.MSG_WARN);
break;
}
}
if (getCatalogPath() != null &&
getCatalogPath().list().length != 0) {
log("Warning: catalogpath listing external catalogs"+
@@ -1125,7 +1087,7 @@ public class XMLCatalog extends DataType

/**
* Process each external catalog file specified in a
* <code>&lt;catalogfiles&gt;</code> FileSet. It will be
* <code>&lt;catalogpath&gt;</code>. It will be
* parsed by the resolver library, and the individual elements
* will be added back to us (that is, the controlling
* XMLCatalog instance) via a callback mechanism.
@@ -1143,29 +1105,6 @@ public class XMLCatalog extends DataType
throw new BuildException(ex);
}

// Parse each catalog listed in nested <catalogfile> elements.
Enumeration enum = getElements().elements();
while (enum.hasMoreElements()) {
Object o = enum.nextElement();
if (o instanceof FileSet) {
FileSet fs = (FileSet)o;
DirectoryScanner ds =
fs.getDirectoryScanner(getProject());
String[] files = ds.getIncludedFiles();
for (int i = 0; i < files.length; i++) {
File catFile = new File(ds.getBasedir(), files[i]);
try {
parseCatalog.invoke(resolverImpl,
new Object[]
{ catFile.getPath() });
}
catch (Exception ex) {
throw new BuildException(ex);
}
}
}
}

// Parse each catalog listed in nested <catalogpath> elements
Path catPath = getCatalogPath();
if (catPath != null) {


Loading…
Cancel
Save