1 7 8 package org.dom4j.io; 9 10 import javax.xml.parsers.DocumentBuilder ; 11 import javax.xml.parsers.DocumentBuilderFactory ; 12 import javax.xml.parsers.SAXParser ; 13 import javax.xml.parsers.SAXParserFactory ; 14 15 import org.xml.sax.XMLReader ; 16 17 25 class JAXPHelper { 26 protected JAXPHelper() { 27 } 28 29 44 public static XMLReader createXMLReader(boolean validating, 45 boolean namespaceAware) throws Exception { 46 SAXParserFactory factory = SAXParserFactory.newInstance(); 47 factory.setValidating(validating); 48 factory.setNamespaceAware(namespaceAware); 49 50 SAXParser parser = factory.newSAXParser(); 51 52 return parser.getXMLReader(); 53 } 54 55 public static org.w3c.dom.Document createDocument(boolean validating, 56 boolean namespaceAware) throws Exception { 57 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 58 factory.setValidating(validating); 59 factory.setNamespaceAware(namespaceAware); 60 61 DocumentBuilder builder = factory.newDocumentBuilder(); 62 63 return builder.newDocument(); 64 } 65 } 66 67 103 | Popular Tags |