1 package net.sf.invicta.util; 2 3 import java.io.IOException ; 4 import java.net.URL ; 5 6 import org.xml.sax.EntityResolver ; 7 import org.xml.sax.InputSource ; 8 import org.xml.sax.SAXException ; 9 10 15 public class DTDEntityResolver implements EntityResolver { 16 17 20 public InputSource resolveEntity(String publicId, String systemId) 21 throws SAXException , IOException { 22 if (systemId.endsWith("dtd")) { 23 int lastSlash = systemId.lastIndexOf("/"); 24 if (lastSlash >= 0) 25 systemId = systemId.substring(lastSlash + 1); 26 URL url = ClassLoader.getSystemResource(systemId); 27 if (url == null) { 28 return null; 29 } 30 return new InputSource (url.toString()); 31 } else { 32 return null; 33 } 34 } 35 36 } 37 | Popular Tags |