XMLValidator for DTD validation.
Since there are 2 sub-types -- full actual DTD validator, and a dummy
one that only adds type information and default values, with no actual
validation -- common functionality was refactored into this base
class.
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final int | DEFAULT_STACK_SIZE
Estimated maximum depth of typical documents; used to allocate the array for element stack |
| protected static final HashMap | EMPTY_MAP
Let's actually just reuse a local Map... |
| pack-priv static final int | EXP_MAX_ATTRS
Estimated maximum number of attributes for a single element |
| protected int | mAttrCount
Number of attribute specification Objects in
|
| protected DTDAttribute[] | mAttrSpecs
List of attribute declarations/specifications, one for each attribute of the current element, for which there is a matching value (either explicitly defined, or assigned via defaulting). |
| pack-priv final ValidationContext | mContext
Validation context (owner) for this validator. |
| protected HashMap | mCurrAttrDefs
Attribute definitions for attributes the current element may have |
| protected DTDElement | mCurrElem
This is the element that is currently being validated; valid
during
|
| protected int | mElemCount
Number of elements in |
| protected DTDElement[] | mElems
Stack of element definitions matching the current active element stack. |
| pack-priv final Map | mElemSpecs
Map that contains element specifications from DTD; null if no DOCTYPE declaration found. |
| pack-priv final Map | mGeneralEntities
General entities defined in DTD subsets; needed for validating ENTITY/ENTITIES attributes. |
| pack-priv final boolean | mHasNsDefaults
Flag that indicates whether any of the elements declared has default attribute values for namespace declaration pseudo-attributes. |
| protected int | mIdAttrIndex
Index of the attribute of type ID, within current element's attribute list. |
| protected boolean | mNormAttrs
Flag that indicates whether parser wants the attribute values to be normalized (according to XML specs) or not (which may be more efficient, although not compliant with the specs) |
| pack-priv final DTDSubset | mSchema
DTD schema ( |
| pack-priv char[] | mTmpAttrValueBuffer
Temporary buffer attribute instances can share for validation purposes |
| protected final transient PrefixedName | |
| protected static final HashMap |
| Access | Constructor and Description |
|---|---|
| public | DTDValidatorBase(DTDSubset schema, ValidationContext ctxt, boolean hasNsDefaults, Map<PrefixedName, DTDElement> elemSpecs, Map<String, EntityDecl> genEntities)
|
| Modifier and Type | Method and Description |
|---|---|
| public void | checkNsDefaults(InputElementStack nsStack)
Implements com. Method called by the input element stack to indicate that it has just added local namespace declarations from the current element, and is about to start resolving element and attribute namespace bindings. |
| protected void | |
| protected void | |
| public String | getAttributeType(int index)
Implements abstract org. Method for getting schema-specified type of an attribute, if information is available. |
| pack-priv PrefixedName | |
| pack-priv Map | |
| public int | Returns: Index of the attribute with type ID, in the current element, if one exists: -1 otherwiseImplements abstract org. Method for finding out the index of the attribute (collected using the attribute collector; having DTD-derived info in same order) that is of type ID. DTD explicitly specifies that at most one attribute can have this type for any element. |
| protected abstract ElementIdMap | |
| pack-priv Location | |
| public int | Returns: Index of the attribute with type NOTATION, in the current element, if one exists: -1 otherwiseImplements abstract org. Method for finding out the index of the attribute (collected using the attribute collector; having DTD-derived info in same order) that is of type NOTATION. |
| public final XMLValidationSchema | getSchema()
Implements abstract org. Returns the schema instance that created this validator object, if known (and applicable). |
| pack-priv char[] | |
| public boolean | |
| public boolean | mayHaveNsDefaults(String elemPrefix, String elemLN)
Implements com. Calling this method before |
| public abstract boolean | Returns: True for validator object that actually do validate content; false for objects that only use DTD type information.
|
| pack-priv void | reportValidationProblem(String msg)
Method called to report validity problems; depending on mode, will either throw an exception, or add a problem notification to the list of problems. |
| pack-priv void | |
| pack-priv void | |
| pack-priv void | |
| public void | setAttrValueNormalization(boolean state)
Method that allows enabling/disabling attribute value normalization. |
| public abstract String | validateAttribute(String localName, String uri, String prefix, String value)
Implements abstract org. 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 abstract 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 valueStart, int valueChars arrayIndex of the character AFTER the last character;
so that the length of the value String is
valueEnd)valueEnd - valueStartImplements abstract org. 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 abstract int | validateElementAndAttributes()
Implements abstract org. Method called after calling |
| public abstract int | Returns: Validation state that should be effective for the parent element stateImplements abstract org. Method called right after encountering an element close tag. |
| public abstract void | validateElementStart(String localName, String uri, String prefix)
Implements abstract org. Method called to update information about the newly encountered (start) element. |
| public void | validateText(String
Text content to validate text, boolean Whether this text content is the last text
segment before a close element; true if it is, false if it is not,
or no determination can be made. Can be used for optimizing
validation -- if this is true, no text needs to be buffered since
no more will be sent before the current element closes. lastTextSegment)Implements abstract org. Method called to validate textual content. |
| public void | validateText(char[]
Character array that contains text content to validate cbuf, int Index of the first character of the content to
validate textStart, int Character following the last character of the
content to validate (that is, length of content to validate is
textEnd, boolean textEnd - textStart).Whether this text content is the last text
segment before a close element; true if it is, false if it is not,
or no determination can be made. Can be used for optimizing
validation -- if this is true, no text needs to be buffered since
no more will be sent before the current element closes. lastTextSegment)Implements abstract org. Method called to validate textual content. |
| public abstract 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 org. 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). |
| DEFAULT_STACK_SIZE | back to summary |
|---|---|
| pack-priv static final int DEFAULT_STACK_SIZE Estimated maximum depth of typical documents; used to allocate the array for element stack | |
| EMPTY_MAP | back to summary |
|---|---|
| protected static final HashMap<String, EntityDecl> EMPTY_MAP Let's actually just reuse a local Map... | |
| EXP_MAX_ATTRS | back to summary |
|---|---|
| pack-priv static final int EXP_MAX_ATTRS Estimated maximum number of attributes for a single element | |
| mAttrCount | back to summary |
|---|---|
| protected int mAttrCount Number of attribute specification Objects in
| |
| mAttrSpecs | back to summary |
|---|---|
| protected DTDAttribute[] mAttrSpecs List of attribute declarations/specifications, one for each attribute of the current element, for which there is a matching value (either explicitly defined, or assigned via defaulting). | |
| mContext | back to summary |
|---|---|
| pack-priv final ValidationContext mContext Validation context (owner) for this validator. Needed for adding default attribute values, for example. | |
| mCurrAttrDefs | back to summary |
|---|---|
| protected HashMap<PrefixedName, DTDAttribute> mCurrAttrDefs Attribute definitions for attributes the current element may have | |
| mCurrElem | back to summary |
|---|---|
| protected DTDElement mCurrElem This is the element that is currently being validated; valid
during
| |
| mElemCount | back to summary |
|---|---|
| protected int mElemCount Number of elements in | |
| mElems | back to summary |
|---|---|
| protected DTDElement[] mElems Stack of element definitions matching the current active element stack. Instances are elements definitions read from DTD. | |
| mElemSpecs | back to summary |
|---|---|
| pack-priv final Map<PrefixedName, DTDElement> mElemSpecs Map that contains element specifications from DTD; null if no DOCTYPE declaration found. | |
| mGeneralEntities | back to summary |
|---|---|
| pack-priv final Map<String, EntityDecl> mGeneralEntities General entities defined in DTD subsets; needed for validating ENTITY/ENTITIES attributes. | |
| mHasNsDefaults | back to summary |
|---|---|
| pack-priv final boolean mHasNsDefaults Flag that indicates whether any of the elements declared has default attribute values for namespace declaration pseudo-attributes. | |
| mIdAttrIndex | back to summary |
|---|---|
| protected int mIdAttrIndex Index of the attribute of type ID, within current element's attribute list. Track of this is kept separate from other attribute since id attributes often need to be used for resolving cross-references. | |
| mNormAttrs | back to summary |
|---|---|
| protected boolean mNormAttrs Flag that indicates whether parser wants the attribute values to be normalized (according to XML specs) or not (which may be more efficient, although not compliant with the specs) | |
| mSchema | back to summary |
|---|---|
| pack-priv final DTDSubset mSchema DTD schema ( | |
| mTmpAttrValueBuffer | back to summary |
|---|---|
| pack-priv char[] mTmpAttrValueBuffer Temporary buffer attribute instances can share for validation purposes | |
| mTmpKey | back to summary |
|---|---|
| protected final transient PrefixedName mTmpKey | |
| NO_ATTRS | back to summary |
|---|---|
| protected static final HashMap<PrefixedName, DTDAttribute> NO_ATTRS | |
| DTDValidatorBase | back to summary |
|---|---|
| public DTDValidatorBase(DTDSubset schema, ValidationContext ctxt, boolean hasNsDefaults, Map<PrefixedName, DTDElement> elemSpecs, Map<String, EntityDecl> genEntities) | |
| checkNsDefaults | back to summary |
|---|---|
| public void checkNsDefaults(InputElementStack nsStack) throws XMLStreamException Implements com. Doc from com. Method called by the input element stack to indicate that it has just added local namespace declarations from the current element, and is about to start resolving element and attribute namespace bindings. This provider instance is to add namespace declarations from attribute defaults, if any, using callbacks to the input element stack.
| |
| doAddDefaultValue | back to summary |
|---|---|
| protected void doAddDefaultValue(DTDAttribute attr) throws XMLStreamException | |
| doReportValidationProblem | back to summary |
|---|---|
| protected void doReportValidationProblem(String msg, Location loc) throws XMLStreamException | |
| getAttributeType | back to summary |
|---|---|
| public String getAttributeType(int index) Implements abstract org. Doc from org. Method for getting schema-specified type of an attribute, if information is available. If not, validators can return null to explicitly indicate no information was available.
| |
| getElemName | back to summary |
|---|---|
| pack-priv PrefixedName getElemName() Name of current element on the top of the element stack. | |
| getEntityMap | back to summary |
|---|---|
| pack-priv Map | |
| getIdAttrIndex | back to summary |
|---|---|
| public int getIdAttrIndex() Implements abstract org. Method for finding out the index of the attribute (collected using the attribute collector; having DTD-derived info in same order) that is of type ID. DTD explicitly specifies that at most one attribute can have this type for any element.
| |
| getIdMap | back to summary |
|---|---|
| protected abstract ElementIdMap getIdMap() | |
| getLocation | back to summary |
|---|---|
| pack-priv Location getLocation() | |
| getNotationAttrIndex | back to summary |
|---|---|
| public int getNotationAttrIndex() Implements abstract org. Method for finding out the index of the attribute (collected using the attribute collector; having DTD-derived info in same order) that is of type NOTATION. DTD explicitly specifies that at most one attribute can have this type for any element.
| |
| getSchema | back to summary |
|---|---|
| public final XMLValidationSchema getSchema() Implements abstract org. Doc from org. Returns the schema instance that created this validator
object, if known (and applicable). May return null for
some instances: specifically,
| |
| getTempAttrValueBuffer | back to summary |
|---|---|
| pack-priv char[] getTempAttrValueBuffer(int neededLength) | |
| hasNsDefaults | back to summary |
|---|---|
| public boolean hasNsDefaults() | |
| mayHaveNsDefaults | back to summary |
|---|---|
| public boolean mayHaveNsDefaults(String elemPrefix, String elemLN) Implements com. Calling this method before
| |
| reallyValidating | back to summary |
|---|---|
public abstract boolean reallyValidating()
| |
| reportValidationProblem | back to summary |
|---|---|
| pack-priv void reportValidationProblem(String msg) throws XMLStreamException Method called to report validity problems; depending on mode, will either throw an exception, or add a problem notification to the list of problems. | |
| reportValidationProblem | back to summary |
|---|---|
| pack-priv void reportValidationProblem(String msg, Location loc) throws XMLStreamException | |
| reportValidationProblem | back to summary |
|---|---|
| pack-priv void reportValidationProblem(String format, Object arg) throws XMLStreamException | |
| reportValidationProblem | back to summary |
|---|---|
| pack-priv void reportValidationProblem(String format, Object arg1, Object arg2) throws XMLStreamException | |
| setAttrValueNormalization | back to summary |
|---|---|
| public void setAttrValueNormalization(boolean state) Method that allows enabling/disabling attribute value normalization. In general, readers by default enable normalization (to be fully xml compliant), whereas writers do not (since there is usually little to gain, if anything -- it is even possible value may be written before validation is called in some cases) | |
| validateAttribute | back to summary |
|---|---|
| public abstract String validateAttribute(String localName, String uri, String prefix, String value) throws XMLStreamException Implements abstract org. Doc from org. 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.).
| |
| validateAttribute | back to summary |
|---|---|
| public abstract String validateAttribute(String localName, String uri, String prefix, char[] valueChars, int valueStart, int valueEnd) throws XMLStreamException Implements abstract org. Doc from org. 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.).
| |
| validateElementAndAttributes | back to summary |
|---|---|
| public abstract int validateElementAndAttributes() throws XMLStreamException Implements abstract org. Doc from org. Method called after calling
| |
| validateElementEnd | back to summary |
|---|---|
| public abstract int validateElementEnd(String localName, String uri, String prefix) throws XMLStreamException Implements abstract org. Doc from org. Method called right after encountering an element close tag.
| |
| validateElementStart | back to summary |
|---|---|
| public abstract void validateElementStart(String localName, String uri, String prefix) throws XMLStreamException Implements abstract org. 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.
| |
| validateText | back to summary |
|---|---|
| public void validateText(String text, boolean lastTextSegment) throws XMLStreamException Implements abstract org. Doc from org. Method called to validate textual content. Note this method is only guaranteed to be called when
| |
| validateText | back to summary |
|---|---|
| public void validateText(char[] cbuf, int textStart, int textEnd, boolean lastTextSegment) throws XMLStreamException Implements abstract org. Doc from org. Method called to validate textual content. Note this method is only guaranteed to be called when
| |
| validationCompleted | back to summary |
|---|---|
| public abstract void validationCompleted(boolean eod) throws XMLStreamException Implements abstract org. Doc from org. 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).
| |