Top Description Inners Fields Constructors Methods
org.apache.xerces.impl.xs

public Class XMLSchemaValidator

extends Object
implements XMLComponent, XMLDocumentFilter, FieldActivator, RevalidationHandler, XSElementDeclHelper
Class Inheritance
All Implemented Interfaces
org.apache.xerces.impl.xs.XSElementDeclHelper, 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.xs.identity.FieldActivator, org.apache.xerces.xni.parser.XMLComponent
Imports
java.io.IOException, java.util.ArrayList, .HashMap, .Hashtable, .Iterator, .Map, .Stack, .Vector, javax.xml.XMLConstants, org.apache.xerces.impl.Constants, .RevalidationHandler, .XMLEntityManager, .XMLErrorReporter, org.apache.xerces.impl.dv.DatatypeException, .InvalidDatatypeValueException, .ValidatedInfo, .XSSimpleType, org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl, org.apache.xerces.impl.validation.ConfigurableValidationState, .ValidationManager, .ValidationState, org.apache.xerces.impl.xs.identity.Field, .FieldActivator, .IdentityConstraint, .KeyRef, .Selector, .UniqueOrKey, .ValueStore, .XPathMatcher, org.apache.xerces.impl.xs.models.CMBuilder, .CMNodeFactory, .XSCMValidator, org.apache.xerces.impl.xs.util.XS10TypeHelper, org.apache.xerces.util.AugmentationsImpl, .IntStack, .SymbolTable, .XMLAttributesImpl, .XMLChar, .XMLSymbols, .URI.MalformedURIException, org.apache.xerces.xni.Augmentations, .NamespaceContext, .QName, .XMLAttributes, .XMLDocumentHandler, .XMLLocator, .XMLResourceIdentifier, .XMLString, .XNIException, org.apache.xerces.xni.grammars.XMLGrammarDescription, .XMLGrammarPool, org.apache.xerces.xni.parser.XMLComponent, .XMLComponentManager, .XMLConfigurationException, .XMLDocumentFilter, .XMLDocumentSource, .XMLEntityResolver, .XMLInputSource, org.apache.xerces.xs.AttributePSVI, .ElementPSVI, .ShortList, .StringList, .XSConstants, .XSObjectList, .XSTypeDefinition

The XML Schema 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.

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

Authors
Sandy Gao IBM, Elena Litani IBM, Andy Clark IBM, Neeraj Bajaj, Sun Microsystems, inc.
Version
$Id: XMLSchemaValidator.java 1894472 2021-10-22 10:17:43Z mukulg $

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
XMLSchemaValidator.KeyRefValueStore

Key reference value store.

protected class
protected static class
protected static class
XMLSchemaValidator.ShortVector

A simple vector for shorts.

protected class
protected abstract class
XMLSchemaValidator.ValueStoreBase

Value store implementation base class.

protected class
protected static class
XMLSchemaValidator.XPathMatcherStack

Stack of XPath matchers for identity constraints.

protected class
XMLSchemaValidator.XSIErrorReporter

A wrapper of the standard error reporter.

Field Summary

Modifier and TypeField and Description
protected static final String
ALLOW_JAVA_ENCODINGS

Feature identifier: whether to recognize java encoding names

private static final int
protected static final String
CONTINUE_AFTER_FATAL_ERROR

Feature identifier: whether to continue parsing a schema after a fatal error is encountered

private static final boolean
private static final boolean
protected static final String
DYNAMIC_VALIDATION

Feature identifier: dynamic validation.

private static final Hashtable<K, V>
protected static final String
public static final String
ENTITY_RESOLVER

Property identifier: entity resolver.

public static final String
ERROR_REPORTER

Property identifier: error reporter.

private boolean
fAppendBuffer

Whether need to append characters to fBuffer

protected final AugmentationsImpl
protected boolean
private final StringBuffer
fBuffer

Temporary string buffers.

private final CMBuilder
fCMBuilder

used to build content models

private XSCMValidator[]
fCMStack

Content model stack.

private int[][]
fCMStateStack

stack to hold content model states

private int[]
fCurrCMState

the current state of the current content model

private XSCMValidator
fCurrentCM

Current content model.

private XSElementDecl
fCurrentElemDecl

Current element declaration.

protected ElementPSVImpl
fCurrentPSVI

current PSVI element info

private XSTypeDefinition
fCurrentType

Current type.

protected XMLString
protected XMLDocumentHandler
fDocumentHandler

Document handler.

protected XMLDocumentSource
protected boolean
protected boolean
private static final Boolean[]
FEATURE_DEFAULTS

Feature defaults.

private XSElementDecl[]
fElemDeclStack

