mrglavas 2004/07/12 14:51:28 Modified: java/src/org/apache/xerces/util XMLCatalogResolver.java Log: Jira Issue #990:
http://nagoya.apache.org/jira/browse/XERCESJ-990 Adding support org.xml.sax.ext.EntityResolver2 to XMLCatalogResolver as convenience for users. Thanks to John Kim for this contribution. Revision Changes Path 1.6 +69 -4 xml-xerces/java/src/org/apache/xerces/util/XMLCatalogResolver.java Index: XMLCatalogResolver.java =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/util/XMLCatalogResolver.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- XMLCatalogResolver.java 22 Mar 2004 03:38:31 -0000 1.5 +++ XMLCatalogResolver.java 12 Jul 2004 21:51:28 -0000 1.6 @@ -18,7 +18,12 @@ import java.io.IOException; -import org.xml.sax.EntityResolver; +/** + * Switch the following import statement once the real interface + * (org.xml.sax.ext.EntityResolver2) is available. + */ +// import org.xml.sax.ext.EntityResolver2; +import org.apache.xerces.util.EntityResolver2Wrapper.EntityResolver2; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -62,7 +67,7 @@ * @version $Id$ */ public class XMLCatalogResolver - implements XMLEntityResolver, EntityResolver, LSResourceResolver { + implements XMLEntityResolver, EntityResolver2, LSResourceResolver { /** Internal catalog manager for Apache catalogs. **/ private CatalogManager fResolverCatalogManager = null; @@ -232,7 +237,7 @@ * @throws IOException thrown if some i/o error occurs */ public InputSource resolveEntity(String publicId, String systemId) - throws SAXException, IOException { + throws SAXException, IOException { String resolvedId = null; if (publicId != null && systemId != null) { @@ -249,6 +254,66 @@ } return null; } + + /** + * <p>Resolves an external entity. If the entity cannot be + * resolved, this method should return <code>null</code>. This + * method returns an input source if an entry was found in the + * catalog for the given external identifier. It should be + * overrided if other behaviour is required.</p> + * + * @param name the identifier of the external entity + * @param publicId the public identifier, or <code>null</code> if none was supplied + * @param baseURI the URI with respect to which relative systemIDs are interpreted. + * @param systemId the system identifier + * + * @throws SAXException any SAX exception, possibly wrapping another exception + * @throws IOException thrown if some i/o error occurs + */ + public InputSource resolveEntity(String name, String publicId, + String baseURI, String systemId) throws SAXException, IOException { + + String resolvedId = null; + + if(!getUseLiteralSystemId() && baseURI != null){ + + URI base_uri = new URI(baseURI); + URI uri = new URI(base_uri, systemId); + systemId = uri.toString(); + + } + + if (publicId != null && systemId != null) { + resolvedId = resolvePublic(publicId, systemId); + } + else if (systemId != null) { + resolvedId = resolveSystem(systemId); + } + + if (resolvedId != null) { + InputSource source = new InputSource(resolvedId); + source.setPublicId(publicId); + return source; + } + return null; + } + + /** + * <p>Locates an external subset for documents which do not explicitly + * provide one. If no external subset is provided, this method should + * return <code>null</code>.</p> + * + * @param name the identifier of the document root element + * @param baseURI the document's base URI + * + * @throws SAXException any SAX exception, possibly wrapping another exception + * @throws IOException thrown if some i/o error occurs + */ + public InputSource getExternalSubset(String name, String baseURI) + throws SAXException, IOException { + + return null; + } /** * <p>Resolves a resource using the catalog. This method interprets that --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
