|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.xml.validation.ValidatorHandler com.saxonica.jaxp.ValidatorHandlerImpl
public class ValidatorHandlerImpl
The is the Saxon implementation of the JAXP 1.3 ValidatorHandler interface. It is a SAX ContentHandler that accepts events from an XML parser (or elsewhere), validates them, reports any errors, and passes the events on to another ContentHandler. The events that are passed on will be augmented with extra elements and attributes that expand default values defined in the schema. In addition, the receiving ContentHandler has access to a TypeInfoProvider that gives information about the type of the current element or attribute event.
A ValidatorHandler is the front end to a rather complex pipeline. The ValidatorHandler is the first stage in the pipeline: it receives events from a SAX parser or other source of SAX events. The next stage is a ReceivingContentHandler, which translates SAX events into Receiver events. This is followed by a number of Receivers to do the validation (actually a stack of Receivers, since a new ComplexContentValidator is added each time a new element starts). The last Receiver is the finalProxy: this translates Receiver events back into SAX2 events, for delivery to the user's ContentHandler.
The user's ContentHandler has access to a TypeInfoProvider that gives information about the types of elements and attributes. This information is passed down the Receiver pipeline in the form of typeCodes associated with element and attribute events. The TypeInfoProvider is part of the finalProxy, which saves the type information locally and returns it to the user's ContentHandler on request. The TypeInfo objects supplied by the TypeInfoProvider are in fact the schema components representing the type, as a SchemaType object.
Constructor Summary | |
---|---|
ValidatorHandlerImpl()
|
Method Summary | |
---|---|
void |
characters(char[] ch,
int start,
int length)
Receive notification of character data. |
void |
comment(char[] ch,
int start,
int length)
Report an XML comment anywhere in the document. |
void |
endCDATA()
Report the end of a CDATA section. |
void |
endDocument()
Receive notification of the end of a document. |
void |
endDTD()
Report the end of DTD declarations. |
void |
endElement(String uri,
String localName,
String qName)
Receive notification of the end of an element. |
void |
endEntity(String name)
Report the end of an entity. |
void |
endPrefixMapping(String prefix)
End the scope of a prefix-URI mapping. |
EnterpriseConfiguration |
getConfiguration()
Get the Configuration object |
ContentHandler |
getContentHandler()
Gets the ContentHandler which receives the
augmented validation result. |
ErrorHandler |
getErrorHandler()
Gets the current ErrorHandler |
Object |
getProperty(String name)
Look up the value of a property. |
LSResourceResolver |
getResourceResolver()
Gets the current LSResourceResolver |
TypeInfoProvider |
getTypeInfoProvider()
Obtains the TypeInfoProvider implementation of this
ValidatorHandler . |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Receive notification of ignorable whitespace in element content. |
void |
notationDecl(String name,
String publicId,
String systemId)
Receive notification of a notation declaration event. |
void |
processingInstruction(String target,
String data)
Receive notification of a processing instruction. |
void |
setContentHandler(ContentHandler receiver)
Sets the ContentHandler which receives
the augmented validation result. |
void |
setDocumentLocator(Locator locator)
Receive an object for locating the origin of SAX document events. |
void |
setErrorHandler(ErrorHandler errorHandler)
Sets the ErrorHandler to receive errors encountered
during the validation. |
void |
setFinalProxy(TypedContentHandler proxy)
Set the TypedContentHandler that acts as the final stage in this pipeline, receiving typed events from the validator stack |
void |
setPipelineConfiguration(PipelineConfiguration pipe)
Set the pipeline configuration used by this validator handler |
void |
setProperty(String name,
Object object)
Set the value of a property. |
void |
setReceivingContentHandler(ReceivingContentHandler rch)
Get the ReceivingContentHandler that receives the SAX events at the start of this pipeline |
void |
setResourceResolver(LSResourceResolver resourceResolver)
Sets the LSResourceResolver to customize
resource resolution while in a validation episode. |
void |
skippedEntity(String name)
Receive notification of a skipped entity. |
void |
startCDATA()
Report the start of a CDATA section. |
void |
startDocument()
Receive notification of the beginning of a document. |
void |
startDTD(String name,
String publicId,
String systemId)
Report the start of DTD declarations, if any. |
void |
startElement(String uri,
String localName,
String qName,
Attributes atts)
Receive notification of the beginning of an element. |
void |
startEntity(String name)
Report the beginning of some internal and external XML entities. |
void |
startPrefixMapping(String prefix,
String uri)
Begin the scope of a prefix-URI Namespace mapping. |
void |
unparsedEntityDecl(String name,
String publicId,
String systemId,
String notationName)
Receive notification of an unparsed entity declaration event. |
Methods inherited from class javax.xml.validation.ValidatorHandler |
---|
getFeature, setFeature |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ValidatorHandlerImpl()
Method Detail |
---|
public void setPipelineConfiguration(PipelineConfiguration pipe)
pipe
- the pipeline configurationpublic void setReceivingContentHandler(ReceivingContentHandler rch)
rch
- the ReceivingContentHandlerpublic void setFinalProxy(TypedContentHandler proxy)
proxy
- the TypedContentHandler at the end of the pipelinepublic void setContentHandler(ContentHandler receiver)
ContentHandler
which receives
the augmented validation result.
A ValidatorHandler
may buffer events to certain
extent, but to allow ValidatorHandler
to be used
by a parser, the following requirement has to be met.
ContentHandler.startElement(String, String, String, Attributes)
,
ContentHandler.endElement(String, String, String)
,
ContentHandler.startDocument()
, or
ContentHandler.endDocument()
are invoked on a ValidatorHandler
,
the same method on the user-specified ContentHandler
must be invoked for the same event before the callback
returns.
The Saxon implementation does not meet this requirement. StartElement events are buffered until the first thing following the attributes is encountered.
setContentHandler
in class ValidatorHandler
receiver
- A ContentHandler
or a null value.public ContentHandler getContentHandler()
ContentHandler
which receives the
augmented validation result.
getContentHandler
in class ValidatorHandler
getContentHandler()
method, or null
if that method has never been called since this ValidatorHandler
has created.setContentHandler(org.xml.sax.ContentHandler)
public void setErrorHandler(ErrorHandler errorHandler)
ErrorHandler
to receive errors encountered
during the validation.
setErrorHandler
in class ValidatorHandler
errorHandler
- A new error handler to be set. This parameter can be null.public ErrorHandler getErrorHandler()
ErrorHandler
getErrorHandler
in class ValidatorHandler
setErrorHandler(org.xml.sax.ErrorHandler)
method, or null
if that method has never been calledsetErrorHandler(org.xml.sax.ErrorHandler)
public void setResourceResolver(LSResourceResolver resourceResolver)
LSResourceResolver
to customize
resource resolution while in a validation episode.
setResourceResolver
in class ValidatorHandler
resourceResolver
- A new resource resolver to be set. This parameter can be null.public LSResourceResolver getResourceResolver()
LSResourceResolver
getResourceResolver
in class ValidatorHandler
setResourceResolver(org.w3c.dom.ls.LSResourceResolver)
method, or null
if that method has never been calledpublic TypeInfoProvider getTypeInfoProvider()
TypeInfoProvider
implementation of this
ValidatorHandler
.
The obtained TypeInfoProvider
can be queried during a parse
to access the type information determined by the validator.
getTypeInfoProvider
in class ValidatorHandler
TypeInfoProvider
.public void setDocumentLocator(Locator locator)
setDocumentLocator
in interface ContentHandler
locator
- an object that can return the location of
any SAX document eventLocator
public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException
The property name is any fully-qualified URI. It is
possible for a ValidatorHandler
to recognize a property name but
temporarily be unable to return its value.
Some property values may be available only in specific
contexts, such as before, during, or after a validation.
Validator
s are not required to recognize any specific
property names.
In the Saxon implementation, the property names that are recognized are the same as the
attribute names recognised by a TransformerFactory
.
These are listed as constant fields
in the class FeatureKeys
getProperty
in class ValidatorHandler
name
- The property name, which is a non-null fully-qualified URI.
SAXNotRecognizedException
- If the property
value can't be assigned or retrieved.
SAXNotSupportedException
- When the
XMLReader recognizes the property name but
cannot determine its value at this time.
NullPointerException
- When the name parameter is null.setProperty(String, Object)
public void setProperty(String name, Object object) throws SAXNotRecognizedException, SAXNotSupportedException
The property name is any fully-qualified URI. It is
possible for a ValidatorHandler
to recognize a property name but
to be unable to change the current value.
Some property values may be immutable or mutable only
in specific contexts, such as before, during, or after
a validation.
In the Saxon implementation, the property names that are recognized are the same as the
attribute names recognised by a TransformerFactory
.
These are listed as constant fields
in the class FeatureKeys
setProperty
in class ValidatorHandler
name
- The property name, which is a non-null fully-qualified URI.object
- The requested value for the property.
SAXNotRecognizedException
- If the property
value can't be assigned or retrieved.
SAXNotSupportedException
- When the
Validator
recognizes the property name but
cannot set the requested value.
NullPointerException
- When the name parameter is null.public EnterpriseConfiguration getConfiguration()
public void startDocument() throws SAXException
The SAX parser will invoke this method only once, before any
other event callbacks (except for setDocumentLocator
).
startDocument
in interface ContentHandler
SAXException
- any SAX exception, possibly
wrapping another exceptionendDocument()
public void endDocument() throws SAXException
endDocument
in interface ContentHandler
SAXException
- any SAX exception, possibly
wrapping another exceptionpublic void startPrefixMapping(String prefix, String uri) throws SAXException
There should never be start/endPrefixMapping events for the "xml" prefix, since it is predeclared and immutable.
startPrefixMapping
in interface ContentHandler
prefix
- the Namespace prefix being declared.
An empty string is used for the default element namespace,
which has no prefix.uri
- the Namespace URI the prefix is mapped to
SAXException
- the client may throw
an exception during processingendPrefixMapping(java.lang.String)
,
startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
public void endPrefixMapping(String prefix) throws SAXException
endPrefixMapping
in interface ContentHandler
prefix
- the prefix that was being mapped.
This is the empty string when a default mapping scope ends.
SAXException
- the client may throw
an exception during processingpublic void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException
startElement
in interface ContentHandler
uri
- the Namespace URI, or the empty string if the
element has no Namespace URI or if Namespace
processing is not being performedlocalName
- the local name (without prefix), or the
empty string if Namespace processing is not being
performedqName
- the qualified name (with prefix), or the
empty string if qualified names are not availableatts
- the attributes attached to the element. If
there are no attributes, it shall be an empty
Attributes object. The value of this object after
startElement returns is undefined
SAXException
- any SAX exception, possibly
wrapping another exceptionpublic void endElement(String uri, String localName, String qName) throws SAXException
endElement
in interface ContentHandler
SAXException
public void characters(char[] ch, int start, int length) throws SAXException
characters
in interface ContentHandler
SAXException
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
ignorableWhitespace
in interface ContentHandler
SAXException
public void processingInstruction(String target, String data) throws SAXException
processingInstruction
in interface ContentHandler
SAXException
public void skippedEntity(String name) throws SAXException
skippedEntity
in interface ContentHandler
SAXException
public void startDTD(String name, String publicId, String systemId) throws SAXException
startDTD
in interface LexicalHandler
SAXException
public void endDTD() throws SAXException
endDTD
in interface LexicalHandler
SAXException
public void startEntity(String name) throws SAXException
startEntity
in interface LexicalHandler
SAXException
public void endEntity(String name) throws SAXException
endEntity
in interface LexicalHandler
SAXException
public void startCDATA() throws SAXException
startCDATA
in interface LexicalHandler
SAXException
public void endCDATA() throws SAXException
endCDATA
in interface LexicalHandler
SAXException
public void comment(char[] ch, int start, int length) throws SAXException
comment
in interface LexicalHandler
SAXException
public void notationDecl(String name, String publicId, String systemId) throws SAXException
notationDecl
in interface DTDHandler
SAXException
public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName) throws SAXException
unparsedEntityDecl
in interface DTDHandler
SAXException
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |