Top Description Inners Fields Constructors Methods
org.apache.xerces.jaxp.validation

pack-priv final Class DOMValidatorHelper

extends Object
implements ValidatorHelper, EntityState
Class Inheritance
All Implemented Interfaces
org.apache.xerces.impl.validation.EntityState, org.apache.xerces.jaxp.validation.ValidatorHelper
Imports
java.io.IOException, java.util.Enumeration, javax.xml.parsers.DocumentBuilder, .DocumentBuilderFactory, .ParserConfigurationException, javax.xml.transform.Result, .Source, javax.xml.transform.dom.DOMResult, .DOMSource, org.apache.xerces.dom.NodeImpl, org.apache.xerces.impl.Constants, .XMLErrorReporter, org.apache.xerces.impl.validation.EntityState, .ValidationManager, org.apache.xerces.impl.xs.XMLSchemaValidator, org.apache.xerces.impl.xs.util.SimpleLocator, org.apache.xerces.util.NamespaceSupport, .SymbolTable, .XMLAttributesImpl, .XMLSymbols, org.apache.xerces.xni.NamespaceContext, .QName, .XMLString, .XNIException, org.apache.xerces.xni.parser.XMLParseException, org.w3c.dom.Attr, .CDATASection, .Comment, .Document, .DocumentType, .Entity, .NamedNodeMap, .Node, .ProcessingInstruction, .Text, org.xml.sax.SAXException

A validator helper for DOMSources.

Author
Michael Glavassevich, IBM
Version
$Id: DOMValidatorHelper.java 713638 2008-11-13 04:42:18Z mrglavas $

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
DOMValidatorHelper.DOMNamespaceContext

NamespaceContext for the DOMSource, includes context for ancestor nodes.

Field Summary

Modifier and TypeField and Description
private static final int
CHUNK_MASK

Chunk mask (CHUNK_SIZE - 1).

private static final int
CHUNK_SIZE

Chunk size (1024).

private static final String
ERROR_REPORTER

Property identifier: error reporter.

pack-priv final QName
pack-priv final XMLAttributesImpl
private final char[]
fCharBuffer

Array for holding character data.

private final XMLSchemaValidatorComponentManager
fComponentManager

Component manager.

private Node
fCurrentElement

Current element.

private final DOMValidatorHelper.DOMNamespaceContext
fDOMNamespaceContext

The namespace context of the DOMSource, includes context from ancestor nodes.

private final DOMResultAugmentor
fDOMResultAugmentor

DOM result augmentor.

private final DOMResultBuilder
fDOMResultBuilder

DOM result builder.

private DOMDocumentHandler
fDOMValidatorHandler

DOM document handler.

pack-priv final QName
fElementQName

Fields for start element, end element and characters.

private NamedNodeMap
fEntities

Map for tracking unparsed entities.

private final XMLErrorReporter
fErrorReporter

Error reporter.

private final NamespaceSupport
fNamespaceContext

The namespace context of this document: stores namespaces in scope.

private Node
fRoot

Root node.

private final XMLSchemaValidator
fSchemaValidator

Schema validator.

private final SymbolTable
fSymbolTable

Symbol table

pack-priv final XMLString
private final ValidationManager
fValidationManager

Validation manager.

private final SimpleLocator
fXMLLocator

Simple Locator.

private static final String
NAMESPACE_CONTEXT

Property identifier: namespace context.

private static final String
SCHEMA_VALIDATOR

Property identifier: XML Schema validator.

private static final String
SYMBOL_TABLE

Property identifier: symbol table.

private static final String
VALIDATION_MANAGER

Property identifier: validation manager.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
beginNode(Node node)

Do processing for the start of a node.

private void
fillQName(QName toFill, Node node)

private void
finishNode(Node node)

Do processing for the end of a node.

pack-priv Node
getCurrentElement()

Returns the current element node.

public boolean
isEntityDeclared(String name)

Implements org.apache.xerces.impl.validation.EntityState.isEntityDeclared.

Query method to check if entity with this name was declared.
public boolean
isEntityUnparsed(String name)

Implements org.apache.xerces.impl.validation.EntityState.isEntityUnparsed.

