org.ow2.util.xml
Class SchemaEntityResolver

java.lang.Object
  extended by org.ow2.util.xml.SchemaEntityResolver
All Implemented Interfaces:
org.xml.sax.EntityResolver

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

Entity resolver allowing to find schema within the classloader.

Author:
Florent Benoit

Constructor Summary
SchemaEntityResolver(java.lang.String[] schemas)
          Constructor.
SchemaEntityResolver(java.lang.String[] schemas, java.lang.String[] dtdPublicIds, java.lang.String[] dtdsFileNames)
          Constructor.
 
Method Summary
protected  void addDtds(java.lang.String[] dtdPublicIds, java.lang.String[] dtdsFileNames)
          Add the mapping between a public Id and the local path of the DTD.
protected  java.net.URL getURL(java.lang.String resourceName)
          Gets an URL for a given resource.
 org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
          The Parser will call this method before opening any external entity except the top-level document entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchemaEntityResolver

public SchemaEntityResolver(java.lang.String[] schemas)
Constructor. Finds the XSD with classloader.

Parameters:
schemas - the name of the schemas to resolve.

SchemaEntityResolver

public SchemaEntityResolver(java.lang.String[] schemas,
                            java.lang.String[] dtdPublicIds,
                            java.lang.String[] dtdsFileNames)
Constructor. Finds the XSD with classloader.

Parameters:
schemas - the name of the schemas to resolve.
dtdPublicIds - the PublicId
dtdsFileNames - the name of the DTDs
Method Detail

addDtds

protected void addDtds(java.lang.String[] dtdPublicIds,
                       java.lang.String[] dtdsFileNames)
Add the mapping between a public Id and the local path of the DTD.

Parameters:
dtdPublicIds - the PublicId
dtdsFileNames - the name of the DTDs

getURL

protected java.net.URL getURL(java.lang.String resourceName)
Gets an URL for a given resource.

Parameters:
resourceName - the name of the resource
Returns:
the requested URL

resolveEntity

public org.xml.sax.InputSource resolveEntity(java.lang.String publicId,
                                             java.lang.String systemId)
                                      throws java.io.IOException,
                                             org.xml.sax.SAXException
The Parser will call this method before opening any external entity except the top-level document entity.

Specified by:
resolveEntity in interface org.xml.sax.EntityResolver
Parameters:
publicId - The public identifier of the external entity being referenced, or null if none was supplied.
systemId - The system identifier of the external entity being referenced.
Returns:
An InputSource object describing the new input source, or null to request that the parser open a regular URI connection to the system identifier.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
java.io.IOException - A Java-specific IO exception, possibly the result of creating a new InputStream or Reader for the InputSource.


Copyright © 2007-2009 OW2 Consortium. All Rights Reserved.