@Test
public void test() {
try {
Schema schema = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema").newSchema(new StreamSource(testFile));
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
saxParserFactory.setNamespaceAware(true);
saxParserFactory.setSchema(schema);
// saxParserFactory.setFeature("http://java.sun.com/xml/schema/features/report-ignored-element-content-whitespace",
// true);
SAXParser saxParser = saxParserFactory.newSAXParser();
XMLReader xmlReader = saxParser.getXMLReader();
xmlReader.setContentHandler(new DefaultHandler());
// InputStream input =
// ClassLoader.getSystemClassLoader().getResourceAsStream("test/test.xml");
InputStream input = getClass().getResourceAsStream("Issue682.xml");
System.out.println("Parse InputStream:");
xmlReader.parse(new InputSource(input));
} catch (Exception ex) {
ex.printStackTrace();
Assert.fail(ex.toString());
}
}
Issue682Test.java 文件源码
java
阅读 28
收藏 0
点赞 0
评论 0
项目:openjdk-jdk10
作者:
评论列表
文章目录