1 7 8 package org.dom4j.io; 9 10 import junit.textui.TestRunner; 11 12 import java.io.ByteArrayInputStream ; 13 import java.util.List ; 14 15 import javax.xml.parsers.DocumentBuilder ; 16 import javax.xml.parsers.DocumentBuilderFactory ; 17 18 import org.dom4j.AbstractTestCase; 19 20 25 public class DOMReaderTest extends AbstractTestCase { 26 public static void main(String [] args) { 27 TestRunner.run(DOMReaderTest.class); 28 } 29 30 public void testBug972737() throws Exception { 31 String xml = "<schema targetNamespace='http://SharedTest.org/xsd' " 32 + " xmlns='http://www.w3.org/2001/XMLSchema' " 33 + " xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" 34 + " <complexType name='AllStruct'>" + " <all>" 35 + " <element name='arString' type='xsd:string'/>" 36 + " <element name='varInt' type='xsd:int'/>" 37 + " </all>" + " </complexType>" + "</schema>"; 38 39 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 40 DocumentBuilder builder = factory.newDocumentBuilder(); 41 org.w3c.dom.Document doc = builder.parse(new ByteArrayInputStream (xml 42 .getBytes())); 43 44 DOMReader reader = new DOMReader(); 45 org.dom4j.Document dom4jDoc = reader.read(doc); 46 47 List namespaces = dom4jDoc.getRootElement().declaredNamespaces(); 48 assertEquals(2, namespaces.size()); 49 50 System.out.println(dom4jDoc.asXML()); 51 } 52 } 53 54 90 | Popular Tags |