All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opengis.cite.wfs20.nsg.utils.SchemaUtils Maven / Gradle / Ivy

package org.opengis.cite.wfs20.nsg.utils;

import java.net.URL;
import java.util.logging.Level;

import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;

import org.opengis.cite.iso19142.util.TestSuiteLogger;
import org.opengis.cite.validation.XmlSchemaCompiler;
import org.xml.sax.SAXException;

import de.latlon.ets.wfs20.core.utils.ValidationUtils;

/**
 * A utility class that provides access to schema files.
 * 
 * @author Lyn Goltz 
 */
public class SchemaUtils {

    /**
     * Creates a single Schema object representing the NSG WFS schema.
     *
     * @return An immutable Schema object, or null if one cannot be constructed.
     * @see XML Schema for WFS 2.0
     */
    public static Schema createWFSSchema() {
        URL entityCatalog = ValidationUtils.class.getResource( "schema-catalog.xml" );
        XmlSchemaCompiler xsdCompiler = new XmlSchemaCompiler( entityCatalog );
        try {
            URL schemaURL = SchemaUtils.class.getResource( "/org/opengis/cite/wfs20/nsg/xsd/nsg/wfs_nsg.xsd" );
            Source xsdSource = new StreamSource( schemaURL.toString() );
            return xsdCompiler.compileXmlSchema( new Source[] { xsdSource } );
        } catch ( SAXException e ) {
            TestSuiteLogger.log( Level.WARNING, "Failed to create WFS Schema object.", e );
        }
        return null;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy