com.ctc.wstx.dtd
Class DTDValidator

java.lang.Object
  extended by org.codehaus.stax2.validation.XMLValidator
      extended by com.ctc.wstx.dtd.DTDValidatorBase
          extended by com.ctc.wstx.dtd.DTDValidator
All Implemented Interfaces:
NsDefaultProvider

public class DTDValidator
extends DTDValidatorBase

Woodstox implementation of XMLValidator; the class that handles DTD-based validation.


Field Summary
protected  java.util.BitSet mCurrSpecialAttrs
          Bitset used for keeping track of required and defaulted attributes for which values have been found.
protected  com.ctc.wstx.dtd.ElementIdMap mIdMap
          Information about declared and referenced element ids (unique ids that attributes may defined, as defined by DTD)
protected  boolean mReportDuplicateErrors
          Determines if identical problems (definition of the same element, for example) should cause multiple error notifications or not: if true, will get one error per instance, if false, only the first one will get reported.
protected  StructValidator[] mValidators
          Stack of validators for open elements
 
Fields inherited from class com.ctc.wstx.dtd.DTDValidatorBase
EMPTY_MAP, mAttrCount, mAttrSpecs, mCurrAttrDefs, mCurrElem, mElemCount, mElems, mIdAttrIndex, mNormAttrs, mTmpKey
 
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
 
Constructor Summary
DTDValidator(DTDSubset schema, ValidationContext ctxt, boolean hasNsDefaults, java.util.Map elemSpecs, java.util.Map genEntities)
           
 
Method Summary
protected  void checkIdRefs()
           
protected  com.ctc.wstx.dtd.ElementIdMap getIdMap()
           
 boolean reallyValidating()
           
 java.lang.String validateAttribute(java.lang.String localName, java.lang.String uri, java.lang.String prefix, char[] valueChars, int valueStart, int valueEnd)
          Callback method called on validator to give it a chance to validate the value of an attribute, as well as to normalize its value if appropriate (remove leading/trailing/intervening white space for certain token types etc.).
 java.lang.String validateAttribute(java.lang.String localName, java.lang.String uri, java.lang.String prefix, java.lang.String value)
          Callback method called on validator to give it a chance to validate the value of an attribute, as well as to normalize its value if appropriate (remove leading/trailing/intervening white space for certain token types etc.).
 int validateElementAndAttributes()
          Method called after calling XMLValidator.validateAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String) on all attributes (if any), but before starting to handle element content.
 int validateElementEnd(java.lang.String localName, java.lang.String uri, java.lang.String prefix)
          Method called right after encountering an element close tag.
 void validateElementStart(java.lang.String localName, java.lang.String uri, java.lang.String prefix)
          Method called to update information about the newly encountered (start) element.
 void validationCompleted(boolean eod)
          Method called when the validation is completed; either due to the input stream ending, or due to an explicit 'stop validation' request by the application (via context object).
 
Methods inherited from class com.ctc.wstx.dtd.DTDValidatorBase
checkNsDefaults, doAddDefaultValue, doReportProblem, getAttributeType, getIdAttrIndex, getNotationAttrIndex, getSchema, hasNsDefaults, mayHaveNsDefaults, setAttrValueNormalization, validateText, validateText
 
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

mReportDuplicateErrors

protected boolean mReportDuplicateErrors
Determines if identical problems (definition of the same element, for example) should cause multiple error notifications or not: if true, will get one error per instance, if false, only the first one will get reported.


mIdMap

protected com.ctc.wstx.dtd.ElementIdMap mIdMap
Information about declared and referenced element ids (unique ids that attributes may defined, as defined by DTD)


mValidators

protected StructValidator[] mValidators
Stack of validators for open elements


mCurrSpecialAttrs

protected java.util.BitSet mCurrSpecialAttrs
Bitset used for keeping track of required and defaulted attributes for which values have been found.

Constructor Detail

DTDValidator

