APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.org.apache.xerces.internal.impl.dtd

public Class XMLDTDValidator

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

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

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
public void
characters(XMLString
The content.
text
,
Augmentations
Additional information that may include infoset augmentations
augs
)

Implements com.sun.org.apache.xerces.internal.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 com.sun.org.apache.xerces.internal.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 com.sun.org.apache.xerces.internal.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 com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler.emptyElement.

An empty element.

public void
endCDATA(Augmentations
Additional information that may include infoset augmentations
augs
)

Implements com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler.endCDATA.

The end of a CDATA section.

public void
endDocument(Augmentations
Additional information that may include infoset augmentations
augs
)

Implements com.sun.org.apache.xerces.internal.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 com.sun.org.apache.xerces.internal.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 com.sun.org.apache.xerces.internal.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

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 com.sun.org.apache.xerces.internal.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 com.sun.org.apache.xerces.internal.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 com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.getRecognizedFeatures.

Returns a list of feature identifiers that are recognized by this component.

public String[]
getRecognizedProperties()

Implements com.sun.org.apache.xerces.internal.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 com.sun.org.apache.xerces.internal.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 com.sun.org.apache.xerces.internal.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 com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler.processingInstruction.

A processing instruction.

public void
private final void
rootElementSpecified(QName rootElement)

Root element specified.

public void
setDocumentHandler(XMLDocumentHandler documentHandler)

Implements com.sun.org.apache.xerces.internal.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 com.sun.org.apache.xerces.internal.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 com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.setProperty.

Sets the value of a property.

public void
startCDATA(Augmentations
Additional information that may include infoset augmentations
augs
)

Implements com.sun.org.apache.xerces.internal.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 com.sun.org.apache.xerces.internal.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 com.sun.org.apache.xerces.internal.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 com.sun.org.apache.xerces.internal.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 com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler.textDecl.

Notifies of the presence of a TextDecl line in an entity.

public final boolean
validate()

Implements com.sun.org.apache.xerces.internal.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 com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler.xmlDecl.

Notifies of the presence of an XMLDecl line in the document.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait