com.ctc.wstx.msv
Class GenericMsvValidator

java.lang.Object
  extended by org.codehaus.stax2.validation.XMLValidator
      extended by com.ctc.wstx.msv.GenericMsvValidator
All Implemented Interfaces:
com.sun.msv.grammar.IDContextProvider2, org.relaxng.datatype.ValidationContext

public final class GenericMsvValidator
extends org.codehaus.stax2.validation.XMLValidator
implements com.sun.msv.grammar.IDContextProvider2

Generic validator instance to be used for all Multi-Schema Validator backed implementations. A common class can be used since functionality is almost identical between variants (RNG, W3C SChema); minor differences that exist can be configured by settings provided.

Note about id context provider interface: while it'd be nice to separate that part out, it is unfortunately closely tied to the validation process. Hence it's directly implemented by this class.


Field Summary
protected  ArrayList mAcceptors
           
protected  org.codehaus.stax2.validation.ValidationContext mContext
           
protected  com.sun.msv.verifier.Acceptor mCurrAcceptor
           
protected  String mCurrAttrLocalName
           
protected  String mCurrAttrPrefix
           
protected  ElementIdMap mIdDefs
          Map that contains information about element id (values of attributes or textual content with type ID) declarations and references
protected  org.codehaus.stax2.validation.XMLValidationSchema mParentSchema
           
protected  org.codehaus.stax2.validation.XMLValidationProblem mProblem
          Sometimes a problem object has to be temporarily stored, and only reported later on.
protected  TextAccumulator mTextAccumulator
           
protected  com.sun.msv.verifier.DocumentDeclaration mVGM
           
 
Fields inherited from class org.codehaus.stax2.validation.XMLValidator
CONTENT_ALLOW_ANY_TEXT, CONTENT_ALLOW_NONE, CONTENT_ALLOW_UNDEFINED, CONTENT_ALLOW_VALIDATABLE_TEXT, CONTENT_ALLOW_WS, CONTENT_ALLOW_WS_NONSTRICT
 
Constructor Summary
GenericMsvValidator(org.codehaus.stax2.validation.XMLValidationSchema parent, org.codehaus.stax2.validation.ValidationContext ctxt, com.sun.msv.verifier.DocumentDeclaration vgm)
           
 
Method Summary
 String getAttributeType(int index)
           
 String getBaseUri()
           
 int getIdAttrIndex()
           
 int getNotationAttrIndex()
           
 org.codehaus.stax2.validation.XMLValidationSchema getSchema()
           
 boolean isNotation(String notationName)
           
 boolean isUnparsedEntity(String entityName)
           
 void onID(org.relaxng.datatype.Datatype datatype, com.sun.msv.verifier.regexp.StringToken idToken)
           Note: we have to throw a dummy marker exception, which merely signals that a validation problem is to be reported.
 String resolveNamespacePrefix(String prefix)
           
 String validateAttribute(String localName, String uri, String prefix, char[] valueChars, int valueStart, int valueEnd)
           
 String validateAttribute(String localName, String uri, String prefix, String value)
           
 int validateElementAndAttributes()
           
 int validateElementEnd(String localName, String uri, String prefix)
           
 void validateElementStart(String localName, String uri, String prefix)
          Method called to update information about the newly encountered (start) element.
 void validateText(char[] cbuf, int textStart, int textEnd, boolean lastTextSegment)
           
 void validateText(String text, boolean lastTextSegment)
           
 void validationCompleted(boolean eod)
           
 
Methods inherited from class org.codehaus.stax2.validation.XMLValidator
getSchemaType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mParentSchema

protected final org.codehaus.stax2.validation.XMLValidationSchema mParentSchema

mContext

protected final org.codehaus.stax2.validation.ValidationContext mContext

mVGM

protected final com.sun.msv.verifier.DocumentDeclaration mVGM

mAcceptors

protected final ArrayList mAcceptors

mCurrAcceptor

protected com.sun.msv.verifier.Acceptor mCurrAcceptor

mTextAccumulator

protected final TextAccumulator mTextAccumulator

mIdDefs

protected ElementIdMap mIdDefs
Map that contains information about element id (values of attributes or textual content with type ID) declarations and references


mCurrAttrPrefix

protected String mCurrAttrPrefix

mCurrAttrLocalName

protected String mCurrAttrLocalName

mProblem

