public InputSource resolveEntity(String publicId,String systemId) throws SAXException, IOException {
  hasDTD=false;
  String dtd=UtilProperties.getSplitPropertyValue(UtilURL.fromResource("localdtds.properties"),publicId);
  if (UtilValidate.isNotEmpty(dtd)) {
    if (Debug.verboseOn())     Debug.logVerbose("[UtilXml.LocalResolver.resolveEntity] resolving DTD with publicId [" + publicId + "], systemId ["+ systemId+ "] and the dtd file is ["+ dtd+ "]",module);
    try {
      URL dtdURL=UtilURL.fromResource(dtd);
      if (dtdURL == null) {
        throw new GeneralException("Local DTD not found - " + dtd);
      }
      InputStream dtdStream=dtdURL.openStream();
      InputSource inputSource=new InputSource(dtdStream);
      inputSource.setPublicId(publicId);
      hasDTD=true;
      if (Debug.verboseOn())       Debug.logVerbose("[UtilXml.LocalResolver.resolveEntity] got LOCAL DTD input source with publicId [" + publicId + "] and the dtd file is ["+ dtd+ "]",module);
      return inputSource;
    }
 catch (    Exception e) {
      Debug.logWarning(e,module);
    }
  }
 else {
    int lastSlash=systemId.lastIndexOf("/");
    String filename=null;
    if (lastSlash == -1) {
      filename=systemId;
    }
 else {
      filename=systemId.substring(lastSlash + 1);
    }
    URL resourceUrl=UtilURL.fromResource(filename);
    if (resourceUrl != null) {
      InputStream resStream=resourceUrl.openStream();
      InputSource inputSource=new InputSource(resStream);
      if (UtilValidate.isNotEmpty(publicId)) {
        inputSource.setPublicId(publicId);
      }
      hasDTD=true;
      if (Debug.verboseOn())       Debug.logVerbose("[UtilXml.LocalResolver.resolveEntity] got LOCAL DTD/Schema input source with publicId [" + publicId + "] and the file/resource is ["+ filename+ "]",module);
      return inputSource;
    }
 else {
      Debug.logWarning("[UtilXml.LocalResolver.resolveEntity] could not find LOCAL DTD/Schema with publicId [" + publicId + "] and the file/resource is ["+ filename+ "]",module);
      return null;
    }
  }
  return defaultResolver.resolveEntity(publicId,systemId);
}

public InputSource resolveEntity ( String publicId , String systemId ) throws SAXException , IOException { hasDTD = false ; String dtd = UtilProperties . getSplitPropertyValue ( UtilURL . fromResource ( "localdtds.properties" ) , publicId ) ; if ( UtilValidate . isNotEmpty ( dtd ) ) { if ( Debug . verboseOn ( ) ) Debug . logVerbose ( "[UtilXml.LocalResolver.resolveEntity] resolving DTD with publicId [" + publicId + "], systemId [" + systemId + "] and the dtd file is [" + dtd + "]" , module ) ; try { URL dtdURL = UtilURL . fromResource ( dtd ) ; if ( dtdURL == null ) { throw new GeneralException ( "Local DTD not found - " + dtd ) ; } InputStream dtdStream = dtdURL . openStream ( ) ; InputSource inputSource = new InputSource ( dtdStream ) ; inputSource . setPublicId ( publicId ) ; hasDTD = true ; if ( Debug . verboseOn ( ) ) Debug . logVerbose ( "[UtilXml.LocalResolver.resolveEntity] got LOCAL DTD input source with publicId [" + publicId + "] and the dtd file is [" + dtd + "]" , module ) ; return inputSource ; } catch ( Exception e ) { Debug . logWarning ( e , module ) ; } } else { int lastSlash = systemId . lastIndexOf ( "/" ) ; String filename = null ; if ( lastSlash == - 1 ) { filename = systemId ; } else { filename = systemId . substring ( lastSlash + 1 ) ; } URL resourceUrl = UtilURL . fromResource ( filename ) ; if ( resourceUrl != null ) { InputStream resStream = resourceUrl . openStream ( ) ; InputSource inputSource = new InputSource ( resStream ) ; if ( UtilValidate . isNotEmpty ( publicId ) ) { inputSource . setPublicId ( publicId ) ; } hasDTD = true ; if ( Debug . verboseOn ( ) ) Debug . logVerbose ( "[UtilXml.LocalResolver.resolveEntity] got LOCAL DTD/Schema input source with publicId [" + publicId + "] and the file/resource is [" + filename + "]" , module ) ; return inputSource ; } else { Debug . logWarning ( "[UtilXml.LocalResolver.resolveEntity] could not find LOCAL DTD/Schema with publicId [" + publicId + "] and the file/resource is [" + filename + "]" , module ) ; return null ; } } return defaultResolver . resolveEntity ( publicId , systemId ) ; }
returns dtd inputsource . if dtd was found in the dtds map and inputsource was created flag hasdtd is set to true .
