org.geotools.xml
Class AppSchemaValidator

Object
  extended by AppSchemaValidator

public class AppSchemaValidator
extends Object

A class to perform XML schema validation against schemas found using an SchemaResolver .

Author:
Ben Caradoc-Davies (CSIRO Earth Science and Resource Engineering)

Method Summary
static AppSchemaValidator buildValidator()
          Construct an AppSchemaValidator that performs schema validation against schemas found on the classpath using the convention described in SchemaResolver.getSimpleHttpResourcePath(java.net.URI).
static AppSchemaValidator buildValidator(SchemaCatalog catalog)
          Construct an AppSchemaValidator that performs schema validation against schemas found using an SchemaResolver with a SchemaCatalog.
static AppSchemaValidator buildValidator(SchemaResolver resolver)
          Construct an AppSchemaValidator that performs schema validation against schemas found using an SchemaResolver.
 void checkForFailures()
          Throw a RuntimeException if the validator has found any failures.
 List<String> getFailures()
          Return the list of failures found during parsing.
 boolean isFailOnWarning()
          Are validation warnings considered failures?
 void parse(InputStream input)
          Parse an XML instance document read from an InputStream, recording any validation failures failures.
 void setFailOnWarning(boolean failOnWarning)
          Should validation warnings be considered failures?
static void validate(InputStream input, SchemaCatalog catalog)
          Perform schema validation of an XML instance document read from an input stream against schemas found on the classpath using the convention described in SchemaResolver.getSimpleHttpResourcePath(java.net.URI).
static void validate(String xml, SchemaCatalog catalog)
          Perform schema validation of an XML instance document in a string against schemas found on the classpath using the convention described in SchemaResolver.getSimpleHttpResourcePath(java.net.URI).
static void validateResource(String name, SchemaCatalog catalog)
          Perform schema validation of an XML instance document read from a classpath resource against schemas found on the classpath using the convention described in SchemaResolver.getSimpleHttpResourcePath(java.net.URI).
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getFailures

public List<String> getFailures()
Return the list of failures found during parsing.


isFailOnWarning

public boolean isFailOnWarning()
Are validation warnings considered failures?


setFailOnWarning

public void setFailOnWarning(boolean failOnWarning)
Should validation warnings be considered failures?


parse

public void parse(InputStream input)
Parse an XML instance document read from an InputStream, recording any validation failures failures.

Parameters:
input - stream from which XML instance document is read

checkForFailures

public void checkForFailures()
Throw a RuntimeException if the validator has found any failures. The exception detail contains the failure messages.


buildValidator

public static AppSchemaValidator buildValidator()
Construct an AppSchemaValidator that performs schema validation against schemas found on the classpath using the convention described in SchemaResolver.getSimpleHttpResourcePath(java.net.URI).


buildValidator

public static AppSchemaValidator buildValidator(SchemaResolver resolver)
Construct an AppSchemaValidator that performs schema validation against schemas found using an SchemaResolver.

Parameters:
resolver - the resolver used to find schemas

buildValidator

public static AppSchemaValidator buildValidator(SchemaCatalog catalog)
Construct an AppSchemaValidator that performs schema validation against schemas found using an SchemaResolver with a SchemaCatalog.

Parameters:
catalog - SchemaCatalog

validateResource

public static void validateResource(String name,
                                    SchemaCatalog catalog)
Perform schema validation of an XML instance document read from a classpath resource against schemas found on the classpath using the convention described in SchemaResolver.getSimpleHttpResourcePath(java.net.URI).

If validation fails, a RuntimeException is thrown containing details of all failures.

Parameters:
name - resource name of XML instance document
catalog - SchemaCatalog to aide local schema resolution or null

validate

public static void validate(String xml,
                            SchemaCatalog catalog)
Perform schema validation of an XML instance document in a string against schemas found on the classpath using the convention described in SchemaResolver.getSimpleHttpResourcePath(java.net.URI).

If validation fails, a RuntimeException is thrown containing details of all failures.

Parameters:
xml - string containing XML instance document
catalog - SchemaCatalog to aide local schema resolution or null

validate

public static void validate(InputStream input,
                            SchemaCatalog catalog)
Perform schema validation of an XML instance document read from an input stream against schemas found on the classpath using the convention described in SchemaResolver.getSimpleHttpResourcePath(java.net.URI).

If validation fails, a RuntimeException is thrown containing details of all failures.

Parameters:
input - stream providing XML instance document
catalog - SchemaCatalog file to aide local schema resolution or null


Copyright © 1996-2014 Geotools. All Rights Reserved.