1 19 package org.jahia.tools.files; 20 21 22 import java.io.File ; 23 import java.io.FileInputStream ; 24 import java.io.FileNotFoundException ; 25 import java.util.Hashtable ; 26 27 28 34 public class DtdEntityResolver implements org.xml.sax.EntityResolver { 35 36 39 private Hashtable m_DTDs = new Hashtable (); 40 41 42 48 public org.xml.sax.InputSource resolveEntity (String publicID, String systemID) { 49 50 52 if ( publicID == null ){ 53 return null; 54 } 55 56 String dtd = null; 57 58 if ( m_DTDs.get(publicID) != null ){ 59 dtd = (String ) m_DTDs.get(publicID); 60 } 61 62 if( dtd != null ) { 63 File f = new File ( dtd ); 65 if( f.exists() ) 66 try { 67 return new org.xml.sax.InputSource (new FileInputStream (f)); 68 } catch( FileNotFoundException ex ) { 69 } 70 } 71 72 return null; 73 } 74 75 76 81 public void registerDTD(String publicID, String dtd) { 82 83 m_DTDs.put(publicID, dtd); 84 85 } 86 87 88 } | Popular Tags |