org.yawlfoundation.yawl.schema
Class SchemaHandler

java.lang.Object
  extended by org.yawlfoundation.yawl.schema.SchemaHandler

public class SchemaHandler
extends Object

This object acts a reusable Schema validator for a given schema. Once the schema has been succesfully compiled, any number of XML documents can be validated by calling either of the validate methods.

Author:
Mike Fowler Date: 04-Jul-2006

Constructor Summary
SchemaHandler(String schemaXML)
          Constructs a new SchemaHandler based on the schema schemaXML.
 
Method Summary
 boolean compileSchema()
          Attempts to compile the schema.
 String getConcatenatedMessage()
           
 Vector<String> getErrorMessages()
           
 Vector<String> getMessages()
           
 String getSchema()
           
 Vector<String> getWarningMessages()
           
 void setSchema(String schema)
           
 boolean validate(Document dom)
          Validates the given XML document against the compiled schema.
 boolean validate(String xml)
          Validates the given XML document against the compiled schema.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchemaHandler

public SchemaHandler(String schemaXML)
Constructs a new SchemaHandler based on the schema schemaXML.

Parameters:
schemaXML - Schema XML to based schemaHandler
Method Detail

compileSchema

public boolean compileSchema()
Attempts to compile the schema. If successful, allows an XML document to be validated.

Returns:
true if the schema has compiled successfully.

validate

public boolean validate(String xml)
Validates the given XML document against the compiled schema.

Parameters:
xml - instance document to be validated.
Returns:
true if the xml is a valid instance of the schema
Throws:
IllegalStateException - if schema has not been compiled succesfully

validate

public boolean validate(Document dom)
Validates the given XML document against the compiled schema. Converts the dom to a String and calls validate(String xml).

Parameters:
dom - document to be validated
Returns:
true if the xml is a valid instance of the schema
Throws:
IllegalStateException - if schema has not been compiled succesfully

getErrorMessages

public Vector<String> getErrorMessages()
Returns:
all error messages from the last validation/compilation

getWarningMessages

public Vector<String> getWarningMessages()
Returns:
all warning messages from the last validation/compilation

getMessages

public Vector<String> getMessages()
Returns:
all messages from the last validation/compilation

getConcatenatedMessage

public String getConcatenatedMessage()
Returns:
all messages since the last validation/compilation

getSchema

public String getSchema()
Returns:
String representation of the schema

setSchema

public void setSchema(String schema)
Parameters:
schema - new schema to use (resets everything)


Copyright © 2004-2012 The YAWL Foundation.