001 package railo.runtime.text.xml; 002 003 import org.xml.sax.InputSource; 004 import org.xml.sax.SAXException; 005 import org.xml.sax.helpers.DefaultHandler; 006 007 import railo.commons.io.IOUtil; 008 import railo.commons.net.HTTPUtil; 009 010 011 012 public class XMLEntityResolverDefaultHandler extends DefaultHandler { 013 014 private InputSource entityRes; 015 016 public XMLEntityResolverDefaultHandler(InputSource entityRes) { 017 this.entityRes=entityRes; 018 } 019 020 /** 021 * @see org.xml.sax.helpers.DefaultHandler#resolveEntity(java.lang.String, java.lang.String) 022 */ 023 public InputSource resolveEntity(String publicID, String systemID) throws SAXException { 024 //if(entityRes!=null)print.out("resolveEntity("+(entityRes!=null)+"):"+publicID+":"+systemID); 025 026 if(entityRes!=null) return entityRes; 027 try { 028 // TODO user resources 029 return new InputSource(IOUtil.toBufferedInputStream(HTTPUtil.toURL(systemID).openStream())); 030 } 031 catch (Throwable t) { 032 return null; 033 } 034 } 035 036 }