org.netbeans.modules.xml.xam.spi
Class XsdBasedValidator

java.lang.Object
  extended by org.netbeans.modules.xml.xam.spi.XsdBasedValidator
All Implemented Interfaces:
Validator

public abstract class XsdBasedValidator
extends java.lang.Object
implements Validator

Base class for Schema validator. Each domain specific schema validator can extend this.

Author:
Shivanand Kini, Nam Nguyen, Praveen Savur

Nested Class Summary
protected  class XsdBasedValidator.Handler
          Handler to receive parse events.
 
Nested classes/interfaces inherited from interface org.netbeans.modules.xml.xam.spi.Validator
Validator.ResultItem, Validator.ResultType
 
Constructor Summary
XsdBasedValidator()
          Creates a new instance of XsdBasedValidation
 
Method Summary
protected  javax.xml.validation.Schema getCompiledSchema(java.io.InputStream[] schemas, org.w3c.dom.ls.LSResourceResolver lsResourceResolver)
          Subclasses can use this to get a compiled schema object.
protected  javax.xml.validation.Schema getCompiledSchema(javax.xml.transform.Source[] schemas, org.w3c.dom.ls.LSResourceResolver lsResourceResolver, org.xml.sax.ErrorHandler errorHandler)
           
protected abstract  javax.xml.validation.Schema getSchema(Model model)
          Get Schemas that the model has to be validated against.
protected  javax.xml.transform.Source getSource(Model model, XsdBasedValidator.Handler handler)
           
 DocumentModel resolveResource(java.lang.String systemId, Model currentModel)
           
protected  void validate(Model model, javax.xml.validation.Schema schema, XsdBasedValidator.Handler handler)
          Validates the model against the schema.
 ValidationResult validate(Model model, Validation validation, Validation.ValidationType validationType)
          Entry point to validate a model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.netbeans.modules.xml.xam.spi.Validator
getName
 

Constructor Detail

XsdBasedValidator

public XsdBasedValidator()
Creates a new instance of XsdBasedValidation

Method Detail

getSchema

protected abstract javax.xml.validation.Schema getSchema(Model model)
Get Schemas that the model has to be validated against. Returns compiled Schema to be used in validation of the given model; or null if this validator does not know how to validate the model.

Parameters:
model - Get Schemas that the model has to be validated against.
Returns:
Compiled Schema object.

validate

public ValidationResult validate(Model model,
                                 Validation validation,
                                 Validation.ValidationType validationType)
Entry point to validate a model.

Specified by:
validate in interface Validator
Parameters:
model - Model to validate.
validation - Reference to Validation object.
validationType - Type of validation. Complete(slow) or partial(fast).
Returns:
ValidationResults.

getSource

protected javax.xml.transform.Source getSource(Model model,
                                               XsdBasedValidator.Handler handler)
Parameters:
model -
handler -
Returns:
Source input source stream for the validation.

validate

protected void validate(Model model,
                        javax.xml.validation.Schema schema,
                        XsdBasedValidator.Handler handler)
Validates the model against the schema. Errors are sent to the handler.

Parameters:
model - Model to be validated.
schema - Compiled schema against which the model is validated.
handler - Handler to receive validation messages.

getCompiledSchema

protected javax.xml.validation.Schema getCompiledSchema(java.io.InputStream[] schemas,
                                                        org.w3c.dom.ls.LSResourceResolver lsResourceResolver)
Subclasses can use this to get a compiled schema object.

Parameters:
schemas - Input stream of schemas.
lsResourceResolver - resolver can be supplied optionally. Otherwise pass null.
Returns:
Compiled Schema object.

getCompiledSchema

protected javax.xml.validation.Schema getCompiledSchema(javax.xml.transform.Source[] schemas,
                                                        org.w3c.dom.ls.LSResourceResolver lsResourceResolver,
                                                        org.xml.sax.ErrorHandler errorHandler)

resolveResource

public DocumentModel resolveResource(java.lang.String systemId,
                                     Model currentModel)