Rely on the catalog for which we are reading to provide the debug object for printing messages.
git-svn-id: https://svn.apache.org/repos/asf/xml/commons/trunk@226009 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
60a2439163
commit
ec123dbb6d
@ -229,11 +229,12 @@ public class DOMCatalogReader implements CatalogReader {
|
||||
|
||||
if (domParserClass == null) {
|
||||
if (namespaceURI == null) {
|
||||
Debug.message(1, "No Catalog parser for " + localName);
|
||||
catalog.getCatalogManager().debug.message(1, "No Catalog parser for "
|
||||
+ localName);
|
||||
} else {
|
||||
Debug.message(1, "No Catalog parser for "
|
||||
+ "{" + namespaceURI + "}"
|
||||
+ localName);
|
||||
catalog.getCatalogManager().debug.message(1, "No Catalog parser for "
|
||||
+ "{" + namespaceURI + "}"
|
||||
+ localName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -243,16 +244,16 @@ public class DOMCatalogReader implements CatalogReader {
|
||||
try {
|
||||
domParser = (DOMCatalogParser) Class.forName(domParserClass).newInstance();
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
Debug.message(1, "Cannot load XML Catalog Parser class", domParserClass);
|
||||
catalog.getCatalogManager().debug.message(1, "Cannot load XML Catalog Parser class", domParserClass);
|
||||
throw new CatalogException(CatalogException.UNPARSEABLE);
|
||||
} catch (InstantiationException ie) {
|
||||
Debug.message(1, "Cannot instantiate XML Catalog Parser class", domParserClass);
|
||||
catalog.getCatalogManager().debug.message(1, "Cannot instantiate XML Catalog Parser class", domParserClass);
|
||||
throw new CatalogException(CatalogException.UNPARSEABLE);
|
||||
} catch (IllegalAccessException iae) {
|
||||
Debug.message(1, "Cannot access XML Catalog Parser class", domParserClass);
|
||||
catalog.getCatalogManager().debug.message(1, "Cannot access XML Catalog Parser class", domParserClass);
|
||||
throw new CatalogException(CatalogException.UNPARSEABLE);
|
||||
} catch (ClassCastException cce ) {
|
||||
Debug.message(1, "Cannot cast XML Catalog Parser class", domParserClass);
|
||||
catalog.getCatalogManager().debug.message(1, "Cannot cast XML Catalog Parser class", domParserClass);
|
||||
throw new CatalogException(CatalogException.UNPARSEABLE);
|
||||
}
|
||||
|
||||
|
||||
@ -132,16 +132,16 @@ public class ExtendedXMLCatalogReader extends OASISXMLCatalogReader {
|
||||
entryArgs.add(baseURI);
|
||||
baseURIStack.push(baseURI);
|
||||
|
||||
Debug.message(4, "xml:base", baseURI);
|
||||
debug.message(4, "xml:base", baseURI);
|
||||
|
||||
try {
|
||||
CatalogEntry ce = new CatalogEntry(entryType, entryArgs);
|
||||
catalog.addEntry(ce);
|
||||
} catch (CatalogException cex) {
|
||||
if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
|
||||
Debug.message(1, "Invalid catalog entry type", localName);
|
||||
debug.message(1, "Invalid catalog entry type", localName);
|
||||
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
|
||||
Debug.message(1, "Invalid catalog entry (base)", localName);
|
||||
debug.message(1, "Invalid catalog entry (base)", localName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ public class ExtendedXMLCatalogReader extends OASISXMLCatalogReader {
|
||||
entryArgs.add(atts.getValue("suffix"));
|
||||
entryArgs.add(atts.getValue("uri"));
|
||||
|
||||
Debug.message(4, "uriSuffix",
|
||||
debug.message(4, "uriSuffix",
|
||||
atts.getValue("suffix"),
|
||||
atts.getValue("uri"));
|
||||
}
|
||||
@ -167,13 +167,13 @@ public class ExtendedXMLCatalogReader extends OASISXMLCatalogReader {
|
||||
entryArgs.add(atts.getValue("suffix"));
|
||||
entryArgs.add(atts.getValue("uri"));
|
||||
|
||||
Debug.message(4, "systemSuffix",
|
||||
debug.message(4, "systemSuffix",
|
||||
atts.getValue("suffix"),
|
||||
atts.getValue("uri"));
|
||||
}
|
||||
} else {
|
||||
// This is equivalent to an invalid catalog entry type
|
||||
Debug.message(1, "Invalid catalog entry type", localName);
|
||||
debug.message(1, "Invalid catalog entry type", localName);
|
||||
}
|
||||
|
||||
if (entryType >= 0) {
|
||||
@ -182,9 +182,9 @@ public class ExtendedXMLCatalogReader extends OASISXMLCatalogReader {
|
||||
catalog.addEntry(ce);
|
||||
} catch (CatalogException cex) {
|
||||
if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
|
||||
Debug.message(1, "Invalid catalog entry type", localName);
|
||||
debug.message(1, "Invalid catalog entry type", localName);
|
||||
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
|
||||
Debug.message(1, "Invalid catalog entry", localName);
|
||||
debug.message(1, "Invalid catalog entry", localName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -217,16 +217,16 @@ public class ExtendedXMLCatalogReader extends OASISXMLCatalogReader {
|
||||
entryType = catalog.BASE;
|
||||
entryArgs.add(baseURI);
|
||||
|
||||
Debug.message(4, "(reset) xml:base", baseURI);
|
||||
debug.message(4, "(reset) xml:base", baseURI);
|
||||
|
||||
try {
|
||||
CatalogEntry ce = new CatalogEntry(entryType, entryArgs);
|
||||
catalog.addEntry(ce);
|
||||
} catch (CatalogException cex) {
|
||||
if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
|
||||
Debug.message(1, "Invalid catalog entry type", localName);
|
||||
debug.message(1, "Invalid catalog entry type", localName);
|
||||
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
|
||||
Debug.message(1, "Invalid catalog entry (rbase)", localName);
|
||||
debug.message(1, "Invalid catalog entry (rbase)", localName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,8 +91,8 @@ import org.w3c.dom.*;
|
||||
*/
|
||||
public class OASISXMLCatalogReader extends SAXCatalogReader implements SAXCatalogParser {
|
||||
/** The catalog object needs to be stored by the object so that
|
||||
* SAX callbacks can use it.
|
||||
*/
|
||||
* SAX callbacks can use it.
|
||||
*/
|
||||
protected Catalog catalog = null;
|
||||
|
||||
/** The namespace name of OASIS ERTC catalogs */
|
||||
@ -108,6 +108,7 @@ public class OASISXMLCatalogReader extends SAXCatalogReader implements SAXCatalo
|
||||
/** Set the current catalog. */
|
||||
public void setCatalog (Catalog catalog) {
|
||||
this.catalog = catalog;
|
||||
debug = catalog.getCatalogManager().debug;
|
||||
}
|
||||
|
||||
/** Get the current catalog. */
|
||||
@ -195,16 +196,16 @@ public class OASISXMLCatalogReader extends SAXCatalogReader implements SAXCatalo
|
||||
entryArgs.add(baseURI);
|
||||
baseURIStack.push(baseURI);
|
||||
|
||||
Debug.message(4, "xml:base", baseURI);
|
||||
debug.message(4, "xml:base", baseURI);
|
||||
|
||||
try {
|
||||
CatalogEntry ce = new CatalogEntry(entryType, entryArgs);
|
||||
catalog.addEntry(ce);
|
||||
} catch (CatalogException cex) {
|
||||
if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
|
||||
Debug.message(1, "Invalid catalog entry type", localName);
|
||||
debug.message(1, "Invalid catalog entry type", localName);
|
||||
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
|
||||
Debug.message(1, "Invalid catalog entry (base)", localName);
|
||||
debug.message(1, "Invalid catalog entry (base)", localName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -224,7 +225,7 @@ public class OASISXMLCatalogReader extends SAXCatalogReader implements SAXCatalo
|
||||
} else if (override.equals("system")) {
|
||||
override = "no";
|
||||
} else {
|
||||
Debug.message(1,
|
||||
debug.message(1,
|
||||
"Invalid prefer: must be 'system' or 'public'",
|
||||
localName);
|
||||
override = catalog.getDefaultOverride();
|
||||
@ -234,16 +235,16 @@ public class OASISXMLCatalogReader extends SAXCatalogReader implements SAXCatalo
|
||||
entryArgs.add(override);
|
||||
overrideStack.push(override);
|
||||
|
||||
Debug.message(4, "override", override);
|
||||
debug.message(4, "override", override);
|
||||
|
||||
try {
|
||||
CatalogEntry ce = new CatalogEntry(entryType, entryArgs);
|
||||
catalog.addEntry(ce);
|
||||
} catch (CatalogException cex) {
|
||||
if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
|
||||
Debug.message(1, "Invalid catalog entry type", localName);
|
||||
debug.message(1, "Invalid catalog entry type", localName);
|
||||
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
|
||||
Debug.message(1, "Invalid catalog entry (override)", localName);
|
||||
debug.message(1, "Invalid catalog entry (override)", localName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,7 +261,7 @@ public class OASISXMLCatalogReader extends SAXCatalogReader implements SAXCatalo
|
||||
entryArgs.add(atts.getValue("publicIdStartString"));
|
||||
entryArgs.add(atts.getValue("catalog"));
|
||||
|
||||
Debug.message(4, "delegatePublic",
|
||||
debug.message(4, "delegatePublic",
|
||||
PublicId.normalize(atts.getValue("publicIdStartString")),
|
||||
atts.getValue("catalog"));
|
||||
}
|
||||
@ -270,7 +271,7 @@ public class OASISXMLCatalogReader extends SAXCatalogReader implements SAXCatalo
|
||||
entryArgs.add(atts.getValue("systemIdStartString"));
|
||||
entryArgs.add(atts.getValue("catalog"));
|
||||
|
||||
Debug.message(4, "delegateSystem",
|
||||
debug.message(4, "delegateSystem",
|
||||
atts.getValue("systemIdStartString"),
|
||||
atts.getValue("catalog"));
|
||||
}
|
||||
@ -280,7 +281,7 @@ public class OASISXMLCatalogReader extends SAXCatalogReader implements SAXCatalo
|
||||
entryArgs.add(atts.getValue("uriStartString"));
|
||||
entryArgs.add(atts.getValue("catalog"));
|
||||
|
||||
Debug.message(4, "delegateURI",
|
||||
debug.message(4, "delegateURI",
|
||||
atts.getValue("uriStartString"),
|
||||
atts.getValue("catalog"));
|
||||
}
|
||||
@ -290,7 +291,7 @@ public class OASISXMLCatalogReader extends SAXCatalogReader implements SAXCatalo
|
||||
entryArgs.add(atts.getValue("systemIdStartString"));
|
||||
entryArgs.add(atts.getValue("rewritePrefix"));
|
||||
|
||||
Debug.message(4, "rewriteSystem",
|
||||
debug.message(4, "rewriteSystem",
|
||||
atts.getValue("systemIdStartString"),
|
||||
atts.getValue("rewritePrefix"));
|
||||
}
|
||||
@ -300,7 +301,7 @@ public class OASISXMLCatalogReader extends SAXCatalogReader implements SAXCatalo
|
||||
entryArgs.add(atts.getValue("uriStartString"));
|
||||
entryArgs.add(atts.getValue("rewritePrefix"));
|
||||
|
||||
Debug.message(4, "rewriteURI",
|
||||
debug.message(4, "rewriteURI",
|
||||
atts.getValue("uriStartString"),
|
||||
atts.getValue("rewritePrefix"));
|
||||
}
|
||||
@ -309,7 +310,7 @@ public class OASISXMLCatalogReader extends SAXCatalogReader implements SAXCatalo
|
||||
entryType = Catalog.CATALOG;
|
||||
entryArgs.add(atts.getValue("catalog"));
|
||||
|
||||
Debug.message(4, "nextCatalog", atts.getValue("catalog"));
|
||||
debug.message(4, "nextCatalog", atts.getValue("catalog"));
|
||||
}
|
||||
} else if (localName.equals("public")) {
|
||||
if (checkAttributes(atts, "publicId", "uri")) {
|
||||
@ -317,7 +318,7 @@ public class OASISXMLCatalogReader extends SAXCatalogReader implements SAXCatalo
|
||||
entryArgs.add(atts.getValue("publicId"));
|
||||
entryArgs.add(atts.getValue("uri"));
|
||||
|
||||
Debug.message(4, "public",
|
||||
debug.message(4, "public",
|
||||
PublicId.normalize(atts.getValue("publicId")),
|
||||
atts.getValue("uri"));
|
||||
}
|
||||
@ -327,7 +328,7 @@ public class OASISXMLCatalogReader extends SAXCatalogReader implements SAXCatalo
|
||||
entryArgs.add(atts.getValue("systemId"));
|
||||
entryArgs.add(atts.getValue("uri"));
|
||||
|
||||
Debug.message(4, "system",
|
||||
debug.message(4, "system",
|
||||
atts.getValue("systemId"),
|
||||
atts.getValue("uri"));
|
||||
}
|
||||
@ -337,7 +338,7 @@ public class OASISXMLCatalogReader extends SAXCatalogReader implements SAXCatalo
|
||||
entryArgs.add(atts.getValue("name"));
|
||||
entryArgs.add(atts.getValue("uri"));
|
||||
|
||||
Debug.message(4, "uri",
|
||||
debug.message(4, "uri",
|
||||
atts.getValue("name"),
|
||||
atts.getValue("uri"));
|
||||
}
|
||||
@ -347,7 +348,7 @@ public class OASISXMLCatalogReader extends SAXCatalogReader implements SAXCatalo
|
||||
// nop, a group
|
||||
} else {
|
||||
// This is equivalent to an invalid catalog entry type
|
||||
Debug.message(1, "Invalid catalog entry type", localName);
|
||||
debug.message(1, "Invalid catalog entry type", localName);
|
||||
}
|
||||
|
||||
if (entryType >= 0) {
|
||||
@ -356,9 +357,9 @@ public class OASISXMLCatalogReader extends SAXCatalogReader implements SAXCatalo
|
||||
catalog.addEntry(ce);
|
||||
} catch (CatalogException cex) {
|
||||
if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
|
||||
Debug.message(1, "Invalid catalog entry type", localName);
|
||||
debug.message(1, "Invalid catalog entry type", localName);
|
||||
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
|
||||
Debug.message(1, "Invalid catalog entry", localName);
|
||||
debug.message(1, "Invalid catalog entry", localName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -374,16 +375,16 @@ public class OASISXMLCatalogReader extends SAXCatalogReader implements SAXCatalo
|
||||
entryArgs.add(baseURI);
|
||||
baseURIStack.push(baseURI);
|
||||
|
||||
Debug.message(4, "xml:base", baseURI);
|
||||
debug.message(4, "xml:base", baseURI);
|
||||
|
||||
try {
|
||||
CatalogEntry ce = new CatalogEntry(entryType, entryArgs);
|
||||
catalog.addEntry(ce);
|
||||
} catch (CatalogException cex) {
|
||||
if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
|
||||
Debug.message(1, "Invalid catalog entry type", localName);
|
||||
debug.message(1, "Invalid catalog entry type", localName);
|
||||
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
|
||||
Debug.message(1, "Invalid catalog entry (base)", localName);
|
||||
debug.message(1, "Invalid catalog entry (base)", localName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -422,7 +423,7 @@ public class OASISXMLCatalogReader extends SAXCatalogReader implements SAXCatalo
|
||||
entryArgs.add(atts.getValue("uri"));
|
||||
} else {
|
||||
// This is equivalent to an invalid catalog entry type
|
||||
Debug.message(1, "Invalid catalog entry type", localName);
|
||||
debug.message(1, "Invalid catalog entry type", localName);
|
||||
}
|
||||
|
||||
if (entryType >= 0) {
|
||||
@ -431,9 +432,9 @@ public class OASISXMLCatalogReader extends SAXCatalogReader implements SAXCatalo
|
||||
catalog.addEntry(ce);
|
||||
} catch (CatalogException cex) {
|
||||
if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
|
||||
Debug.message(1, "Invalid catalog entry type", localName);
|
||||
debug.message(1, "Invalid catalog entry type", localName);
|
||||
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
|
||||
Debug.message(1, "Invalid catalog entry", localName);
|
||||
debug.message(1, "Invalid catalog entry", localName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -442,7 +443,7 @@ public class OASISXMLCatalogReader extends SAXCatalogReader implements SAXCatalo
|
||||
|
||||
public boolean checkAttributes (Attributes atts, String attName) {
|
||||
if (atts.getValue(attName) == null) {
|
||||
Debug.message(1, "Error: required attribute " + attName + " missing.");
|
||||
debug.message(1, "Error: required attribute " + attName + " missing.");
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
@ -479,16 +480,16 @@ public class OASISXMLCatalogReader extends SAXCatalogReader implements SAXCatalo
|
||||
entryType = catalog.BASE;
|
||||
entryArgs.add(baseURI);
|
||||
|
||||
Debug.message(4, "(reset) xml:base", baseURI);
|
||||
debug.message(4, "(reset) xml:base", baseURI);
|
||||
|
||||
try {
|
||||
CatalogEntry ce = new CatalogEntry(entryType, entryArgs);
|
||||
catalog.addEntry(ce);
|
||||
} catch (CatalogException cex) {
|
||||
if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
|
||||
Debug.message(1, "Invalid catalog entry type", localName);
|
||||
debug.message(1, "Invalid catalog entry type", localName);
|
||||
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
|
||||
Debug.message(1, "Invalid catalog entry (rbase)", localName);
|
||||
debug.message(1, "Invalid catalog entry (rbase)", localName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -505,16 +506,16 @@ public class OASISXMLCatalogReader extends SAXCatalogReader implements SAXCatalo
|
||||
entryArgs.add(override);
|
||||
overrideStack.push(override);
|
||||
|
||||
Debug.message(4, "(reset) override", override);
|
||||
debug.message(4, "(reset) override", override);
|
||||
|
||||
try {
|
||||
CatalogEntry ce = new CatalogEntry(entryType, entryArgs);
|
||||
catalog.addEntry(ce);
|
||||
} catch (CatalogException cex) {
|
||||
if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
|
||||
Debug.message(1, "Invalid catalog entry type", localName);
|
||||
debug.message(1, "Invalid catalog entry type", localName);
|
||||
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
|
||||
Debug.message(1, "Invalid catalog entry (roverride)", localName);
|
||||
debug.message(1, "Invalid catalog entry (roverride)", localName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,6 +71,7 @@ import java.net.URLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.UnknownHostException;
|
||||
import org.apache.xml.resolver.Catalog;
|
||||
import org.apache.xml.resolver.CatalogManager;
|
||||
import org.apache.xml.resolver.CatalogEntry;
|
||||
import org.apache.xml.resolver.CatalogException;
|
||||
import org.apache.xml.resolver.readers.CatalogReader;
|
||||
@ -159,6 +160,33 @@ public class SAXCatalogReader implements CatalogReader, ContentHandler, Document
|
||||
return parserClass;
|
||||
}
|
||||
|
||||
/** The debug class to use for this reader.
|
||||
*
|
||||
* This is a bit of a hack. Anyway, whenever we read for a catalog,
|
||||
* we extract the debug object
|
||||
* from the catalog's manager so that we can use it to print messages.
|
||||
*
|
||||
* In production, we don't really expect any messages so it doesn't
|
||||
* really matter. But it's still a bit of a hack.
|
||||
*/
|
||||
protected Debug debug = CatalogManager.getStaticManager().debug;
|
||||
|
||||
/** The constructor */
|
||||
public SAXCatalogReader() {
|
||||
parserFactory = null;
|
||||
parserClass = null;
|
||||
}
|
||||
|
||||
/** The constructor */
|
||||
public SAXCatalogReader(SAXParserFactory parserFactory) {
|
||||
this.parserFactory = parserFactory;
|
||||
}
|
||||
|
||||
/** The constructor */
|
||||
public SAXCatalogReader(String parserClass) {
|
||||
this.parserClass = parserClass;
|
||||
}
|
||||
|
||||
/** Set the SAXCatalogParser class for the given namespace/root
|
||||
* element type.
|
||||
*/
|
||||
@ -184,22 +212,6 @@ public class SAXCatalogReader implements CatalogReader, ContentHandler, Document
|
||||
}
|
||||
}
|
||||
|
||||
/** The constructor */
|
||||
public SAXCatalogReader() {
|
||||
parserFactory = null;
|
||||
parserClass = null;
|
||||
}
|
||||
|
||||
/** The constructor */
|
||||
public SAXCatalogReader(SAXParserFactory parserFactory) {
|
||||
this.parserFactory = parserFactory;
|
||||
}
|
||||
|
||||
/** The constructor */
|
||||
public SAXCatalogReader(String parserClass) {
|
||||
this.parserClass = parserClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Parse an XML Catalog file.</p>
|
||||
*
|
||||
@ -221,11 +233,13 @@ public class SAXCatalogReader implements CatalogReader, ContentHandler, Document
|
||||
url = new URL("file:///" + fileUrl);
|
||||
}
|
||||
|
||||
debug = catalog.getCatalogManager().debug;
|
||||
|
||||
try {
|
||||
URLConnection urlCon = url.openConnection();
|
||||
readCatalog(catalog, urlCon.getInputStream());
|
||||
} catch (FileNotFoundException e) {
|
||||
Debug.message(1, "Failed to load catalog, file not found",
|
||||
catalog.getCatalogManager().debug.message(1, "Failed to load catalog, file not found",
|
||||
url.toString());
|
||||
}
|
||||
}
|
||||
@ -245,10 +259,12 @@ public class SAXCatalogReader implements CatalogReader, ContentHandler, Document
|
||||
|
||||
// Create an instance of the parser
|
||||
if (parserFactory == null && parserClass == null) {
|
||||
Debug.message(1, "Cannot read SAX catalog without a parser");
|
||||
debug.message(1, "Cannot read SAX catalog without a parser");
|
||||
throw new CatalogException(CatalogException.UNPARSEABLE);
|
||||
}
|
||||
|
||||
debug = catalog.getCatalogManager().debug;
|
||||
|
||||
this.catalog = catalog;
|
||||
|
||||
try {
|
||||
@ -350,9 +366,9 @@ public class SAXCatalogReader implements CatalogReader, ContentHandler, Document
|
||||
if (saxParserClass == null) {
|
||||
abandonHope = true;
|
||||
if (namespaceURI == null) {
|
||||
Debug.message(2, "No Catalog parser for " + name);
|
||||
debug.message(2, "No Catalog parser for " + name);
|
||||
} else {
|
||||
Debug.message(2, "No Catalog parser for "
|
||||
debug.message(2, "No Catalog parser for "
|
||||
+ "{" + namespaceURI + "}"
|
||||
+ name);
|
||||
}
|
||||
@ -369,19 +385,19 @@ public class SAXCatalogReader implements CatalogReader, ContentHandler, Document
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
saxParser = null;
|
||||
abandonHope = true;
|
||||
Debug.message(2, cnfe.toString());
|
||||
debug.message(2, cnfe.toString());
|
||||
} catch (InstantiationException ie) {
|
||||
saxParser = null;
|
||||
abandonHope = true;
|
||||
Debug.message(2, ie.toString());
|
||||
debug.message(2, ie.toString());
|
||||
} catch (IllegalAccessException iae) {
|
||||
saxParser = null;
|
||||
abandonHope = true;
|
||||
Debug.message(2, iae.toString());
|
||||
debug.message(2, iae.toString());
|
||||
} catch (ClassCastException cce ) {
|
||||
saxParser = null;
|
||||
abandonHope = true;
|
||||
Debug.message(2, cce.toString());
|
||||
debug.message(2, cce.toString());
|
||||
}
|
||||
} else {
|
||||
saxParser.startElement(name, atts);
|
||||
@ -411,9 +427,9 @@ public class SAXCatalogReader implements CatalogReader, ContentHandler, Document
|
||||
if (saxParserClass == null) {
|
||||
abandonHope = true;
|
||||
if (namespaceURI == null) {
|
||||
Debug.message(2, "No Catalog parser for " + localName);
|
||||
debug.message(2, "No Catalog parser for " + localName);
|
||||
} else {
|
||||
Debug.message(2, "No Catalog parser for "
|
||||
debug.message(2, "No Catalog parser for "
|
||||
+ "{" + namespaceURI + "}"
|
||||
+ localName);
|
||||
}
|
||||
@ -430,19 +446,19 @@ public class SAXCatalogReader implements CatalogReader, ContentHandler, Document
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
saxParser = null;
|
||||
abandonHope = true;
|
||||
Debug.message(2, cnfe.toString());
|
||||
debug.message(2, cnfe.toString());
|
||||
} catch (InstantiationException ie) {
|
||||
saxParser = null;
|
||||
abandonHope = true;
|
||||
Debug.message(2, ie.toString());
|
||||
debug.message(2, ie.toString());
|
||||
} catch (IllegalAccessException iae) {
|
||||
saxParser = null;
|
||||
abandonHope = true;
|
||||
Debug.message(2, iae.toString());
|
||||
debug.message(2, iae.toString());
|
||||
} catch (ClassCastException cce ) {
|
||||
saxParser = null;
|
||||
abandonHope = true;
|
||||
Debug.message(2, cce.toString());
|
||||
debug.message(2, cce.toString());
|
||||
}
|
||||
} else {
|
||||
saxParser.startElement(namespaceURI, localName, qName, atts);
|
||||
|
||||
@ -170,7 +170,7 @@ public class TR9401CatalogReader extends TextCatalogReader {
|
||||
}
|
||||
unknownEntry.addElement(token);
|
||||
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
|
||||
Debug.message(1, "Invalid catalog entry", token);
|
||||
catalog.getCatalogManager().debug.message(1, "Invalid catalog entry", token);
|
||||
unknownEntry = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,8 +147,8 @@ public class TextCatalogReader implements CatalogReader {
|
||||
try {
|
||||
readCatalog(catalog, urlCon.getInputStream());
|
||||
} catch (FileNotFoundException e) {
|
||||
Debug.message(1, "Failed to load catalog, file not found",
|
||||
catURL.toString());
|
||||
catalog.getCatalogManager().debug.message(1, "Failed to load catalog, file not found",
|
||||
catURL.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -205,7 +205,7 @@ public class TextCatalogReader implements CatalogReader {
|
||||
}
|
||||
unknownEntry.addElement(token);
|
||||
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
|
||||
Debug.message(1, "Invalid catalog entry", token);
|
||||
catalog.getCatalogManager().debug.message(1, "Invalid catalog entry", token);
|
||||
unknownEntry = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,45 +90,45 @@ import javax.xml.parsers.*;
|
||||
* @version 1.0
|
||||
*/
|
||||
public class XCatalogReader extends SAXCatalogReader implements SAXCatalogParser {
|
||||
/** The catalog object needs to be stored by the object so that
|
||||
* SAX callbacks can use it.
|
||||
*/
|
||||
protected Catalog catalog = null;
|
||||
/** The catalog object needs to be stored by the object so that
|
||||
* SAX callbacks can use it.
|
||||
*/
|
||||
protected Catalog catalog = null;
|
||||
|
||||
/** Set the current catalog. */
|
||||
public void setCatalog (Catalog catalog) {
|
||||
this.catalog = catalog;
|
||||
}
|
||||
/** Set the current catalog. */
|
||||
public void setCatalog (Catalog catalog) {
|
||||
this.catalog = catalog;
|
||||
}
|
||||
|
||||
/** Get the current catalog. */
|
||||
public Catalog getCatalog () {
|
||||
return catalog;
|
||||
}
|
||||
/** Get the current catalog. */
|
||||
public Catalog getCatalog () {
|
||||
return catalog;
|
||||
}
|
||||
|
||||
/** The constructor */
|
||||
public XCatalogReader(SAXParserFactory parserFactory) {
|
||||
super(parserFactory);
|
||||
}
|
||||
/** The constructor */
|
||||
public XCatalogReader(SAXParserFactory parserFactory) {
|
||||
super(parserFactory);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Implement the SAX DocumentHandler interface
|
||||
// ----------------------------------------------------------------------
|
||||
// Implement the SAX DocumentHandler interface
|
||||
|
||||
/** <p>The SAX <code>setDocumentLocator</code> method does nothing.</p> */
|
||||
public void setDocumentLocator (Locator locator) {
|
||||
return;
|
||||
}
|
||||
/** <p>The SAX <code>setDocumentLocator</code> method does nothing.</p> */
|
||||
public void setDocumentLocator (Locator locator) {
|
||||
return;
|
||||
}
|
||||
|
||||
/** <p>The SAX <code>startDocument</code> method does nothing.</p> */
|
||||
public void startDocument ()
|
||||
throws SAXException {
|
||||
return;
|
||||
}
|
||||
/** <p>The SAX <code>startDocument</code> method does nothing.</p> */
|
||||
public void startDocument ()
|
||||
throws SAXException {
|
||||
return;
|
||||
}
|
||||
|
||||
/** <p>The SAX <code>endDocument</code> method does nothing.</p> */
|
||||
public void endDocument ()
|
||||
throws SAXException {
|
||||
return;
|
||||
}
|
||||
/** <p>The SAX <code>endDocument</code> method does nothing.</p> */
|
||||
public void endDocument ()
|
||||
throws SAXException {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>The SAX <code>startElement</code> method recognizes elements
|
||||
@ -155,26 +155,26 @@ public class XCatalogReader extends SAXCatalogReader implements SAXCatalogParser
|
||||
entryType = catalog.BASE;
|
||||
entryArgs.add(atts.getValue("HRef"));
|
||||
|
||||
Debug.message(4, "Base", atts.getValue("HRef"));
|
||||
catalog.getCatalogManager().debug.message(4, "Base", atts.getValue("HRef"));
|
||||
} else if (localName.equals("Delegate")) {
|
||||
entryType = catalog.DELEGATE_PUBLIC;
|
||||
entryArgs.add(atts.getValue("PublicId"));
|
||||
entryArgs.add(atts.getValue("HRef"));
|
||||
|
||||
Debug.message(4, "Delegate",
|
||||
catalog.getCatalogManager().debug.message(4, "Delegate",
|
||||
PublicId.normalize(atts.getValue("PublicId")),
|
||||
atts.getValue("HRef"));
|
||||
} else if (localName.equals("Extend")) {
|
||||
entryType = catalog.CATALOG;
|
||||
entryArgs.add(atts.getValue("HRef"));
|
||||
|
||||
Debug.message(4, "Extend", atts.getValue("HRef"));
|
||||
catalog.getCatalogManager().debug.message(4, "Extend", atts.getValue("HRef"));
|
||||
} else if (localName.equals("Map")) {
|
||||
entryType = catalog.PUBLIC;
|
||||
entryArgs.add(atts.getValue("PublicId"));
|
||||
entryArgs.add(atts.getValue("HRef"));
|
||||
|
||||
Debug.message(4, "Map",
|
||||
catalog.getCatalogManager().debug.message(4, "Map",
|
||||
PublicId.normalize(atts.getValue("PublicId")),
|
||||
atts.getValue("HRef"));
|
||||
} else if (localName.equals("Remap")) {
|
||||
@ -182,14 +182,14 @@ public class XCatalogReader extends SAXCatalogReader implements SAXCatalogParser
|
||||
entryArgs.add(atts.getValue("SystemId"));
|
||||
entryArgs.add(atts.getValue("HRef"));
|
||||
|
||||
Debug.message(4, "Remap",
|
||||
catalog.getCatalogManager().debug.message(4, "Remap",
|
||||
atts.getValue("SystemId"),
|
||||
atts.getValue("HRef"));
|
||||
} else if (localName.equals("XMLCatalog")) {
|
||||
// nop, start of catalog
|
||||
} else {
|
||||
// This is equivalent to an invalid catalog entry type
|
||||
Debug.message(1, "Invalid catalog entry type", localName);
|
||||
catalog.getCatalogManager().debug.message(1, "Invalid catalog entry type", localName);
|
||||
}
|
||||
|
||||
if (entryType >= 0) {
|
||||
@ -198,9 +198,9 @@ public class XCatalogReader extends SAXCatalogReader implements SAXCatalogParser
|
||||
catalog.addEntry(ce);
|
||||
} catch (CatalogException cex) {
|
||||
if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
|
||||
Debug.message(1, "Invalid catalog entry type", localName);
|
||||
catalog.getCatalogManager().debug.message(1, "Invalid catalog entry type", localName);
|
||||
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
|
||||
Debug.message(1, "Invalid catalog entry", localName);
|
||||
catalog.getCatalogManager().debug.message(1, "Invalid catalog entry", localName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user