dtdentityresolver.java
来自「java 写的一个新闻发布系统」· Java 代码 · 共 97 行
JAVA
97 行
//// ____.// __/\ ______| |__/\. _______// __ .____| | \ | +----+ \// _______| /--| | | - \ _ | : - \_________// \\______: :---| : : | : | \________>// |__\---\_____________:______: :____|____:_____\// /_____|//// . . . i n j a h i a w e t r u s t . . .//////// DtdEntityResolver//// NK 08.03.2001//package org.jahia.utils.xml;import java.io.*;import java.util.*;import org.w3c.dom.*;import org.jahia.exceptions.*;import org.jahia.utils.*; // JahiaConsoleimport org.xml.sax.EntityResolver;import org.xml.sax.InputSource;import org.jahia.data.constants.JahiaConstants;/** * Substitute external DTD files with local DTD files. * * @author Khue * @version 1.0 */public class DtdEntityResolver implements EntityResolver { /** * Registered DTD, the key is the public id */ private Hashtable m_DTDs = new Hashtable(); /** * Replace external dtd with local dtd. * Return an InputSource to a local DTD file or null if not found * in the registered DTD * */ public InputSource resolveEntity (String publicID, String systemID) { //System.out.println("DtdEntityResolver: " + publicID + " " + systemID); if ( publicID == null ){ return null; } String dtd = null; if ( m_DTDs.get(publicID) != null ){ dtd = (String) m_DTDs.get(publicID); } if( dtd != null ) { //System.out.println("DtdEntityResolver: found dtd "); File f = new File( dtd ); if( f.exists() ) try { return new InputSource(new FileInputStream(f)); } catch( FileNotFoundException ex ) { } } return null; } /** * * @param publicID the key to identify the requested dtd * @param dtd the dtd resource file */ public void registerDTD(String publicID, String dtd) { m_DTDs.put(publicID, dtd); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?