Top Description Fields Constructors Methods
com.ctc.wstx.dtd

public Class DTDValidator

extends DTDValidatorBase
Class Inheritance
Imports
java.util.*, javax.xml.stream.XMLStreamException, org.codehaus.stax2.validation.*, com.ctc.wstx.cfg.ErrorConsts, com.ctc.wstx.ent.EntityDecl, com.ctc.wstx.util.DataUtil, .ElementId, .ElementIdMap, .PrefixedName, .StringUtil

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

Field Summary

Modifier and TypeField and Description
protected boolean
protected BitSet
mCurrSpecialAttrs

Bitset used for keeping track of required and defaulted attributes for which values have been found.

protected 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 BitSet
mTmpSpecialAttrs

Reusable lazily instantiated BitSet; needed to keep track of missing 'special' attributes (required ones, ones with default values)

protected StructValidator[]
mValidators

Stack of validators for open elements

Inherited from com.ctc.wstx.dtd.DTDValidatorBase:
DEFAULT_STACK_SIZEEMPTY_MAPEXP_MAX_ATTRSmAttrCountmAttrSpecsmContextmCurrAttrDefsmCurrElemmElemCountmElemsmElemSpecsmGeneralEntitiesmHasNsDefaultsmIdAttrIndexmNormAttrsmSchemamTmpAttrValueBuffermTmpKeyNO_ATTRS

Constructor Summary

AccessConstructor and Description
public
DTDValidator(DTDSubset schema, ValidationContext ctxt, boolean hasNsDefaults, Map<PrefixedName, DTDElement> elemSpecs, Map<String, EntityDecl> genEntities)

Method Summary

Modifier and TypeMethod and Description
protected void
protected ElementIdMap
public final boolean
public String
validateAttribute(String localName, String uri, String prefix, String value)

Implements abstract com.ctc.wstx.dtd.DTDValidatorBase.validateAttribute.

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.).

public String
validateAttribute(String localName, String uri, String prefix, char[]
Character array that contains value (possibly along with some other text)
valueChars
,
int
Index of the first character of the value in in valueChars array
valueStart
,
int
Index of the character AFTER the last character; so that the length of the value String is valueEnd - valueStart
valueEnd
)

Implements abstract com.ctc.wstx.dtd.DTDValidatorBase.validateAttribute.

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.).

public int
validateElementAndAttributes()

Implements abstract com.ctc.wstx.dtd.DTDValidatorBase.validateElementAndAttributes.

Method called after calling validateAttribute on all attributes (if any), but before starting to handle element content.

public int

Returns:

Validation state that should be effective for the parent element state
validateElementEnd
(String localName, String uri, String prefix)

Implements abstract com.ctc.wstx.dtd.DTDValidatorBase.validateElementEnd.

Method called right after encountering an element close tag.

public void
validateElementStart(String localName, String uri, String prefix)

Implements abstract com.ctc.wstx.dtd.DTDValidatorBase.validateElementStart.

Method called to update information about the newly encountered (start) element.

public void
validationCompleted(boolean
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).
eod
)

Implements abstract com.ctc.wstx.dtd.DTDValidatorBase.validationCompleted.

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).

Inherited from com.ctc.wstx.dtd.DTDValidatorBase:
checkNsDefaultsdoAddDefaultValuedoReportValidationProblemgetAttributeTypegetElemNamegetEntityMapgetIdAttrIndexgetLocationgetNotationAttrIndexgetSchemagetTempAttrValueBufferhasNsDefaultsmayHaveNsDefaultsreportValidationProblemreportValidationProblemreportValidationProblemreportValidationProblemsetAttrValueNormalizationvalidateTextvalidateText

Field Detail

mCurrHasAnyFixedback to summary
protected boolean mCurrHasAnyFixed
mCurrSpecialAttrsback to summary
protected BitSet mCurrSpecialAttrs

Bitset used for keeping track of required and defaulted attributes for which values have been found.