Query method to check if entity is unparsed.
private void
private void
private void
setupDOMResultHandler(DOMSource source, DOMResult result)

Sets up handler for DOMResult.

private void
setupEntityMap(Document doc)

Extracts NamedNodeMap of entities.

private boolean
useIsSameNode(Node node)

Use isSameNode() for testing node identity if the DOM implementation supports DOM Level 3 core and it isn't the Xerces implementation.

public void
private void
validate(Node node)

Traverse the DOM and fire events to the schema validator.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CHUNK_MASKback to summary
private static final int CHUNK_MASK

Chunk mask (CHUNK_SIZE - 1).

CHUNK_SIZEback to summary
private static final int CHUNK_SIZE

Chunk size (1024).

ERROR_REPORTERback to summary
private static final String ERROR_REPORTER

Property identifier: error reporter.

fAttributeQNameback to summary
pack-priv final QName fAttributeQName
fAttributesback to summary
pack-priv final XMLAttributesImpl fAttributes
fCharBufferback to summary
private final char[] fCharBuffer

Array for holding character data.

fComponentManagerback to summary
private final XMLSchemaValidatorComponentManager fComponentManager

Component manager.

fCurrentElementback to summary
private Node fCurrentElement

Current element.

fDOMNamespaceContextback to summary
private final DOMValidatorHelper.DOMNamespaceContext fDOMNamespaceContext

The namespace context of the DOMSource, includes context from ancestor nodes.

fDOMResultAugmentorback to summary
private final DOMResultAugmentor fDOMResultAugmentor

DOM result augmentor.

fDOMResultBuilderback to summary
private final DOMResultBuilder fDOMResultBuilder

DOM result builder.

fDOMValidatorHandlerback to summary
private DOMDocumentHandler fDOMValidatorHandler

DOM document handler.

fElementQNameback to summary
pack-priv final QName fElementQName

Fields for start element, end element and characters.

fEntitiesback to summary
private NamedNodeMap fEntities

Map for tracking unparsed entities.

fErrorReporterback to summary
private final XMLErrorReporter fErrorReporter

Error reporter.

fNamespaceContextback to summary
private final NamespaceSupport fNamespaceContext

The namespace context of this document: stores namespaces in scope.

fRootback to summary
private Node fRoot

Root node.

fSchemaValidatorback to summary
private final XMLSchemaValidator fSchemaValidator

Schema validator.

fSymbolTableback to summary
private final SymbolTable fSymbolTable

Symbol table

fTempStringback to summary
pack-priv final XMLString fTempString
fValidationManagerback to summary
private final ValidationManager fValidationManager

Validation manager.

fXMLLocatorback to summary
private final SimpleLocator fXMLLocator

Simple Locator.

NAMESPACE_CONTEXTback to summary
private static final String NAMESPACE_CONTEXT

Property identifier: namespace context.

SCHEMA_VALIDATORback to summary
private static final String SCHEMA_VALIDATOR

Property identifier: XML Schema validator.

SYMBOL_TABLEback to summary
private static final String SYMBOL_TABLE

Property identifier: symbol table.

VALIDATION_MANAGERback to summary
private static final String VALIDATION_MANAGER

Property identifier: validation manager.

Constructor Detail

DOMValidatorHelperback to summary
public DOMValidatorHelper(XMLSchemaValidatorComponentManager componentManager)

Method Detail

beginNodeback to summary
private void beginNode(Node node)

Do processing for the start of a node.

fillQNameback to summary
private void fillQName(QName toFill, Node node)
finishNodeback to summary
private void finishNode(Node node)

Do processing for the end of a node.

getCurrentElementback to summary
pack-priv Node getCurrentElement()

Returns the current element node.

isEntityDeclaredback to summary
public boolean isEntityDeclared(String name)

Implements org.apache.xerces.impl.validation.EntityState.isEntityDeclared.

Doc from org.apache.xerces.impl.validation.EntityState.isEntityDeclared.

Query method to check if entity with this name was declared.

Returns:boolean

true if name is a declared entity

isEntityUnparsedback to summary
public boolean isEntityUnparsed(String name)

Implements org.apache.xerces.impl.validation.EntityState.isEntityUnparsed.

