Java XML Transform Usage newSchema(File xmlSchema)

Here you can find the source of newSchema(File xmlSchema)

Description

Creates a new Schema using the default XML implementation

License

Apache License

Parameter

Parameter Description
xmlSchema a parameter

Return

Schema

Declaration

public static Schema newSchema(File xmlSchema) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

import javax.xml.transform.Source;

import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;

import org.xml.sax.SAXException;

public class Main {
    /**/*from   w  w w  . j a va  2 s  .  c o  m*/
     * Schema factory
     */
    private static final SchemaFactory W3X_XML_SCHEMA_FACTORY = SchemaFactory
            .newInstance(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);

    /**
     * Creates a new Schema using the default XML implementation
     *
     * @param xmlSchema
     * @return Schema
     */
    public static Schema newSchema(File xmlSchema) {
        try {
            return W3X_XML_SCHEMA_FACTORY.newSchema(xmlSchema);
        } catch (SAXException e) {
            throw new RuntimeException("Could not create schema for file '" + xmlSchema.getName() + "'!", e);
        }
    }

    /**
     * Creates a new Schema using the default XML implementation
     *
     * @param xmlSchema
     * @return Schema
     */
    public static Schema newSchema(Source xmlSchema) {
        try {
            return W3X_XML_SCHEMA_FACTORY.newSchema(xmlSchema);
        } catch (SAXException e) {
            throw new RuntimeException("Could not create schema for file '" + xmlSchema + "'!", e);
        }
    }
}

Related

  1. getWSAAddress(W3CEndpointReference ref)
  2. getXMLCalendar(Date date)
  3. getXmlEventWriter(Result r)
  4. longToGregorian(long date)
  5. map2Xml(Map map)
  6. newSchema(Source[] schemas)
  7. paramsEqual(AlgorithmParameterSpec spec1, AlgorithmParameterSpec spec2)
  8. parse(File f)
  9. parse(final InputStream file, final ContentHandler handler)