FileDocCategorySizeDatePackage
SimpleEntityResolver.javaAPI DocExample3369Thu Aug 16 16:31:58 BST 2001javaxml2

SimpleEntityResolver

public class SimpleEntityResolver extends Object implements EntityResolver
SimpleEntityResolver shows how to implement the SAX EntityResolver interface, and locally resolve an entity that has a specific Internet URI.

Fields Summary
Constructors Summary
Methods Summary
public org.xml.sax.InputSourceresolveEntity(java.lang.String publicID, java.lang.String systemID)

This resolves URIs for entities locally, if needed.

param
publicID the public ID of the reported entity.
param
systemID the system ID of the reported entity.
return
InputSource - the source to read the entity from.
throws
IOException - when resolution errors occur.
throws
SAXException - when errors in creating a new InputSource may result.


        // Handle references to online version of copyright.xml   
        if (systemID.equals(
            "http://www.newInstance.com/javaxml2/copyright.xml")) {
            return new InputSource(
                "file:///c:/javaxml2/ch04/xml/copyright.xml");
        }            
        
        // In the default case, return null
        return null;