mIdMapback to summary
protected ElementIdMap mIdMap

Information about declared and referenced element ids (unique ids that attributes may defined, as defined by DTD)

mReportDuplicateErrorsback to summary
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.

mTmpSpecialAttrsback to summary
protected BitSet mTmpSpecialAttrs

Reusable lazily instantiated BitSet; needed to keep track of missing 'special' attributes (required ones, ones with default values)

mValidatorsback to summary
protected StructValidator[] mValidators

Stack of validators for open elements

Constructor Detail

DTDValidatorback to summary
public DTDValidator(DTDSubset schema, ValidationContext ctxt, boolean hasNsDefaults, Map<PrefixedName, DTDElement> elemSpecs, Map<String, EntityDecl> genEntities)

Method Detail

checkIdRefsback to summary
protected void checkIdRefs() throws XMLStreamException
getIdMapback to summary
protected ElementIdMap getIdMap()

Implements abstract com.ctc.wstx.dtd.DTDValidatorBase.getIdMap.

Annotations
@Override
reallyValidatingback to summary
public final boolean reallyValidating()

Implements abstract com.ctc.wstx.dtd.DTDValidatorBase.reallyValidating.

Returns:boolean

Doc from com.ctc.wstx.dtd.DTDValidatorBase.reallyValidating.

True for validator object that actually do validate content; false for objects that only use DTD type information.

Annotations
@Override
validateAttributeback to summary
public String validateAttribute(String localName, String uri, String prefix, String value) throws XMLStreamException

Implements abstract com.ctc.wstx.dtd.DTDValidatorBase.validateAttribute.

Doc from org.codehaus.stax2.validation.XMLValidator.validateAttribute.

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.).

Returns:String

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.

Annotations
@Override
validateAttributeback to summary
public String validateAttribute(String localName, String uri, String prefix, char[] valueChars, int valueStart, int valueEnd) throws XMLStreamException

Implements abstract com.ctc.wstx.dtd.DTDValidatorBase.validateAttribute.

Doc from org.codehaus.stax2.validation.XMLValidator.validateAttribute.

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.).

Parameters
valueChars:char[]

Character array that contains value (possibly along with some other text)

valueStart:int

Index of the first character of the value in in valueChars array

valueEnd:int

Index of the character AFTER the last character; so that the length of the value String is valueEnd - valueStart

Returns:String

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.

Annotations
@Override
validateElementAndAttributesback to summary
public int validateElementAndAttributes() throws XMLStreamException

Implements abstract com.ctc.wstx.dtd.DTDValidatorBase.validateElementAndAttributes.

Doc from org.codehaus.stax2.validation.XMLValidator.validateElementAndAttributes.

Method called after calling validateAttribute on all attributes (if any), but before starting to handle element content.

Returns:int

One of CONTENT_ALLOW_ constants, to indicate what kind of textual content is allowed at the scope returned to after the element has closed.

Annotations
@Override
validateElementEndback to summary
public int validateElementEnd(String localName, String uri, String prefix) throws XMLStreamException

Implements abstract com.ctc.wstx.dtd.DTDValidatorBase.validateElementEnd.

Doc from org.codehaus.stax2.validation.XMLValidator.validateElementEnd.

Method called right after encountering an element close tag.

Returns:int

Validation state that should be effective for the parent element state

Annotations
@Override
validateElementStartback to summary
public void validateElementStart(String localName, String uri, String prefix) throws XMLStreamException

Implements abstract com.ctc.wstx.dtd.DTDValidatorBase.validateElementStart.

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.

Annotations
@Override
validationCompletedback to summary
public void validationCompleted(boolean eod) throws XMLStreamException

Implements abstract com.ctc.wstx.dtd.DTDValidatorBase.validationCompleted.

Doc from org.codehaus.stax2.validation.XMLValidator.validationCompleted.

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).

Parameters
eod:boolean

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).

Annotations
@Override