Top Description Fields Constructors Methods
org.apache.xerces.impl.dtd

public Class XMLDTDValidator

extends Object
implements XMLComponent, XMLDocumentFilter, XMLDTDValidatorFilter, RevalidationHandler
Class Inheritance
All Implemented Interfaces
org.apache.xerces.impl.RevalidationHandler, org.apache.xerces.xni.parser.XMLDocumentFilter, org.apache.xerces.xni.parser.XMLDocumentSource, org.apache.xerces.xni.XMLDocumentHandler, org.apache.xerces.impl.dtd.XMLDTDValidatorFilter, org.apache.xerces.xni.parser.XMLComponent
Known Direct Subclasses
org.apache.xerces.impl.dtd.XMLNSDTDValidator, org.apache.xerces.impl.dtd.XML11DTDValidator
Imports
java.util.Iterator, org.apache.xerces.impl.Constants, .RevalidationHandler, .XMLEntityManager, .XMLErrorReporter, org.apache.xerces.impl.dtd.models.ContentModelValidator, org.apache.xerces.impl.dv.DTDDVFactory, .DatatypeValidator, .InvalidDatatypeValueException, org.apache.xerces.impl.msg.XMLMessageFormatter, org.apache.xerces.impl.validation.ValidationManager, .ValidationState, org.apache.xerces.util.SymbolTable, .XMLChar, .XMLSymbols, org.apache.xerces.xni.Augmentations, .NamespaceContext, .QName, .XMLAttributes, .XMLDocumentHandler, .XMLLocator, .XMLResourceIdentifier, .XMLString, .XNIException, org.apache.xerces.xni.grammars.Grammar, .XMLGrammarDescription, .XMLGrammarPool, org.apache.xerces.xni.parser.XMLComponent, .XMLComponentManager, .XMLConfigurationException, .XMLDocumentFilter, .XMLDocumentSource

The DTD validator. The validator implements a document filter: receiving document events from the scanner; validating the content and structure; augmenting the InfoSet, if applicable; and notifying the parser of the information resulting from the validation process.

Formerly, this component also handled DTD events and grammar construction. To facilitate the development of a meaningful DTD grammar caching/preparsing framework, this functionality has been moved into the XMLDTDLoader class. Therefore, this class no longer implements the DTDFilter or DTDContentModelFilter interfaces.

This component requires the following features and properties from the component manager that uses it:

Authors
Eric Ye, IBM, Andy Clark, IBM, Jeffrey Rodriguez IBM, Neil Graham, IBM
Version
$Id: XMLDTDValidator.java 1380445 2012-09-04 04:43:34Z mrglavas $

Field Summary

Modifier and TypeField and Description
protected static final String
BALANCE_SYNTAX_TREES

Feature identifier: balance syntax trees.

protected static final String
DATATYPE_VALIDATOR_FACTORY

Property identifier: datatype validator factory.

private static final boolean
DEBUG_ATTRIBUTES

Compile to true to debug attributes.

private static final boolean
DEBUG_ELEMENT_CHILDREN

Compile to true to debug element children.

protected static final String
DYNAMIC_VALIDATION

Feature identifier: dynamic validation.

protected static final String
ERROR_REPORTER

Property identifier: error reporter.

protected boolean
fBalanceSyntaxTrees

Controls whether the DTD grammar produces balanced syntax trees.

private final StringBuffer
fBuffer

Temporary string buffers.

private int[]
fContentSpecTypeStack

Content spec type stack.

private int
fCurrentContentSpecType

Current content spec type.

private final QName
fCurrentElement

Current element name.

private int
fCurrentElementIndex

Current element index.

protected DTDDVFactory
fDatatypeValidatorFactory

Datatype validator factory.

protected XMLLocator
protected XMLDocumentHandler
fDocumentHandler

Document handler.

protected XMLDocumentSource
protected DTDGrammar
fDTDGrammar

DTD Grammar.

protected boolean
fDTDValidation

Validation against only DTD

protected boolean
fDynamicValidation

Dynamic validation.

private static final Boolean[]
FEATURE_DEFAULTS

Feature defaults.

private QName[]
fElementChildren

Element children.

private int
fElementChildrenLength

Element children count.

private int[]
fElementChildrenOffsetStack

Element children offset stack.

private int
fElementDepth

Element depth.

private int[]
fElementIndexStack

Element index stack.

private QName[]
fElementQNamePartsStack

Element name stack.

private final XMLEntityDecl
fEntityDecl

Temporary entity declaration.

protected XMLErrorReporter
fErrorReporter

Error reporter.

protected DTDGrammarBucket
fGrammarBucket

Grammar bucket.

protected XMLGrammarPool
private boolean
private boolean
fInElementContent

True if inside of element content.

protected NamespaceContext
fNamespaceContext

Namespace support.

protected boolean
fNamespaces

Namespaces.

private boolean
fPerformValidation

Perform validation.

private final QName
fRootElement

The root element name.

private String
fSchemaType

Schema type: None, DTD, Schema

protected boolean
fSeenDoctypeDecl

True if seen DOCTYPE declaration.

private boolean
fSeenRootElement

True if seen the root element.