Element decl stack.

private int
fElementDepth

Element depth: -2: validator not in pipeline; >= -1 current depth.

private final XMLString
protected boolean
protected XMLEntityResolver
fEntityResolver

Entity resolver

protected final Hashtable<K, V>
protected String
protected String
private boolean
protected boolean
private final XSGrammarBucket
fGrammarBucket

Schema grammar resolver.

protected XMLGrammarPool
private boolean
protected boolean
private int
protected boolean
protected Object
protected final Hashtable<K, V>
private XMLLocator
fLocator

While parsing a document, keep the location of the document.

protected XMLSchemaValidator.XPathMatcherStack
fMatcherStack

Stack of active XPath matchers for identity constraints.

protected boolean
private int
fNFullValidationDepth

anything above this level has validation_attempted != full

private boolean
fNil

nil value of the current element

private boolean[]
fNilStack

nil value stack

private int
fNNoneValidationDepth

anything above this level has validation_attempted != none

protected boolean
private final XMLString
private XSNotationDecl
fNotation

notation value of the current element

private XSNotationDecl[]
fNotationStack

notation stack

private final XSSimpleType
fQNameDV

the DV usd to convert xsi:type to a QName

private XSElementDecl
private QName
fRootElementDeclQName

value of the "root-element-declaration" property.

private XSTypeDefinition
private QName
fRootTypeQName

value of the "root-type-definition" property.

private boolean
fSawCharacters

Did we see non-whitespace character data?

private boolean
fSawText

Did we see any character data?

private boolean[]
fSawTextStack

stack to record if we saw character data

protected boolean
protected boolean
private final XMLSchemaLoader
private String
fSchemaType

Schema type: None, DTD, Schema

private int
fSkipValidationDepth

Skip validation: anything below this level should be skipped

private ValidationState
private ValidationState
private boolean
fStrictAssess

whether the curret element is strictly assessed

private boolean[]
fStrictAssessStack

strict assess stack

private boolean[]
fStringContent

Stack to record if we saw character data outside of element content

private boolean
fSubElement

Seen sub elements.

private boolean[]
fSubElementStack

Seen sub elements stack.

private final SubstitutionGroupHandler
protected SymbolTable
fSymbolTable

Symbol table.

private final QName
fTempQName

temporary qname

private boolean
private XSTypeDefinition[]
fTypeStack

type stack.

private boolean
protected final ArrayList<E>
protected boolean
private ValidatedInfo
fValidatedInfo

temporary validated info

protected ValidationManager
private String
fValidationRoot

String representation of the validation root.

protected ConfigurableValidationState
protected XMLSchemaValidator.ValueStoreCache
fValueStoreCache

Cache of value stores for identity constraint fields.

private short
protected final XSDDescription
fXSDDescription

Schema Grammar Description passed, to give a chance to application to supply the Grammar

protected final XMLSchemaValidator.XSIErrorReporter
fXSIErrorReporter

Error reporter.

protected static final String
GENERATE_SYNTHETIC_ANNOTATIONS

Feature: generate synthetic annotations

protected static final String
HONOUR_ALL_SCHEMALOCATIONS

Feature identifier: honour all schemaLocations

protected static final int
protected static final String
ID_IDREF_CHECKING

Feature identifier: whether to ignore ID/IDREF errors

protected static final String
IDENTITY_CONSTRAINT_CHECKING

Feature identifier: whether to ignore identity constraint errors

protected static final String
IGNORE_XSI_TYPE

Feature identifier: whether to ignore xsi:type attributes until a global element declaration is encountered

pack-priv static final int
pack-priv static final int
protected static final String
JAXP_SCHEMA_LANGUAGE

Property identifier: JAXP schema language.

protected static final String
JAXP_SCHEMA_SOURCE

Property identifier: JAXP schema source.

protected static final String
NAMESPACE_GROWTH

Feature identifier: namespace growth

private final CMNodeFactory
protected static final String
NORMALIZE_DATA

Feature identifier: expose schema normalized value

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
ROOT_ELEMENT_DECL

Property identifier: root element declaration.

protected static final String
ROOT_TYPE_DEF

Property identifier: root type definition.

protected static final String
SCHEMA_AUGMENT_PSVI

Feature identifier: augment PSVI

protected static final String
SCHEMA_DV_FACTORY

Property identifier: Schema DV Factory

protected static final String
SCHEMA_ELEMENT_DEFAULT

Feature identifier: send element default value via characters()

protected static final String
SCHEMA_FULL_CHECKING

Feature identifier: schema full checking

protected static final String
SCHEMA_LOCATION

Property identifier: schema location.

