org.deegree.commons.xml.schema
Class SchemaValidator

java.lang.Object
  extended by org.deegree.commons.xml.schema.SchemaValidator

public class SchemaValidator
extends Object

Provides utility methods for the easy validation of XML instance documents against XML schemas and for the validation of XML schema documents.

Validation of instance documents

The XML schemas are either determined from the xsi:schemaLocation attribute of the document or may be explicitly specified. The validator uses the RedirectingEntityResolver, so OGC core schemas are not fetched over the network, but loaded from a local copy.

Validation of schema documents

The validator uses the RedirectingEntityResolver, so OGC core schemas are not fetched over the network, but loaded from a local copy.

Version:
$Revision: $, $Date: $
Author:
Markus Schneider, last edited by: $Author: schneider $

Constructor Summary
SchemaValidator()
           
 
Method Summary
static List<String> validate(InputStream source, String... schemaUris)
          Validates the specified XML instance document according to the contained schema references ( xsi:schemaLocation attribute) and/or to the explicitly specified schema references.
static List<String> validate(String url, String... schemaUris)
          Validates the specified XML instance document according to the contained schema references ( xsi:schemaLocation attribute) and/or to the explicitly specified schema references.
static List<String> validate(org.apache.xerces.xni.parser.XMLInputSource source, String... schemaUris)
          Validates the specified XML instance document according to the contained schema references ( xsi:schemaLocation attribute) and/or to explicitly specified schema references.
static List<String> validateSchema(InputStream inputSchema, String... additionalUris)
          Validates the specified XML schema document, additionally in conjunction with more schemas.
static List<String> validateSchema(LSInput inputSchema, LSInput... additionalSchemas)
          Validates the specified XML schema document, additionally in conjunction with more schemas.
static List<String> validateSchema(String inputSchemaUri, String... additionalUris)
          Validates the specified XML schema document, additionally in conjunction with more schemas.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchemaValidator

public SchemaValidator()
Method Detail

validate

public static List<String> validate(InputStream source,
                                    String... schemaUris)
Validates the specified XML instance document according to the contained schema references ( xsi:schemaLocation attribute) and/or to the explicitly specified schema references.

Parameters:
source - provides the XML document to be validated, must not be null
schemaUris - URIs of schema documents to be considered, can be null (only the xsi:schemaLocation attribute is considered then)
Returns:
list of validation events (errors/warnings) that occured, never null, size of 0 means valid document

validate

public static List<String> validate(String url,
                                    String... schemaUris)
                             throws MalformedURLException,
                                    IOException
Validates the specified XML instance document according to the contained schema references ( xsi:schemaLocation attribute) and/or to the explicitly specified schema references.

Parameters:
url - provides the XML document to be validated, must not be null
schemaUris - URIs of schema documents to be considered, can be null (only the xsi:schemaLocation attribute is considered then)
Returns:
list of validation events (errors/warnings) that occured, never null, size of 0 means valid document
Throws:
IOException
MalformedURLException

validate

public static List<String> validate(org.apache.xerces.xni.parser.XMLInputSource source,
                                    String... schemaUris)
Validates the specified XML instance document according to the contained schema references ( xsi:schemaLocation attribute) and/or to explicitly specified schema references.

Parameters:
source - provides the document to be validated, must not be null
schemaUris - URIs of schema documents to be considered, can be null (only the xsi:schemaLocation attribute is considered then)
Returns:
list of validation events (errors/warnings) that occured, never null, size of 0 means valid document

validateSchema

public static List<String> validateSchema(String inputSchemaUri,
                                          String... additionalUris)
Validates the specified XML schema document, additionally in conjunction with more schemas.

Parameters:
inputSchemaUri - provides the XML schema document to be validated, must not be null
additionalUris - additional schema documents to be considered, can be null
Returns:
list of validation events (errors/warnings) that occured, never null, size of 0 means valid document

validateSchema

public static List<String> validateSchema(InputStream inputSchema,
                                          String... additionalUris)
Validates the specified XML schema document, additionally in conjunction with more schemas.

Parameters:
inputSchema - provides the XML schema document to be validated, must not be null
additionalUris - additional schema documents to be considered, can be null
Returns:
list of validation events (errors/warnings) that occured, never null, size of 0 means valid document

validateSchema

public static List<String> validateSchema(LSInput inputSchema,
                                          LSInput... additionalSchemas)
Validates the specified XML schema document, additionally in conjunction with more schemas.

Parameters:
inputSchema - provides the XML schema document to be validated, must not be null
additionalSchemas - additional schema documents to be considered, can be null
Returns:
list of validation events (errors/warnings) that occured, never null, size of 0 means valid document


Copyright © 2011. All Rights Reserved.