protected SymbolTable
fSymbolTable

Symbol table.

private final XMLAttributeDecl
fTempAttDecl

Temporary atribute declaration.

private final XMLElementDecl
fTempElementDecl

Temporary element declaration.

private final QName
fTempQName

Temporary qualified name.

protected DatatypeValidator
fValENTITIES

Datatype validator: ENTITIES.

protected DatatypeValidator
fValENTITY

Datatype validator: ENTITY.

protected DatatypeValidator
fValID

Datatype validator: ID.

protected boolean
fValidation

Validation.

protected ValidationManager
protected final ValidationState
protected DatatypeValidator
fValIDRef

Datatype validator: IDREF.

protected DatatypeValidator
fValIDRefs

Datatype validator: IDREFS.

protected DatatypeValidator
fValNMTOKEN

Datatype validator: NMTOKEN.

protected DatatypeValidator
fValNMTOKENS

Datatype validator: NMTOKENS.

protected DatatypeValidator
fValNOTATION

Datatype validator: NOTATION.

protected boolean
fWarnDuplicateAttdef

warn on duplicate attribute definition, this feature works only when validation is true

protected static final String
GRAMMAR_POOL

Property identifier: grammar pool.

protected static final String
NAMESPACES

Feature identifier: namespaces.

protected static final String
private static final Object[]
PROPERTY_DEFAULTS

Property defaults.

private static final String[]
RECOGNIZED_FEATURES

Recognized features.

private static final String[]
RECOGNIZED_PROPERTIES

Recognized properties.

protected static final String
SYMBOL_TABLE

Property identifier: symbol table.

private static final int
TOP_LEVEL_SCOPE

Top level scope (-1).

protected static final String
VALIDATION

Feature identifier: validation.

protected static final String
protected static final String
WARN_ON_DUPLICATE_ATTDEF

Feature identifier: warn on duplicate attdef

Constructor Summary

AccessConstructor and Description
public
XMLDTDValidator()

Default constructor.

Method Summary

Modifier and TypeMethod and Description
protected void
addDTDDefaultAttrsAndValidate(QName elementName, int elementIndex, XMLAttributes attributes)

Add default attributes and validate.

public boolean
characterData(String
The character data.
data
,
Augmentations
Augmentations
augs
)

Implements org.apache.xerces.impl.RevalidationHandler.characterData.

