Free Trial - Stylus Studio, The World's Best XML IDE!


com.saxonica.validate
Class Validator

java.lang.Object
  |
  +--net.sf.saxon.event.ProxyReceiver
        |
        +--com.saxonica.validate.Validator
All Implemented Interfaces:
Receiver, javax.xml.transform.Result, javax.xml.transform.SourceLocator
Direct Known Subclasses:
AnnotationRemover, AttributeValidator, LaxValidator

public abstract class Validator
extends ProxyReceiver
implements Receiver, javax.xml.transform.SourceLocator

This class is an abstract superclass for all the validators. The class includes factory methods for constructing a validator.


Field Summary
protected  SchemaType xsiType
           
 
Fields inherited from class net.sf.saxon.event.ProxyReceiver
baseReceiver, config, systemId
 
Fields inherited from interface javax.xml.transform.Result
PI_DISABLE_OUTPUT_ESCAPING, PI_ENABLE_OUTPUT_ESCAPING
 
Constructor Summary
Validator()
           
 
Method Summary
static void checkDerivation(SchemaType xsiType, SchemaType type, int block)
          Check that this type is validly derived from a given type
protected  int getAnnotation()
          Get the type annotation code to be used on elements validated by this validator
protected abstract  Validator getChildValidator()
          Get a validator to handle the children of the current element.
 int getColumnNumber()
          Return the character position where the current document event ends.
 int getContainingElement()
          Get the fingerprint of the name of the element being validated (for diagnostics).
protected  java.lang.String getContainingElementName()
          Get the containing element name, for use in error messages.
 ElementDecl getElementDeclaration()
          Get the element declaration that this validator is validating against
 int getLineNumber()
          Return the line number where the current document event ends.
 NamespaceResolver getNamespaceResolver()
          Get the namespace resolver
 java.lang.String getPublicId()
          Return the public identifier for the current document event.
 java.lang.String getSystemId()
           
abstract  int getTypeAnnotation()
          Get the type annotation to be used for an element or attribute that conforms to the type being validated against
 boolean isNillable()
          Determine whether this type permits xsi:nil = true
static Validator makeValidator(int nameCode, SchemaType xsiType, int validation, ValidationContext validationContext, Configuration config)
          Factory method to make a validator for a particular element
static Validator makeValidator(SchemaType schemaType)
          Factory method to create a validator for elements of this type
static Validator makeValidator(SchemaType type, SchemaType xsiType, ElementDecl decl)
           
protected  void setAnnotation(int annotation)
          Set the type annotation code to be allocated by this validator
 void setContainingElement(int fingerprint)
          Set the fingerprint identifying the name of the containing element (for diagnostics)
 void setDocumentLocator(org.xml.sax.Locator locator)
          Set the Document Locator
 void setElementDeclaration(ElementDecl decl)
          Set the element declaration that this validator is validating against
 void setNamespaceResolver(NamespaceResolver resolver)
          Set the NamespaceResolver to be used for resolving QName-valued attributes
 void setNillable(boolean nillable)
          Set whether this type permits xsi:nil = true
 void setXSIType(SchemaType xsiType)
          Set the value of the xsi:type attribute.
 void startElement(int nameCode, int typeCode, int properties)
          Handle the start tag for a child element of the element being validated
 
Methods inherited from class net.sf.saxon.event.ProxyReceiver
attribute, characters, comment, endDocument, endElement, getConfiguration, getNamePool, getUnderlyingReceiver, namespace, processingInstruction, setConfiguration, setSystemId, setUnderlyingReceiver, setUnparsedEntity, startContent, startDocument
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.saxon.event.Receiver
attribute, characters, comment, endDocument, endElement, getConfiguration, namespace, processingInstruction, setConfiguration, setSystemId, setUnparsedEntity, startContent, startDocument
 

Field Detail

xsiType

protected SchemaType xsiType
Constructor Detail

Validator

public Validator()
Method Detail

setContainingElement

public void setContainingElement(int fingerprint)
Set the fingerprint identifying the name of the containing element (for diagnostics)

Parameters:
fingerprint -

setElementDeclaration

public void setElementDeclaration(ElementDecl decl)
Set the element declaration that this validator is validating against


getElementDeclaration

public ElementDecl getElementDeclaration()
Get the element declaration that this validator is validating against


getContainingElement

public int getContainingElement()
Get the fingerprint of the name of the element being validated (for diagnostics).

Returns:
the fingerprint, or -1 if not available.

getContainingElementName

protected java.lang.String getContainingElementName()
Get the containing element name, for use in error messages.

