当前位置: 首页>>代码示例>>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;未经允许,请勿转载。