src/main/java/org/jboss/util/xml/JBossEntityResolver.java
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
   {
      entityResolved.set(Boolean.FALSE);

      // nothing to resolve
      if( publicId == null && systemId == null )
         return null;

      boolean trace = log.isTraceEnabled();

      boolean resolvePublicIdFirst = true;
      if(publicId != null && systemId != null)
      {
         String registeredSystemId = null;
         if(localEntities != null)
            registeredSystemId = (String) localEntities.get(publicId);
         if(registeredSystemId == null)
            registeredSystemId = (String) entities.get(publicId);
         
         if(registeredSystemId != null && !registeredSystemId.equals(systemId))
         {
            resolvePublicIdFirst = false;
            if(trace)
               log.trace("systemId argument '" + systemId + "' for publicId '" +
                     publicId + "' is different from the registered systemId '" +
                     registeredSystemId + "', resolution will be based on the argument");
         }
      }
      
      InputSource inputSource = null;
      
      if(resolvePublicIdFirst)
      {
         // Look for a registered publicID
         inputSource = resolvePublicID(publicId, trace);
      }
      
      if( inputSource == null )
      {
         // Try to resolve the systemID from the registry
         inputSource = resolveSystemID(systemId, trace);
      }

      if( inputSource == null )
      {
         // Try to resolve the systemID as a classpath reference under dtd or schema
         inputSource = resolveClasspathName(systemId, trace);
      }

      if( inputSource == null )
      {
         // Try to resolve the systemID as a absolute URL
         inputSource = resolveSystemIDasURL(systemId, trace);
      }

      entityResolved.set(new Boolean(inputSource != null));

      if (inputSource == null)
         log.debug("Cannot resolve [publicID=" + publicId + ",systemID=" + systemId + "]");
      
      return inputSource;
   }
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
   {
      entityResolved.set(Boolean.FALSE);

      // nothing to resolve
      if( publicId == null && systemId == null )
         return null;

      boolean trace = log.isTraceEnabled();

      boolean resolvePublicIdFirst = true;
      if(publicId != null && systemId != null)
      {
         String registeredSystemId = null;
         if(localEntities != null)
            registeredSystemId = (String) localEntities.get(publicId);
         if(registeredSystemId == null)
            registeredSystemId = (String) entities.get(publicId);
         
         if(registeredSystemId != null && !registeredSystemId.equals(systemId))
         {
            resolvePublicIdFirst = false;
            if(trace)
               log.trace("systemId argument '" + systemId + "' for publicId '" +
                     publicId + "' is different from the registered systemId '" +
                     registeredSystemId + "', resolution will be based on the argument");
         }
      }
      
      InputSource inputSource = null;
      
      if(resolvePublicIdFirst)
      {
         // Look for a registered publicID
         inputSource = resolvePublicID(publicId, trace);
      }
      
      if( inputSource == null )
      {
         // Try to resolve the systemID from the registry
         inputSource = resolveSystemID(systemId, trace);
      }

      if( inputSource == null )
      {
         // Try to resolve the systemID as a classpath reference under dtd or schema
         inputSource = resolveClasspathName(systemId, trace);
      }

      if( inputSource == null )
      {
         // Try to resolve the systemID as a absolute URL
         inputSource = resolveSystemIDasURL(systemId, trace);
      }

      entityResolved.set(new Boolean(inputSource != null));

      if (inputSource == null)
         log.debug("Cannot resolve [publicID=" + publicId + ",systemID=" + systemId + "]");
      
      return inputSource;
   }
Returns DTD/Schema inputSource. The resolution logic is:

1. Check the publicId against the current registered values in the class
mapping of entity name to dtd/schema file name. If found, the resulting
file name is passed to the loadClasspathResource to locate the file as a
classpath resource.

2. Check the systemId against the current registered values in the class
mapping of entity name to dtd/schema file name. If found, the resulting
file name is passed to the loadClasspathResource to locate the file as a
classpath resource.

3. Strip the systemId name down to the simple file name by removing an URL
style path elements (myschemas/x.dtd becomes x.dtd), and call
loadClasspathResource to locate the simple file name as a classpath resource.

4. Attempt to resolve the systemId as a URL from which the schema can be
read. If the URL input stream can be opened this returned as the resolved
input.

@param publicId - Public ID of DTD, or null if it is a schema
@param systemId - the system ID of DTD or Schema
@return InputSource of entity