Java XML SAX Parser createSchema(String url)

Here you can find the source of createSchema(String url)

Description

create Schema

License

Apache License

Declaration

public static Schema createSchema(String url) 

Method Source Code


//package com.java2s;
/*/* w w  w. j a v a 2  s . co  m*/
 *  Copyright 2017 LunaMC.io
 *
 *    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 org.xml.sax.SAXException;
import javax.xml.XMLConstants;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import java.net.MalformedURLException;
import java.net.URL;

public class Main {
    public static Schema createSchema(String url) {
        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        try {
            return factory.newSchema(new URL(url));
        } catch (MalformedURLException | SAXException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. createSafeSaxReader(SAXParserFactory saxParserFactory, ContentHandler contentHandler)
  2. createSaxParser()
  3. createSAXParser()
  4. createSAXParser(DefaultHandler dh)
  5. createSaxParserFactory()
  6. createXMLReader()
  7. createXmlReader()
  8. createXmlReader()
  9. createXmlReader()