57 * @throws Exception If any errors occur. 58 */ 59 @Test 60 public void testcase01() throws Exception { 61 String outputFile = USER_DIR + "AttributesNS.out"; 62 String goldFile = GOLDEN_DIR + "AttributesNSGF.out"; 63 String xmlFile = XML_DIR + "namespace1.xml"; 64 SAXParserFactory spf = SAXParserFactory.newInstance(); 65 spf.setNamespaceAware(true); 66 // http://www.saxproject.com/?selected=namespaces namespace-prefixes 67 //set to false to supress xmlns attributes 68 spf.setFeature("http://xml.org/sax/features/namespace-prefixes", 69 false); 70 SAXParser saxParser = spf.newSAXParser(); 71 MyAttrCHandler myAttrCHandler = new MyAttrCHandler(outputFile); 72 saxParser.parse(new File(xmlFile), myAttrCHandler); 73 myAttrCHandler.flushAndClose(); 74 assertTrue(compareWithGold(goldFile, outputFile)); 75 } 76 } 77 78 | 57 * @throws Exception If any errors occur. 58 */ 59 @Test 60 public void testcase01() throws Exception { 61 String outputFile = USER_DIR + "AttributesNS.out"; 62 String goldFile = GOLDEN_DIR + "AttributesNSGF.out"; 63 String xmlFile = XML_DIR + "namespace1.xml"; 64 SAXParserFactory spf = SAXParserFactory.newInstance(); 65 spf.setNamespaceAware(true); 66 // http://www.saxproject.com/?selected=namespaces namespace-prefixes 67 //set to false to supress xmlns attributes 68 spf.setFeature("http://xml.org/sax/features/namespace-prefixes", 69 false); 70 SAXParser saxParser = spf.newSAXParser(); 71 MyAttrCHandler myAttrCHandler = new MyAttrCHandler(outputFile); 72 saxParser.parse(new File(xmlFile), myAttrCHandler); 73 myAttrCHandler.flushAndClose(); 74 assertTrue(compareWithGold(goldFile, outputFile)); 75 } 76 } |