Returns:
the name of the containing element (enclosed in chevrons), or the string "this element" if not available

setAnnotation

protected void setAnnotation(int annotation)
Set the type annotation code to be allocated by this validator


getAnnotation

protected int getAnnotation()
Get the type annotation code to be used on elements validated by this validator


setXSIType

public void setXSIType(SchemaType xsiType)
Set the value of the xsi:type attribute. This is called immediately before the call of startElement on which the xsi:type attribute appears.


setNamespaceResolver

public void setNamespaceResolver(NamespaceResolver resolver)
Set the NamespaceResolver to be used for resolving QName-valued attributes


getNamespaceResolver

public NamespaceResolver getNamespaceResolver()
Get the namespace resolver


setNillable

public void setNillable(boolean nillable)
Set whether this type permits xsi:nil = true


isNillable

public boolean isNillable()
Determine whether this type permits xsi:nil = true


startElement

public void startElement(int nameCode,
                         int typeCode,
                         int properties)
                  throws javax.xml.transform.TransformerException
Handle the start tag for a child element of the element being validated

Specified by:
startElement in interface Receiver
Overrides:
startElement in class ProxyReceiver
Parameters:
nameCode - integer code identifying the name of the element within the name pool.
typeCode - integer code identifying the element's type within the name pool.
javax.xml.transform.TransformerException

makeValidator

public static Validator makeValidator(int nameCode,
                                      SchemaType xsiType,
                                      int validation,
                                      ValidationContext validationContext,
                                      Configuration config)
                               throws javax.xml.transform.TransformerException
Factory method to make a validator for a particular element

Parameters:
nameCode - the name of the element to be validated
xsiType - the type identified by xsi:type, if specified; otherwise null
validation - the validation mode (strict, lax, preserve, strip)
validationContext - the validation context
config - the configuration
Returns:
a Validator suitable for validating the content of this element
javax.xml.transform.TransformerException

makeValidator

public static Validator makeValidator(SchemaType type,
                                      SchemaType xsiType,
                                      ElementDecl decl)
                               throws javax.xml.transform.TransformerException
javax.xml.transform.TransformerException

checkDerivation

public static void checkDerivation(SchemaType xsiType,
                                   SchemaType type,
                                   int block)
                            throws ValidationException
Check that this type is validly derived from a given type

ValidationException

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
                        throws javax.xml.transform.TransformerException
Set the Document Locator

Specified by:
setDocumentLocator in interface Receiver
Overrides:
setDocumentLocator in class ProxyReceiver
javax.xml.transform.TransformerException

getTypeAnnotation

public abstract int getTypeAnnotation()
Get the type annotation to be used for an element or attribute that conforms to the type being validated against


getChildValidator

protected abstract Validator getChildValidator()
Get a validator to handle the children of the current element. This is called immediately on return from the startElement call that starts this element.


getSystemId

public java.lang.String getSystemId()
Specified by:
getSystemId in interface javax.xml.transform.Result
Overrides:
getSystemId in class ProxyReceiver

getPublicId

public java.lang.String getPublicId()
Return the public identifier for the current document event.

The return value is the public identifier of the document entity or of the external parsed entity in which the markup that triggered the event appears.

Specified by:
getPublicId in interface javax.xml.transform.SourceLocator
Returns:
A string containing the public identifier, or null if none is available.
See Also:
getSystemId()

getLineNumber

public int getLineNumber()
Return the line number where the current document event ends.

Warning: The return value from the method is intended only as an approximation for the sake of error reporting; it is not intended to provide sufficient information to edit the character content of the original XML document.

The return value is an approximation of the line number in the document entity or external parsed entity where the markup that triggered the event appears.

Specified by:
getLineNumber in interface javax.xml.transform.SourceLocator
Returns:
The line number, or -1 if none is available.
See Also:
getColumnNumber()

getColumnNumber

public int getColumnNumber()
Return the character position where the current document event ends.

Warning: The return value from the method is intended only as an approximation for the sake of error reporting; it is not intended to provide sufficient information to edit the character content of the original XML document.

The return value is an approximation of the column number in the document entity or external parsed entity where the markup that triggered the event appears.

Specified by:
getColumnNumber in interface javax.xml.transform.SourceLocator
Returns:
The column number, or -1 if none is available.
See Also:
getLineNumber()

makeValidator

public static Validator makeValidator(SchemaType schemaType)
Factory method to create a validator for elements of this type

Returns:
a Validator that can sit in the event pipeline to perform local validation of elements declared to have this type


Stylus Studio features integrated development and debugging support for Saxon in the XQuery editor and XSLT editor.