/**
* Test default handler that transverses XML and print all visited node.
*
* @throws Exception If any errors occur.
*/
@Test
public void testDefaultHandler() throws Exception {
String outputFile = USER_DIR + "DefaultHandler.out";
String goldFile = GOLDEN_DIR + "DefaultHandlerGF.out";
String xmlFile = XML_DIR + "namespace1.xml";
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
SAXParser saxparser = spf.newSAXParser();
MyDefaultHandler handler = new MyDefaultHandler(outputFile);
File file = new File(xmlFile);
String Absolutepath = file.getAbsolutePath();
String newAbsolutePath = Absolutepath;
if (File.separatorChar == '\\')
newAbsolutePath = Absolutepath.replace('\\', '/');
saxparser.parse("file:///" + newAbsolutePath, handler);
assertTrue(compareWithGold(goldFile, outputFile));
}
DefaultHandlerTest.java 文件源码
java
阅读 28
收藏 0
点赞 0
评论 0
项目:openjdk-jdk10
作者:
评论列表
文章目录