Here you can find the source of getDocumentBuilderFactory(String schema)
Parameter | Description |
---|---|
schema | the schema |
public static DocumentBuilderFactory getDocumentBuilderFactory(String schema)
//package com.java2s; /**/* w ww . j a va 2s . com*/ * Copyright (C) 2007 Asterios Raptis * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import javax.xml.parsers.DocumentBuilderFactory; public class Main { /** The Constant DOCUMENT_BUILDER_FACTORY_VALUE. */ private static final String DOCUMENT_BUILDER_FACTORY_VALUE = "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"; /** The Constant DOCUMENT_BUILDER_FACTORY_KEY. */ private static final String DOCUMENT_BUILDER_FACTORY_KEY = "javax.xml.parsers.DocumentBuilderFactory"; /** The Constant SCHEMA_SOURCE_KEY. */ private static final String SCHEMA_SOURCE_KEY = "http://java.sun.com/xml/jaxp/properties/schemaSource"; /** The Constant SCHEMA_LANGUAGE_KEY. */ private static final String SCHEMA_LANGUAGE_KEY = "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; /** The Constant HTTP_WWW_W3_ORG_2001_XML_SCHEMA. */ private static final String HTTP_WWW_W3_ORG_2001_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema"; /** * Gets the document builder factory. * * @param schema * the schema * @return the document builder factory */ public static DocumentBuilderFactory getDocumentBuilderFactory(String schema) { System.setProperty(DOCUMENT_BUILDER_FACTORY_KEY, DOCUMENT_BUILDER_FACTORY_VALUE); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); factory.setValidating(true); factory.setAttribute(SCHEMA_LANGUAGE_KEY, HTTP_WWW_W3_ORG_2001_XML_SCHEMA); factory.setAttribute(SCHEMA_SOURCE_KEY, schema); return factory; } }