Package net.shibboleth.tool.xmlsectool
Class SchemaValidator
- java.lang.Object
-
- net.shibboleth.tool.xmlsectool.SchemaValidator
-
public class SchemaValidator extends Object
Validates XML documents based on a schema file, or a collection of schema files contained in a directory.
-
-
Constructor Summary
Constructors Constructor Description SchemaValidator(SchemaBuilder.SchemaLanguage schemaLanguage, File schemaLocation)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidgetSchemaFiles(SchemaBuilder.SchemaLanguage lang, File[] schemaFilesOrDirectories, List<File> accumulatedSchemaFiles)Gets all of the schema files in the given set of readable files, directories or subdirectories.private StringschemaFileExtension(SchemaBuilder.SchemaLanguage schemaLanguage)Provides the file name extension associated with a schema language.voidvalidate(Source document)Validate a document against the compiled schema.
-
-
-
Field Detail
-
log
private final org.slf4j.Logger log
Class logger.
-
schema
private final Schema schema
Compiled schema object. Can be reused for multiple document validations.
-
-
Constructor Detail
-
SchemaValidator
public SchemaValidator(@Nonnull SchemaBuilder.SchemaLanguage schemaLanguage, @Nonnull File schemaLocation) throws SAXExceptionConstructor.- Parameters:
schemaLanguage- schema language in use: either XSD or RELAXschemaLocation- location of the schema description (may be a directory of schema files)- Throws:
SAXException- if there is a problem converting the schema sources into a schema
-
-
Method Detail
-
schemaFileExtension
private String schemaFileExtension(@Nonnull SchemaBuilder.SchemaLanguage schemaLanguage)
Provides the file name extension associated with a schema language. Results include the ".".- Parameters:
schemaLanguage- schema language- Returns:
- the file name extension associated with the schema language
-
getSchemaFiles
protected void getSchemaFiles(@Nonnull SchemaBuilder.SchemaLanguage lang, File[] schemaFilesOrDirectories, List<File> accumulatedSchemaFiles)Gets all of the schema files in the given set of readable files, directories or subdirectories.- Parameters:
lang- schema language, must not be nullschemaFilesOrDirectories- files and directories which may contain schema filesaccumulatedSchemaFiles- list that accumulates the schema files
-
validate
public void validate(@Nonnull Source document) throws SAXException, IOExceptionValidate a document against the compiled schema.- Parameters:
document- document to validate- Throws:
SAXException- if the document fails to validateIOException- if an I/O error occurs while reading the document
-
-