protected static final String
SCHEMA_NONS_LOCATION

Property identifier: no namespace schema location.

protected static final String
SCHEMA_VALIDATION

Feature identifier: validation.

protected static final String
STANDARD_URI_CONFORMANT_FEATURE

Feature identifier: standard uri conformant feature.

public static final String
SYMBOL_TABLE

Property identifier: symbol table.

protected static final String
TOLERATE_DUPLICATES

Feature identifier: tolerate duplicates

protected static final String
UNPARSED_ENTITY_CHECKING

Feature identifier: whether to ignore unparsed entity errors

protected static final String
USE_GRAMMAR_POOL_ONLY

Feature identifier: use grammar pool only

protected static final String
VALIDATE_ANNOTATIONS

Feature identifier: validate annotations.

protected static final String
VALIDATION

Feature identifier: validation.

protected static final String
public static final String
XMLGRAMMAR_POOL

Property identifier: grammar pool.

pack-priv static final XSAttributeDecl
pack-priv static final XSAttributeDecl
pack-priv static final XSAttributeDecl
pack-priv static final XSAttributeDecl

Constructor Summary

AccessConstructor and Description
public
XMLSchemaValidator()

Default constructor.

Method Summary

Modifier and TypeMethod and Description
public XPathMatcher
activateField(Field
The field to activate.
field
,
int
the 0-indexed depth in the instance document at which the Selector began to match.
initialDepth
)

Implements org.apache.xerces.impl.xs.identity.FieldActivator.activateField.

Request to activate the specified field.
private void
pack-priv void
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.
pack-priv void
checkElementMatchesRootElementDecl(final XSElementDecl rootElementDecl, final QName element)

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
pack-priv Object
pack-priv Object
elementLocallyValidType(QName element, Object textContent)

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.
pack-priv final Augmentations
endElementPSVI(boolean root, SchemaGrammar[] grammars, Augmentations augs)

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.
public void
endValueScopeFor(IdentityConstraint
The identity constraint.
identityConstraint
,
int
the 0-indexed depth where the Selector began to match.
initialDepth
)

Implements org.apache.xerces.impl.xs.identity.FieldActivator.endValueScopeFor.

Ends the value scope for the specified identity constraint.
pack-priv void
ensureStackCapacity()

ensure element stack capacity

private String
expectedStr(Vector<E> expected)

pack-priv SchemaGrammar
findSchemaGrammar(short contextType, String namespace, QName enclosingElement, QName triggeringComponent, XMLAttributes attributes)

pack-priv XSTypeDefinition
getAndCheckXsiType(QName element, String xsiType, XMLAttributes attributes)

public XMLDocumentHandler
public XMLDocumentSource
pack-priv Augmentations
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.
public XSElementDecl
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.
pack-priv boolean
getXsiNil(QName element, String xsiNil)

pack-priv XMLString
pack-priv void
pack-priv Augmentations
handleEndElement(QName element, Augmentations augs)

Handle end element.

pack-priv void
pack-priv void
pack-priv Augmentations
handleStartElement(QName element, XMLAttributes attributes, Augmentations augs)

Handle element.

private boolean
hasSchemaComponent(SchemaGrammar grammar, short contextType, QName triggeringComponent)

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.
private void
normalizeWhitespace(XMLString
The string to normalize.
value
,
boolean
replace or collapse
collapse
)

Normalize whitespace in an XMLString according to the rules defined in XML Schema specifications.

private void
normalizeWhitespace(String value, boolean collapse)

pack-priv void
pack-priv void
processElementContent(QName element)

If there is not text content, and there is a {value constraint} on the corresponding element decl, then return an XMLString representing the default value.

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.
pack-priv void
processOneAttribute(QName element, XMLAttributes attributes, int index, XSAttributeDecl currDecl, XSAttributeUseImpl currUse, AttributePSVImpl attrPSVI)

pack-priv void
processRootElementDeclQName(final QName rootElementDeclQName, final QName element)

pack-priv void
processRootTypeQName(final QName rootTypeQName)

pack-priv void
reportSchemaError(String key, Object[] arguments)

public void
reset(XMLComponentManager
The component manager.
componentManager
)

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

Resets the component.
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.
private void
private void
setLocationHints(XSDDescription desc, String[] locations, StringList docLocations)

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.
public void
startValueScopeFor(IdentityConstraint
The identity constraint.
identityConstraint
,
int
the depth at which the selector began matching
initialDepth
)

Implements org.apache.xerces.impl.xs.identity.FieldActivator.startValueScopeFor.

Start the value scope for the specified identity constraint.
pack-priv void
storeLocations(String sLocation, String nsLocation)

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