org.openpermis.policy.io.xmlchecking
Class W3CXMLSchemaValidator

java.lang.Object
  extended by org.openpermis.policy.io.xmlchecking.W3CXMLSchemaValidator

public class W3CXMLSchemaValidator
extends Object

Class that abstracts the W3C XML Schema validation process. It is an implementation of the SchemaValidatorInterface.

Since:
0.3.0

Constructor Summary
W3CXMLSchemaValidator()
          Creates a validator with the default schema.
W3CXMLSchemaValidator(Schema schema)
          Creates a validator for the specified schema.
 
Method Summary
protected static Schema getDefaultSchema()
          Creates the default XML Schema used for validation purposes.
static String validate(File file)
          Checks the file if it matches the XML scheme.
 void validate(Node r)
          Checks if xml represented by a node is valid according to the current schema.
 void validate(Reader r)
          Checks if xml content represented by a Reader is valid according to the current schema.
 void validate(Source source)
          Check if xml represented by a Source is valid according to the current schema.
 void validate(String s)
          Checks if a given xml string is valid according to the current schema.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

W3CXMLSchemaValidator

public W3CXMLSchemaValidator()
                      throws IllegalArgumentException
Creates a validator with the default schema.

Throws:
IllegalArgumentException - if the default schema cannot be loaded.

W3CXMLSchemaValidator

public W3CXMLSchemaValidator(Schema schema)
                      throws IllegalArgumentException
Creates a validator for the specified schema.

Parameters:
schema - the schema to use for validation, must not be null.
Throws:
IllegalArgumentException - if a null schema is passed in.
Since:
0.9.0
Method Detail

validate

public static String validate(File file)
Checks the file if it matches the XML scheme.

Parameters:
file - File to check
Returns:
null if of, errorstring else
Since:
0.3.0

getDefaultSchema

protected static final Schema getDefaultSchema()
Creates the default XML Schema used for validation purposes.

Returns:
the Schema requested.
Since:
0.9.0

validate

public void validate(String s)
              throws SAXException,
                     IOException
Checks if a given xml string is valid according to the current schema.

Parameters:
s - String to be validated
Throws:
SAXException - If parsing of the schema instance fails
IOException - Thrown on IO error

validate

public void validate(Reader r)
              throws SAXException,
                     IOException
Checks if xml content represented by a Reader is valid according to the current schema.

Parameters:
r - Reader accessing the xml content
Throws:
SAXException - If parsing of the schema instance fails
IOException - Thrown on IO error

validate

public void validate(Node r)
              throws SAXException,
                     IOException
Checks if xml represented by a node is valid according to the current schema.

Parameters:
r - XML Node that is to be validated
Throws:
SAXException - If parsing of the schema instance fails
IOException - Thrown on IO error

validate

public void validate(Source source)
              throws SAXException,
                     IOException
Check if xml represented by a Source is valid according to the current schema.

Parameters:
source - Source to be validated
Throws:
SAXException - If parsing of the schema instance fails
IOException - Thrown on IO error


OpenPermis Role Based Access Control 0.9.0 (Build 16)
2009/08/13 07:16:59
Copyright (c) 2002-2007 Ergon Informatik AG