JBoss XML Binding 2.0.3.GA

org.jboss.xb.util
Class DefaultSchemaBindingValidator

java.lang.Object
  extended by org.jboss.xb.util.AbstractSchemaBindingValidator
      extended by org.jboss.xb.util.DefaultSchemaBindingValidator
All Implemented Interfaces:
SchemaBindingValidator

public class DefaultSchemaBindingValidator
extends AbstractSchemaBindingValidator

This class is used to check consistency between SchemaBinding instances and their corresponding XSD schemas. It can be configured to exclude (or include) validation of certain namespaces (i.e. types, elements and model groups from certain namespaces). By default, namespace "http://www.w3.org/2001/XMLSchema" is excluded. Also specific types identified by their QName can be excluded or included from validation. Simple XSD types are validated only if present in SchemaBinding. The reason for that is many simple types are bound/represented in Java model by java.lang.String which when building SchemaBinding is bound to xsd:string. Current implementation does not ensures complete consistency but only the basics such as existence of type definitions, element declarations, element ordering in groups and possible occurences of particles. When an inconsistency is found handleError(String msg) is called. The default implementation of which throws IllegalStateException. Subclasses can override this method to report errors differently. Sometimes the error itself may not be informative enough to e.g. identify the location of the inconsistency in the schema. In this case logging should be enabled. Default logger is an instance of org.jboss.logging.Logger with category org.jboss.xb.util.SchemaBindingValidator. All the messages are logged from method log(String msg) which subclasses can override.

Version:
$Revision: 1.1 $
Author:
Alexey Loubyansky, Ales Justin

Field Summary
 
Fields inherited from class org.jboss.xb.util.AbstractSchemaBindingValidator
excludedNs, excludedTypes, log, validatedElements, validatedTypes, WILDCARD
 
Constructor Summary
DefaultSchemaBindingValidator()
           
DefaultSchemaBindingValidator(SchemaBindingResolver resolver)
           
 
Method Summary
protected  void handleError(String msg)
          This an error handler method.
protected  void log(String msg)
          This method is supposed to log a message.
 void validate(org.apache.xerces.xs.XSComplexTypeDefinition xsType, TypeBinding typeBinding)
           
 void validate(org.apache.xerces.xs.XSElementDeclaration xsElement, ElementBinding elementBinding)
           
 void validate(org.apache.xerces.xs.XSModelGroup xsModelGroup, ParticleBinding groupParticle)
           
protected  void validate(org.apache.xerces.xs.XSModel xsSchema, SchemaBinding schemaBinding)
           
 void validate(org.apache.xerces.xs.XSParticle xsParticle, ParticleBinding particleBinding)
           
 void validate(org.apache.xerces.xs.XSSimpleTypeDefinition xsType, TypeBinding typeBinding)
           
 void validate(org.apache.xerces.xs.XSTypeDefinition xsType, TypeBinding typeBinding)
           
 
Methods inherited from class org.jboss.xb.util.AbstractSchemaBindingValidator
enableLogging, excludeNs, excludeType, getSchemaResolver, includeNs, includeType, isLoggingEnabled, isNsExcluded, isTypeExcluded, reset, setSchemaResolver, validate, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultSchemaBindingValidator

public DefaultSchemaBindingValidator()

DefaultSchemaBindingValidator

public DefaultSchemaBindingValidator(SchemaBindingResolver resolver)
Method Detail

validate

protected void validate(org.apache.xerces.xs.XSModel xsSchema,
                        SchemaBinding schemaBinding)
Specified by:
validate in class AbstractSchemaBindingValidator

validate

public void validate(org.apache.xerces.xs.XSElementDeclaration xsElement,
                     ElementBinding elementBinding)

validate

public void validate(org.apache.xerces.xs.XSTypeDefinition xsType,
                     TypeBinding typeBinding)

validate

public void validate(org.apache.xerces.xs.XSSimpleTypeDefinition xsType,
                     TypeBinding typeBinding)

validate

public void validate(org.apache.xerces.xs.XSComplexTypeDefinition xsType,
                     TypeBinding typeBinding)

validate

public void validate(org.apache.xerces.xs.XSParticle xsParticle,
                     ParticleBinding particleBinding)

validate

public void validate(org.apache.xerces.xs.XSModelGroup xsModelGroup,
                     ParticleBinding groupParticle)

handleError

protected void handleError(String msg)
This an error handler method. Default implementation throws IllegalStateException with the message passed in as the argument.

Overrides:
handleError in class AbstractSchemaBindingValidator
Parameters:
msg - the error message

log

protected void log(String msg)
This method is supposed to log a message. Default implementation uses trace logging.

Overrides:
log in class AbstractSchemaBindingValidator
Parameters:
msg - the message to log.

JBoss XML Binding 2.0.3.GA

Copyright © 2012 JBoss, a division of Red Hat, Inc.. All Rights Reserved.