當前位置: 首頁>>代碼示例>>Java>>正文


Java XMLReader.setDTDHandler方法代碼示例

本文整理匯總了Java中org.xml.sax.XMLReader.setDTDHandler方法的典型用法代碼示例。如果您正苦於以下問題:Java XMLReader.setDTDHandler方法的具體用法?Java XMLReader.setDTDHandler怎麽用?Java XMLReader.setDTDHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.xml.sax.XMLReader的用法示例。


在下文中一共展示了XMLReader.setDTDHandler方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: load

import org.xml.sax.XMLReader; //導入方法依賴的package包/類
public static void load(ThemeNULL theme, InputStream in) throws IOException {
	SAXParserFactory spf = SAXParserFactory.newInstance();
	spf.setValidating(true);
	try {
		SAXParser parser = spf.newSAXParser();
		XMLReader reader = parser.getXMLReader();
		XmlHandler handler = new XmlHandler();
		handler.theme = theme;
		reader.setEntityResolver(handler);
		reader.setContentHandler(handler);
		reader.setDTDHandler(handler);
		reader.setErrorHandler(handler);
		InputSource is = new InputSource(in);
		is.setEncoding("UTF-8");
		reader.parse(is);
	} catch (/*SAX|ParserConfiguration*/Exception se) {
		se.printStackTrace();
		throw new IOException(se.toString());
	}
}
 
開發者ID:Thecarisma,項目名稱:powertext,代碼行數:21,代碼來源:ThemeNULL.java

示例2: parse

import org.xml.sax.XMLReader; //導入方法依賴的package包/類
/**
 * Parse the content given {@link org.xml.sax.InputSource}
 * as XML using the specified
 * {@link org.xml.sax.helpers.DefaultHandler}.
 *
 * @param is The InputSource containing the content to be parsed.
 * @param dh The SAX DefaultHandler to use.
 *
 * @throws IllegalArgumentException If the <code>InputSource</code> object
 *   is <code>null</code>.
 * @throws IOException If any IO errors occur.
 * @throws SAXException If any SAX errors occur during processing.
 *
 * @see org.xml.sax.DocumentHandler
 */
public void parse(InputSource is, DefaultHandler dh)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException("InputSource cannot be null");
    }

    XMLReader reader = this.getXMLReader();
    if (dh != null) {
        reader.setContentHandler(dh);
        reader.setEntityResolver(dh);
        reader.setErrorHandler(dh);
        reader.setDTDHandler(dh);
    }
    reader.parse(is);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:31,代碼來源:SAXParser.java

示例3: dtdhandler01

import org.xml.sax.XMLReader; //導入方法依賴的package包/類
/**
 * No exception expected when set DTD handler as simple DTD handler.
 *
 * @throws Exception If any errors occur.
 */
@Test
public void dtdhandler01() throws Exception {
    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setNamespaceAware(true);
    XMLReader xmlReader = spf.newSAXParser().getXMLReader();
    XMLFilterImpl xmlFilter = new XMLFilterImpl();
    xmlReader.setDTDHandler(xmlFilter);
    assertEquals(xmlReader.getDTDHandler(), xmlFilter);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:XMLReaderTest.java

示例4: test

import org.xml.sax.XMLReader; //導入方法依賴的package包/類
@Test
public void test() throws Exception {
    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setNamespaceAware(true);
    XMLReader reader = spf.newSAXParser().getXMLReader();
    reader.setErrorHandler(null); // SAX 2.0.1 allows
    reader.setContentHandler(null); // SAX 2.0.1 allows
    reader.setEntityResolver(null); // SAX 2.0.1 allows
    reader.setDTDHandler(null); // SAX 2.0.1 allows
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:SAX201Test.java

示例5: createFromXMLReader

import org.xml.sax.XMLReader; //導入方法依賴的package包/類
/**
 * Create contents of a buffer from a {@link XMLReader} and {@link InputStream}.
 *
 * <p>
 * The MutableXMLStreamBuffer is reset (see {@link #reset}) before creation.
 *
 * <p>
 * The MutableXMLStreamBuffer is created by using an instance of {@link SAXBufferCreator}
 * and registering associated handlers on the {@link XMLReader}.
 *
 * @param reader
 * The {@link XMLReader} to use for parsing.
 * @param in
 * The {@link InputStream} to be parsed.
 * @param systemId
 * The system ID of the input stream.
 */
public void createFromXMLReader(XMLReader reader, InputStream in, String systemId) throws SAXException, IOException {
    reset();
    SAXBufferCreator c = new SAXBufferCreator(this);

    reader.setContentHandler(c);
    reader.setDTDHandler(c);
    reader.setProperty(Properties.LEXICAL_HANDLER_PROPERTY, c);

    c.create(reader, in, systemId);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:28,代碼來源:MutableXMLStreamBuffer.java


注:本文中的org.xml.sax.XMLReader.setDTDHandler方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。