public DTDValidator(DTDSubset schema,
                    ValidationContext ctxt,
                    boolean hasNsDefaults,
                    java.util.Map elemSpecs,
                    java.util.Map genEntities)
Method Detail

reallyValidating

public final boolean reallyValidating()
Specified by:
reallyValidating in class DTDValidatorBase
Returns:
True for validator object that actually do validate content; false for objects that only use DTD type information.

validateElementStart

public void validateElementStart(java.lang.String localName,
                                 java.lang.String uri,
                                 java.lang.String prefix)
                          throws XMLValidationException
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 DTDValidatorBase
Throws:
XMLValidationException

validateAttribute

public java.lang.String validateAttribute(java.lang.String localName,
                                          java.lang.String uri,
                                          java.lang.String prefix,
                                          java.lang.String value)
                                   throws XMLValidationException
Description copied from class: XMLValidator
Callback method called on validator to give it a chance to validate the value of an attribute, as well as to normalize its value if appropriate (remove leading/trailing/intervening white space for certain token types etc.).

Specified by:
validateAttribute in class DTDValidatorBase
Returns:
Null, if the passed value is fine as is; or a String, if it needs to be replaced. In latter case, caller will replace the value before passing it to other validators. Also, if the attribute value is accessible via caller (as is the case for stream readers), caller should return this value, instead of the original one.
Throws:
XMLValidationException

validateAttribute

public java.lang.String validateAttribute(java.lang.String localName,
                                          java.lang.String uri,
                                          java.lang.String prefix,
                                          char[] valueChars,
                                          int valueStart,
                                          int valueEnd)
                                   throws XMLValidationException
Description copied from class: XMLValidator
Callback method called on validator to give it a chance to validate the value of an attribute, as well as to normalize its value if appropriate (remove leading/trailing/intervening white space for certain token types etc.).

Specified by:
validateAttribute in class DTDValidatorBase
valueChars - Character array that contains value (possibly along with some other text)
valueStart - Index of the first character of the value in in valueChars array
valueEnd - Index of the character AFTER the last character; so that the length of the value String is valueEnd - valueStart
Returns:
Null, if the passed value is fine as is; or a String, if it needs to be replaced. In latter case, caller will replace the value before passing it to other validators. Also, if the attribute value is accessible via caller (as is the case for stream readers), caller should return this value, instead of the original one.
Throws:
XMLValidationException

validateElementAndAttributes

public int validateElementAndAttributes()
                                 throws XMLValidationException
Description copied from class: XMLValidator
Method called after calling XMLValidator.validateAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String) on all attributes (if any), but before starting to handle element content.

Specified by:
validateElementAndAttributes in class DTDValidatorBase
Returns:
One of CONTENT_ALLOW_ constants, to indicate what kind of textual content is allowed at the scope returned to after the element has closed.
Throws:
XMLValidationException

validateElementEnd

public int validateElementEnd(java.lang.String localName,
                              java.lang.String uri,
                              java.lang.String prefix)
                       throws XMLValidationException
Description copied from class: XMLValidator
Method called right after encountering an element close tag.

Specified by:
validateElementEnd in class DTDValidatorBase
Returns:
Validation state that should be effective for the parent element state
Throws:
XMLValidationException

validationCompleted

public void validationCompleted(boolean eod)
                         throws XMLValidationException
Description copied from class: XMLValidator
Method called when the validation is completed; either due to the input stream ending, or due to an explicit 'stop validation' request by the application (via context object).

Specified by:
validationCompleted in class DTDValidatorBase
Parameters:
eod - Flag that indicates whether this method was called by the context due to the end of the stream (true); or by an application requesting end of validation (false).
Throws:
XMLValidationException

getIdMap

protected com.ctc.wstx.dtd.ElementIdMap getIdMap()
Specified by:
getIdMap in class DTDValidatorBase

checkIdRefs

protected void checkIdRefs()
                    throws XMLValidationException
Throws:
XMLValidationException