1 16 17 package com.icesoft.jasper.xmlparser; 18 19 import com.icesoft.jasper.Constants; 20 import com.icesoft.jasper.compiler.Localizer; 21 import org.xml.sax.EntityResolver ; 22 import org.xml.sax.InputSource ; 23 import org.xml.sax.SAXException ; 24 25 import java.io.InputStream ; 26 27 public class CachedEntityResolver implements EntityResolver { 28 public InputSource resolveEntity(String publicId, String systemId) 29 throws SAXException { 30 for (int i = 0; i < Constants.CACHED_DTD_PUBLIC_IDS.length; i++) { 31 String cachedDtdPublicId = Constants.CACHED_DTD_PUBLIC_IDS[i]; 32 if (cachedDtdPublicId.equals(publicId)) { 33 String resourcePath = Constants.CACHED_DTD_RESOURCE_PATHS[i]; 34 InputStream input = 35 this.getClass().getResourceAsStream(resourcePath); 36 if (input == null) { 37 throw new SAXException ( 38 Localizer.getMessage( 39 "jsp.error.internal.filenotfound", 40 resourcePath)); 41 } 42 InputSource isrc = new InputSource (input); 43 return isrc; 44 } 45 } 46 ParserUtils.log.error(Localizer.getMessage( 47 "jsp.error.parse.xml.invalidPublicId", 48 publicId)); 49 return null; 50 } 51 } 52 53 | Popular Tags |