implements EntityResolver : EntityResolver « XML « Java






implements EntityResolver

   
import java.io.IOException;

import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

public class SimpleEntityResolver implements EntityResolver {

  private static final String USAGE_TERMS_ID = "http://www.n.com/t.xml";

  private static final String USAGE_TERMS_LOCAL_URI = "C:\\t.xml";

  public InputSource resolveEntity(String publicID, String systemID) throws IOException,
      SAXException {

    if (systemID.equals(USAGE_TERMS_ID)) {
      return new InputSource(USAGE_TERMS_LOCAL_URI);
    }

    return null;
  }

}

   
    
  








Related examples in the same category

1.Getting the Value of an Entity Reference in a DOM Document
2.Resolving entities found in source XML during parsing
3.Intercepting All Accesses to External Entities During XML SAX Parsing
4.Preventing Expansion of Entity References While Parsing an XML File
5.Resolves an entity reference or character reference to its value.