Doc from org.apache.xerces.impl.validation.EntityState.isEntityUnparsed.

Query method to check if entity is unparsed.

Returns:boolean

true if name is an unparsed entity

processAttributesback to summary
private void processAttributes(NamedNodeMap attrMap)
sendCharactersToValidatorback to summary
private void sendCharactersToValidator(String str)
setupDOMResultHandlerback to summary
private void setupDOMResultHandler(DOMSource source, DOMResult result) throws SAXException

Sets up handler for DOMResult.

setupEntityMapback to summary
private void setupEntityMap(Document doc)

Extracts NamedNodeMap of entities. We need this to validate elements and attributes of type xs:ENTITY, xs:ENTITIES or types dervied from them.

useIsSameNodeback to summary
private boolean useIsSameNode(Node node)

Use isSameNode() for testing node identity if the DOM implementation supports DOM Level 3 core and it isn't the Xerces implementation.

validateback to summary
public void validate(Source source, Result result) throws SAXException, IOException

Implements org.apache.xerces.jaxp.validation.ValidatorHelper.validate.

validateback to summary
private void validate(Node node)

Traverse the DOM and fire events to the schema validator.

org.apache.xerces.jaxp.validation back to summary

pack-priv final Class DOMValidatorHelper.DOMNamespaceContext

extends Object
implements NamespaceContext
Class Inheritance
  • java.lang.Object
  • org.apache.xerces.jaxp.validation.DOMValidatorHelper.DOMNamespaceContext
All Implemented Interfaces
org.apache.xerces.xni.NamespaceContext

NamespaceContext for the DOMSource, includes context for ancestor nodes.

Field Summary

Modifier and TypeField and Description
protected boolean
fDOMContextBuilt

Flag indicating whether the namespace context has been from the root node's ancestors.

protected String[]
fNamespace

Namespace binding information.

protected int
fNamespaceSize

The size of the namespace information array.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
declarePrefix(String
The prefix to declare, or null for the empty string.
prefix
,
String
The Namespace URI to associate with the prefix.
uri
)

Implements org.apache.xerces.xni.NamespaceContext.declarePrefix.

Declare a Namespace prefix.
private void
private void
public Enumeration<E>
getAllPrefixes()

Implements org.apache.xerces.xni.NamespaceContext.getAllPrefixes.

Return an enumeration of all prefixes whose declarations are active in the current context.
public String
getDeclaredPrefixAt(int index)

Implements org.apache.xerces.xni.NamespaceContext.getDeclaredPrefixAt.

Returns the prefix at the specified index in the current context.
public int
getDeclaredPrefixCount()

Implements org.apache.xerces.xni.NamespaceContext.getDeclaredPrefixCount.

Return a count of locally declared prefixes, including the default prefix if bound.
public String
getPrefix(String
The namespace URI to look up.
uri
)

Implements org.apache.xerces.xni.NamespaceContext.getPrefix.

Look up a namespace URI and get one of the mapped prefix.
public String
getURI(String
The prefix to look up.
prefix
)

Implements org.apache.xerces.xni.NamespaceContext.getURI.

Look up a prefix and get the currently-mapped Namespace URI.
private String
getURI0(String prefix)

public void
popContext()

Implements org.apache.xerces.xni.NamespaceContext.popContext.

Revert to the previous Namespace context.
public void
pushContext()

Implements org.apache.xerces.xni.NamespaceContext.pushContext.

Start a new Namespace context.
public void
reset()

Implements org.apache.xerces.xni.NamespaceContext.reset.

Reset this Namespace support object for reuse.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fDOMContextBuiltback to summary
protected boolean fDOMContextBuilt

Flag indicating whether the namespace context has been from the root node's ancestors.

fNamespaceback to summary
protected String[] fNamespace

Namespace binding information. This array is composed of a series of tuples containing the namespace binding information: <prefix, uri>.

fNamespaceSizeback to summary
protected int fNamespaceSize

The size of the namespace information array.

Constructor Detail

DOMNamespaceContextback to summary
pack-priv DOMNamespaceContext()

Method Detail

declarePrefixback to summary
public boolean declarePrefix(String prefix, String uri)

Implements org.apache.xerces.xni.NamespaceContext.declarePrefix.

