List of usage examples for javax.xml.parsers DocumentBuilderFactory setNamespaceAware
public void setNamespaceAware(boolean awareness)
From source file:Main.java
public final static DocumentBuilder getDocumentBuilder() throws ParserConfigurationException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); factory.setIgnoringComments(true);// w w w . j ava 2 s . c om return factory.newDocumentBuilder(); }
From source file:Main.java
static DocumentBuilder newXmlParser() throws ParserConfigurationException, MalformedURLException, SAXException { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder parser = documentBuilderFactory.newDocumentBuilder(); return parser; }
From source file:Main.java
public static DocumentBuilder getBuilder() { final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); try {//from w ww. j av a 2 s . c o m return factory.newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new RuntimeException(e); } }
From source file:Main.java
private static Document LoadXml(InputStream stream) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); // builder... DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(stream); // return.../* www . ja va 2 s . c om*/ return doc; }
From source file:Main.java
/** Creates a namespace-aware {@link DocumentBuilderFactory} */ private static DocumentBuilderFactory createNamespaceAwareDocumentBuilderFactory() { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); return dbf;/* w ww. j a v a 2 s . c o m*/ }
From source file:Main.java
/** * Get a DocumentBuilder that is namespace aware. * @return a namespace-aware DocumentBuilder. *//*w w w . ja v a 2s. c o m*/ public static DocumentBuilder getDocumentBuilder() throws Exception { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); dbf.setValidating(false); dbf.setXIncludeAware(false); dbf.setExpandEntityReferences(true); dbf.setCoalescing(false); //dbf.setFeature("http://xml.org/sax/features/namespaces", false); //dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false); dbf.setFeature("http://xml.org/sax/features/validation", false); dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); return dbf.newDocumentBuilder(); }
From source file:Main.java
public static void validate(String xmlFileName, String schemaFileName) throws IOException, ParserConfigurationException, SAXException { SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = schemaFactory.newSchema(new File(schemaFileName)); Validator validator = schema.newValidator(); DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); builderFactory.setNamespaceAware(true); DocumentBuilder parser = builderFactory.newDocumentBuilder(); Document document = parser.parse(new File(xmlFileName)); validator.validate(new DOMSource(document)); }
From source file:Main.java
private static DocumentBuilder getDocBuilder() throws ParserConfigurationException { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); docFactory.setNamespaceAware(true); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); return docBuilder; }
From source file:Main.java
static DocumentBuilderFactory getSecureDocumentBuilderFactory() throws ParserConfigurationException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); factory.setFeature("http://xml.org/sax/features/external-general-entities", false); factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false); factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); return factory; }
From source file:Main.java
public static DocumentBuilder createDocumentBuilder() throws ParserConfigurationException { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); documentBuilderFactory.setValidating(false); return documentBuilderFactory.newDocumentBuilder(); }