org.osesb.utilities.xml
Class DefaultEntityResolver

java.lang.Object
  extended by org.osesb.utilities.xml.DefaultEntityResolver
All Implemented Interfaces:
org.xml.sax.EntityResolver
Direct Known Subclasses:
XMLRepositoryEntityResolver

public class DefaultEntityResolver
extends java.lang.Object
implements org.xml.sax.EntityResolver

This Class is the ancestor of framework EntityResolver(s), which resolve schema references in XML documents and return an InputSource for the resolved entity.

Descendants of this class override the resolveEntity() method to resolve the systemID to a concrete location.

The Parser will call resolveEntity() before opening any external entity.

Usage:

For parsing with DOM, use the setEntityResolver() method of the DocumentBuilder to set implementations of this Class as the EntityResolver.

For Parsing with SAX, use the setEntityResolver() method of any of the framework's implementations of DefaultHandler, including SAXDefaultHandler, SAXMultipleElementHandler, and SAXXPathElementHandler to set implementations of this Class as the EntityResolver.

Since:
Version .9

Field Summary
protected  boolean debugFlag
          The debugFlag for this Object.
protected static org.apache.commons.logging.Log log
           
protected  java.lang.String namespaceURI
          The namespace associated with the xmlText that is being parsed.
protected  java.lang.String thisClassName
          The full name of this class.
 
Constructor Summary
DefaultEntityResolver()
          Creates an instance of DefaultEntityResolver.
 
Method Summary
static void main(java.lang.String[] args)
          Main method for testing and sandboxing.
 void reset()
          Reset this resolver for another use.
 org.xml.sax.InputSource resolveEntity(java.lang.String publicID, java.lang.String systemID)
          Called by a parser to resolve a reference to an external entity.
 void setDebugFlag(boolean debugFlag)
          Set the debugFlag for this object.
 void setNamesapceURI(java.lang.String namespaceURI)
          Set the namespaceURI associated with the xmlText that is being parsed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log

namespaceURI

protected java.lang.String namespaceURI
The namespace associated with the xmlText that is being parsed. If set, the namespaceURI can be used for locating an external entity. The EntityResolver interface method, resolveEntity(), does not return the namespace of the schemaLocation attribute (a huge oversight). The namespaceURI property is used to overcome this limitation, allowing the namespaceURI to be determined, and then set by the org.osesb.utilities.xml.DocumentNamespaceHelper Class. See getXMLSchema().


thisClassName

protected java.lang.String thisClassName
The full name of this class.


debugFlag

protected boolean debugFlag
The debugFlag for this Object.

Constructor Detail

DefaultEntityResolver

public DefaultEntityResolver()
Creates an instance of DefaultEntityResolver.

Method Detail

resolveEntity

public org.xml.sax.InputSource resolveEntity(java.lang.String publicID,
                                             java.lang.String systemID)
                                      throws org.xml.sax.SAXException
Called by a parser to resolve a reference to an external entity.

Specified by:
resolveEntity in interface org.xml.sax.EntityResolver
Parameters:
publicID - The public identifier of the external entity being referenced.
systemID - The system identifier, a URI reference of the external resource being referenced.
Returns:
an InputSource for the resolved entity.
Throws:
org.xml.sax.SAXException

setNamesapceURI

public void setNamesapceURI(java.lang.String namespaceURI)
Set the namespaceURI associated with the xmlText that is being parsed. The namespaceURI can be set and used to locating an external entity. The EntityResolver interface method, resolveEntity(), does not return the namespace of the schemaLocation attribute (a huge oversight). The namespaceURI property is used to overcome this limitation, allowing the namespaceURI to be determined, and then set by the org.osesb.utilities.xml.DocumentNamespaceHelper Class.

Parameters:
namespaceURI - The namespaceURI associated with the xmlText that is being parsed.

reset

public void reset()
Reset this resolver for another use.


setDebugFlag

public void setDebugFlag(boolean debugFlag)
Set the debugFlag for this object.

Parameters:
debugFlag - If true, debug messages are logged.

main

public static void main(java.lang.String[] args)
Main method for testing and sandboxing.