Interface Validator
-
- All Known Implementing Classes:
CombineValidator
public interface Validator
Validates an XML document with respect to a schema. The schema is determined when theValidator
is created and cannot be changed. The XML document is provided to theValidator
by calling methods of theContentHandler
object returned bygetContentHandler
; the methods must be called in the sequence specified by theContentHandler
interface. If thegetDTDHandler
method returns a non-null object, then method calls must be made on it reporting DTD information.Any errors will be reported to the
ErrorHandler
specified when theValidator
was created. If, after the call to theendDocument
method, no errors have been reported, then the XML document is valid.A single
Validator
object is not safe for concurrent access from multiple threads. A singleValidatorHandler
can be used to validate only a single document at a time.After completing validation of an XML document (i.e. after calling the
endDocument
on theContentHandler
),reset
can be called to allow validation of another document. Thereset
method may create newContentHandler
andDTDHandler
objects or may simply reinitialize the state of the existing objects. Therefore,getContentHandler
andgetDTDHandler
must be called afterreset
to retrieve the objects to which the XML document to be validated must be provided.- Author:
- James Clark
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description org.xml.sax.ContentHandler
getContentHandler()
Returns the ContentHandler that will receive the XML document.org.xml.sax.DTDHandler
getDTDHandler()
Returns a DTDHandler.void
reset()
Cleans up after validating a document.
-
-
-
Method Detail
-
getContentHandler
org.xml.sax.ContentHandler getContentHandler()
Returns the ContentHandler that will receive the XML document. Information about the XML document to be validated must be reported by calling methods on the returned ContentHandler. When validation of an XML document has been completed (either endDocument() has been called or validation has been abandoned prematurely), reset() must be called. If no calls are made on the ContentHandler, then reset() need not be called. Implementations should allocate resources that require cleanup (e.g. threads, open files) lazily, typically in startDocument(). This method does not change the state of the Validator: the same object will always be returned unlessreset
is called.- Returns:
- a ContentHandler, never
null
- See Also:
reset()
-
getDTDHandler
org.xml.sax.DTDHandler getDTDHandler()
Returns a DTDHandler. Information about the DTD must be reported by calling methods on the returned object, unlessnull
is returned. The same object will always be returned unlessreset
is called: this method does not change the state of the Validator.- Returns:
- a DTDHandler, maybe
null
if DTD information is not significant to theValidator
-
reset
void reset()
Cleans up after validating a document. After completing validation of a document,reset
must be called. After calling reset(), another document may be validated. Calling this method may create new ContentHandler and DTDHandler objects or may simply reinitialize the state of the existing objects.
-
-