protected org.codehaus.stax2.validation.XMLValidationProblem mProblem
Sometimes a problem object has to be temporarily stored, and only reported later on. This happens when exceptions can not be thrown via code outside of Woodstox (like validation methods in MSV that do callbacks).

Constructor Detail

GenericMsvValidator

public GenericMsvValidator(org.codehaus.stax2.validation.XMLValidationSchema parent,
                           org.codehaus.stax2.validation.ValidationContext ctxt,
                           com.sun.msv.verifier.DocumentDeclaration vgm)
Method Detail

getBaseUri

public String getBaseUri()
Specified by:
getBaseUri in interface org.relaxng.datatype.ValidationContext

isNotation

public boolean isNotation(String notationName)
Specified by:
isNotation in interface org.relaxng.datatype.ValidationContext

isUnparsedEntity

public boolean isUnparsedEntity(String entityName)
Specified by:
isUnparsedEntity in interface org.relaxng.datatype.ValidationContext

resolveNamespacePrefix

public String resolveNamespacePrefix(String prefix)
Specified by:
resolveNamespacePrefix in interface org.relaxng.datatype.ValidationContext

onID

public void onID(org.relaxng.datatype.Datatype datatype,
                 com.sun.msv.verifier.regexp.StringToken idToken)
          throws IllegalArgumentException

Note: we have to throw a dummy marker exception, which merely signals that a validation problem is to be reported. This is obviously messy, but has to do for now.

Specified by:
onID in interface com.sun.msv.grammar.IDContextProvider2
Throws:
IllegalArgumentException

getSchema

public org.codehaus.stax2.validation.XMLValidationSchema getSchema()
Specified by:
getSchema in class org.codehaus.stax2.validation.XMLValidator

validateElementStart

public void validateElementStart(String localName,
                                 String uri,
                                 String prefix)
                          throws XMLStreamException
Method called to update information about the newly encountered (start) element. At this point namespace information has been resolved, but no DTD validation has been done. Validator is to do these validations, including checking for attribute value (and existence) compatibility.

Specified by:
validateElementStart in class org.codehaus.stax2.validation.XMLValidator
Throws:
XMLStreamException

validateAttribute

public String validateAttribute(String localName,
                                String uri,
                                String prefix,
                                String value)
                         throws XMLStreamException
Specified by:
validateAttribute in class org.codehaus.stax2.validation.XMLValidator
Throws:
XMLStreamException

validateAttribute

public String validateAttribute(String localName,
                                String uri,
                                String prefix,
                                char[] valueChars,
                                int valueStart,
                                int valueEnd)
                         throws XMLStreamException
Specified by:
validateAttribute in class org.codehaus.stax2.validation.XMLValidator
Throws:
XMLStreamException

validateElementAndAttributes

public int validateElementAndAttributes()
                                 throws XMLStreamException
Specified by:
validateElementAndAttributes in class org.codehaus.stax2.validation.XMLValidator
Throws:
XMLStreamException

validateElementEnd

public int validateElementEnd(String localName,
                              String uri,
                              String prefix)
                       throws XMLStreamException
Specified by:
validateElementEnd in class org.codehaus.stax2.validation.XMLValidator
Returns:
Validation state that should be effective for the parent element state
Throws:
XMLStreamException

validateText

public void validateText(String text,
                         boolean lastTextSegment)
                  throws XMLStreamException
Specified by:
validateText in class org.codehaus.stax2.validation.XMLValidator
Throws:
XMLStreamException

validateText

public void validateText(char[] cbuf,
                         int textStart,
                         int textEnd,
                         boolean lastTextSegment)
                  throws XMLStreamException
Specified by:
validateText in class org.codehaus.stax2.validation.XMLValidator
Throws:
XMLStreamException

validationCompleted

public void validationCompleted(boolean eod)
                         throws XMLStreamException
Specified by:
validationCompleted in class org.codehaus.stax2.validation.XMLValidator
Throws:
XMLStreamException

getAttributeType

public String getAttributeType(int index)
Specified by:
getAttributeType in class org.codehaus.stax2.validation.XMLValidator

getIdAttrIndex

public int getIdAttrIndex()
Specified by:
getIdAttrIndex in class org.codehaus.stax2.validation.XMLValidator

getNotationAttrIndex

public int getNotationAttrIndex()
Specified by:
getNotationAttrIndex in class org.codehaus.stax2.validation.XMLValidator


Copyright © 2011 Codehaus. All Rights Reserved.