Doc from org.apache.xerces.xni.NamespaceContext.declarePrefix.

Declare a Namespace prefix.

This method declares a prefix in the current Namespace context; the prefix will remain in force until this context is popped, unless it is shadowed in a descendant context.

Note that to declare a default Namespace, use the empty string. The prefixes "xml" and "xmlns" can't be rebound.

Note that you must not declare a prefix after you've pushed and popped another Namespace.

Parameters
prefix:String

The prefix to declare, or null for the empty string.

uri:String

The Namespace URI to associate with the prefix.

Returns:boolean

true if the prefix was legal, false otherwise

declarePrefix0back to summary
private void declarePrefix0(String prefix, String uri)
fillNamespaceContextback to summary
private void fillNamespaceContext()
getAllPrefixesback to summary
public Enumeration<E> getAllPrefixes()

Implements org.apache.xerces.xni.NamespaceContext.getAllPrefixes.

Doc from org.apache.xerces.xni.NamespaceContext.getAllPrefixes.

Return an enumeration of all prefixes whose declarations are active in the current context. This includes declarations from parent contexts that have not been overridden.

Returns:Enumeration<E>

Enumeration

getDeclaredPrefixAtback to summary
public String getDeclaredPrefixAt(int index)

Implements org.apache.xerces.xni.NamespaceContext.getDeclaredPrefixAt.

Doc from org.apache.xerces.xni.NamespaceContext.getDeclaredPrefixAt.

Returns the prefix at the specified index in the current context.

getDeclaredPrefixCountback to summary
public int getDeclaredPrefixCount()

Implements org.apache.xerces.xni.NamespaceContext.getDeclaredPrefixCount.

Doc from org.apache.xerces.xni.NamespaceContext.getDeclaredPrefixCount.

Return a count of locally declared prefixes, including the default prefix if bound.

getPrefixback to summary
public String getPrefix(String uri)

Implements org.apache.xerces.xni.NamespaceContext.getPrefix.

Doc from org.apache.xerces.xni.NamespaceContext.getPrefix.

Look up a namespace URI and get one of the mapped prefix.

This method looks up the namespace URI in the current context. If more than one prefix is currently mapped to the same URI, this method will make an arbitrary selection If no mapping is found, this methods will continue lookup in the parent context(s).

Parameters
uri:String

The namespace URI to look up.

Returns:String

One of the associated prefixes, or null if the uri does not map to any prefix.

getURIback to summary
public String getURI(String prefix)

Implements org.apache.xerces.xni.NamespaceContext.getURI.

Doc from org.apache.xerces.xni.NamespaceContext.getURI.

Look up a prefix and get the currently-mapped Namespace URI.

This method looks up the prefix in the current context. If no mapping is found, this methods will continue lookup in the parent context(s). Use the empty string ("") for the default Namespace.

Parameters
prefix:String

The prefix to look up.

Returns:String

The associated Namespace URI, or null if the prefix is undeclared in this context.

getURI0back to summary
private String getURI0(String prefix)
popContextback to summary
public void popContext()

Implements org.apache.xerces.xni.NamespaceContext.popContext.

Doc from org.apache.xerces.xni.NamespaceContext.popContext.

Revert to the previous Namespace context.

The context should be popped at the end of each XML element. After popping the context, all Namespace prefix mappings that were previously in force are restored.

Users must not attempt to declare additional Namespace prefixes after popping a context, unless you push another context first.

pushContextback to summary
public void pushContext()

Implements org.apache.xerces.xni.NamespaceContext.pushContext.

Doc from org.apache.xerces.xni.NamespaceContext.pushContext.

Start a new Namespace context.

A new context should be pushed at the beginning of each XML element: the new context will automatically inherit the declarations of its parent context, but it will also keep track of which declarations were made within this context.

resetback to summary
public void reset()

Implements org.apache.xerces.xni.NamespaceContext.reset.

Doc from org.apache.xerces.xni.NamespaceContext.reset.

Reset this Namespace support object for reuse.

It is necessary to invoke this method before reusing the Namespace support object for a new session.

Note that implementations of this method need to ensure that the declaration of the prefixes "xmlns" and "xml" are available.