Character content.
public void
characters(XMLString
The content.
text
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements org.apache.xerces.xni.XMLDocumentHandler.characters.

Character content.
private void
charDataInContent()

Character data in content.

private int

Returns:

The value -1 if fully valid, else the 0 based index of the child that first failed. If the value returned is equal to the number of children, then additional content is required to reach a valid ending state.
checkContent
(int
The index within the ElementDeclPool of this element.
elementIndex
,
QName[]
The children of this element.
children
,
int childOffset, int
The number of entries in the children array.
childCount
)

Check that the content of an element is valid.

public void
comment(XMLString
The text in the comment.
text
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements org.apache.xerces.xni.XMLDocumentHandler.comment.

A comment.
public void
doctypeDecl(String
The name of the root element.
rootElement
,
String
The public identifier if an external DTD or null if the external DTD is specified using SYSTEM.
publicId
,
String
The system identifier if an external DTD, null otherwise.
systemId
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements org.apache.xerces.xni.XMLDocumentHandler.doctypeDecl.

Notifies of the presence of the DOCTYPE line in the document.
public void
emptyElement(QName
The name of the element.
element
,
XMLAttributes
The element attributes.
attributes
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements org.apache.xerces.xni.XMLDocumentHandler.emptyElement.

An empty element.
public void
endCDATA(Augmentations
Additional information that may include infoset augmentations
augs
)

Implements org.apache.xerces.xni.XMLDocumentHandler.endCDATA.

The end of a CDATA section.
public void
endDocument(Augmentations
Additional information that may include infoset augmentations
augs
)

Implements org.apache.xerces.xni.XMLDocumentHandler.endDocument.

The end of the document.
public void
endElement(QName
The name of the element.
element
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements org.apache.xerces.xni.XMLDocumentHandler.endElement.

The end of an element.
public void
endGeneralEntity(String
The name of the entity.
name
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements org.apache.xerces.xni.XMLDocumentHandler.endGeneralEntity.

This method notifies the end of a general entity.
protected void
endNamespaceScope(QName element, Augmentations augs, boolean isEmpty)

private void
ensureStackCapacity(int newElementDepth)

ensure element stack capacity

private String
getAttributeTypeName(XMLAttributeDecl attrDecl)

convert attribute type from ints to strings

private int
getContentSpecType(int elementIndex)

Returns the content spec type for an element index.

public XMLDocumentHandler
public XMLDocumentSource
protected String
getExternalEntityRefInAttrValue(String nonNormalizedValue)

Checks entities in attribute values for standalone VC.

public Boolean
getFeatureDefault(String
The feature identifier.
featureId
)

Implements org.apache.xerces.xni.parser.XMLComponent.getFeatureDefault.

Returns the default state for a feature, or null if this component does not want to report a default value for this feature.
pack-priv DTDGrammarBucket
public Object
getPropertyDefault(String
The property identifier.
propertyId
)

Implements org.apache.xerces.xni.parser.XMLComponent.getPropertyDefault.

Returns the default state for a property, or null if this component does not want to report a default value for this property.
public String[]
getRecognizedFeatures()

Implements org.apache.xerces.xni.parser.XMLComponent.getRecognizedFeatures.

Returns a list of feature identifiers that are recognized by this component.
public String[]
getRecognizedProperties()

Implements org.apache.xerces.xni.parser.XMLComponent.getRecognizedProperties.

Returns a list of property identifiers that are recognized by this component.
protected void
handleEndElement(QName element, Augmentations augs, boolean isEmpty)

Handle end element.

protected boolean

Returns:

true if validator is removed from the pipeline
handleStartElement
(QName element, XMLAttributes attributes, Augmentations augs)

Handle element

public final boolean
hasGrammar()

Implements org.apache.xerces.impl.dtd.XMLDTDValidatorFilter.hasGrammar.

Returns true if the validator has a DTD grammar
public void
ignorableWhitespace(XMLString
The ignorable whitespace.
text
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements org.apache.xerces.xni.XMLDocumentHandler.ignorableWhitespace.

Ignorable whitespace.
protected void
init()

initialization

protected boolean
invalidStandaloneAttDef(QName element, QName attribute)

Returns true if invalid standalone attribute definition.

protected boolean
isSpace(int c)

private boolean
normalizeAttrValue(XMLAttributes
The list of attributes
attributes
,
int
The index of the attribute to normalize
index
)

Normalize the attribute value of a non CDATA attributes collapsing sequences of space characters (x20)

public void
processingInstruction(String
The target.
target
,
XMLString
The data or null if none specified.
data
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements org.apache.xerces.xni.XMLDocumentHandler.processingInstruction.

A processing instruction.
public void
reset(XMLComponentManager
The component manager.
componentManager
)

Implements org.apache.xerces.xni.parser.XMLComponent.reset.

Resets the component.
private final void
rootElementSpecified(QName rootElement)

Root element specified.

public void
setDocumentHandler(XMLDocumentHandler documentHandler)

Implements org.apache.xerces.xni.parser.XMLDocumentSource.setDocumentHandler.

Sets the document handler to receive information about the document.
public void
public void
setFeature(String
The feature identifier.
featureId
,
boolean
The state of the feature.
state
)

Implements org.apache.xerces.xni.parser.XMLComponent.setFeature.

Sets the state of a feature.
public void
setProperty(String
The property identifier.
propertyId
,
Object
The value of the property.
value
)

Implements org.apache.xerces.xni.parser.XMLComponent.setProperty.

Sets the value of a property.
public void
startCDATA(Augmentations
Additional information that may include infoset augmentations
augs
)

Implements org.apache.xerces.xni.XMLDocumentHandler.startCDATA.

The start of a CDATA section.
public void
startDocument(XMLLocator
The system identifier of the entity if the entity is external, null otherwise.
locator
,
String
The auto-detected IANA encoding name of the entity stream. This value will be null in those situations where the entity encoding is not auto-detected (e.g. internal entities or a document entity that is parsed from a java.io.Reader).
encoding
,
NamespaceContext
The namespace context in effect at the start of this document. This object represents the current context. Implementors of this class are responsible for copying the namespace bindings from the the current context (and its parent contexts) if that information is important.
namespaceContext
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements org.apache.xerces.xni.XMLDocumentHandler.startDocument.

The start of the document.
public void
startElement(QName
The name of the element.
element
,
XMLAttributes
The element attributes.
attributes
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements org.apache.xerces.xni.XMLDocumentHandler.startElement.

The start of an element.
public void
startGeneralEntity(String
The name of the general entity.
name
,
XMLResourceIdentifier
The resource identifier.
identifier
,
String
The auto-detected IANA encoding name of the entity stream. This value will be null in those situations where the entity encoding is not auto-detected (e.g. internal entities or a document entity that is parsed from a java.io.Reader).
encoding
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements org.apache.xerces.xni.XMLDocumentHandler.startGeneralEntity.

This method notifies the start of a general entity.
protected void
public void
textDecl(String
The XML version, or null if not specified.
version
,
String
The IANA encoding name of the entity.
encoding
,
Augmentations
Additional information that may include infoset augmentations.
augs
)

Implements org.apache.xerces.xni.XMLDocumentHandler.textDecl.

Notifies of the presence of a TextDecl line in an entity.
public final boolean
validate()

Implements org.apache.xerces.impl.dtd.XMLDTDValidatorFilter.validate.

Return true if validator must validate the document
protected void
validateDTDattribute(QName element, String attValue, XMLAttributeDecl attributeDecl)

Validate attributes in DTD fashion.

public void
xmlDecl(String
The XML version.
version
,
String
The IANA encoding name of the document, or null if not specified.
encoding
,
String
The standalone value, or null if not specified.
standalone
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements org.apache.xerces.xni.XMLDocumentHandler.xmlDecl.

Notifies of the presence of an XMLDecl line in the document.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait