org.apache.xerces.framework
Interface XMLValidator

All Known Implementing Classes:
DTDValidator, XSchemaValidator

public interface XMLValidator

XMLValidator defines the interface that XMLDocumentScanner and XML EntityHandler have with an object that serves as a pluggable validator. This abstraction allows validators for XML grammar languages to be plugged in and queried for validity checks as the scanner processes a document. The document scanner and entity handler need to ask the validator object for this information because the validator object is responsible for reading the grammar specification file (which contains markup declarations and entity declarations)

Version:
 

Inner Class Summary
static interface XMLValidator.ContentSpec
          ContentSpec really exists to aid the parser classes in implementing access to the grammar
 
Method Summary
 boolean attributeSpecified(int elementType, XMLAttrList attrList, int attrName, Locator attrNameLocator, int attValue)
          add an attribute definition for an attribute name attrName to the element elementType.
 void characters(char[] chars, int offset, int length)
          a callback for character data - String object version
 void characters(int stringIndex)
          a callback for character data - string pool version
 int checkContent(int elementHandle, int childCount, int[] children)
          validate an element's content
 boolean endElement(int elementType)
          a callback for the end tag of an element
 boolean externalReferenceInContent(int entityIndex)
          return true if entityIndex's entity is external, and it satisfies the requirements for an external entity reference within content
 java.lang.String getContentSpecAsString(int elementIndex)
          return elementIndex's content spec as a string
 int getEntityValue(int entityIndex)
          return the replacement text for entityIndex
 int getParameterEntityValue(int peIndex)
          return the replacement text for a parameter entity
 java.lang.String getPublicIdOfEntity(int entityIndex)
          return the public identifer for entityIndex
 java.lang.String getPublicIdOfParameterEntity(int peIndex)
          return the public identifier for a parameter entity
 java.lang.String getSystemIdOfEntity(int entityIndex)
          return the system identifier for entityIndex
 java.lang.String getSystemIdOfParameterEntity(int peIndex)
          return the system identifier for a parameter entity
 void ignorableWhitespace(char[] chars, int offset, int length)
          a callback for ignorable whitespace - String object version
 void ignorableWhitespace(int stringIndex)
          a callback for ignorable whitespace - string pool version
 boolean isExternalEntity(int entityIndex)
          return true if entityIndex's entity is external
 boolean isExternalParameterEntity(int peIndex)
          return true if a parameter entity is external
 boolean isUnparsedEntity(int entityIndex)
          return true if entityIndex's entity is unparsed
 int lookupEntity(int entityName)
          return a handle to an entity.
 int lookupParameterEntity(int peName)
          return a handle to a parameter entity - this handle can then be passed to other XMLEntityHandler methods on XMLValidator
 void rootElementSpecified(int rootElementType)
          Check to see if the rootElement matches the root element specified by the DOCTYPE line.
 boolean startElement(int elementType, XMLAttrList attrList)
          a callback for the start tag of an element
 int valueOfReferenceInAttValue(int entityIndex)
          return the string pool index of an entity the entity must be allowed to appear in an attribute value
 

Method Detail

rootElementSpecified

public void rootElementSpecified(int rootElementType)
                          throws java.lang.Exception
Check to see if the rootElement matches the root element specified by the DOCTYPE line. Signal an error to the application if it does not.
Parameters:
rootElementType - StringPool handle for the rootElement
Throws:
java.lang.Exception -  

attributeSpecified

public boolean attributeSpecified(int elementType,
                                  XMLAttrList attrList,
                                  int attrName,
                                  Locator attrNameLocator,
                                  int attValue)
                           throws java.lang.Exception
add an attribute definition for an attribute name attrName to the element elementType.
Parameters:
elementType - the index of the element
attrList - the XMLAttrList to receive the new attribute
attrName - the string pool index of the attribute name
attrNameLocator - a SAX Locator (for error reporting)
attValue - the string pool index of the attribute value
Throws:
java.lang.Exception -  

startElement

public boolean startElement(int elementType,
                            XMLAttrList attrList)
                     throws java.lang.Exception
a callback for the start tag of an element
Parameters:
elementType - the index of the element
attrList - the XMLAttrList containing the attributes for the element
Returns:
true if processing element content //REVISIT
Throws:
java.lang.Exception -  

endElement

public boolean endElement(int elementType)
                   throws java.lang.Exception
a callback for the end tag of an element
Parameters:
elementType - the index of the element
Returns:
true if processing element content //REVISIT
Throws:
java.lang.Exception -  

characters

public void characters(char[] chars,
                       int offset,
                       int length)
                throws java.lang.Exception
a callback for character data - String object version
Parameters:
chars - array containing the characters that were scanned
offset - offset in chars of characters that were scanned
length - length of characters that were scanned
Throws:
java.lang.Exception -  

characters

public void characters(int stringIndex)
                throws java.lang.Exception
a callback for character data - string pool version
Parameters:
stringIndex - string pool index of the string that was scanned
Throws:
java.lang.Exception -  

ignorableWhitespace

public void ignorableWhitespace(char[] chars,
                                int offset,
                                int length)
                         throws java.lang.Exception
a callback for ignorable whitespace - String object version
Parameters:
chars - array containing the white space that was scanned
offset - offset in chars of the white space that was scanned
length - length of the white space that was scanned
Throws:
java.lang.Exception -  

ignorableWhitespace

public void ignorableWhitespace(int stringIndex)
                         throws java.lang.Exception
a callback for ignorable whitespace - string pool version
Parameters:
stringIndex - - string pool index of the white space that was scanned
Throws:
java.lang.Exception -  

externalReferenceInContent

public boolean externalReferenceInContent(int entityIndex)
                                   throws java.lang.Exception
return true if entityIndex's entity is external, and it satisfies the requirements for an external entity reference within content
Parameters:
entityIndex - entity handle
Returns:
true if the entity is external
Throws:
java.lang.Exception -  

valueOfReferenceInAttValue

public int valueOfReferenceInAttValue(int entityIndex)
                               throws java.lang.Exception
return the string pool index of an entity the entity must be allowed to appear in an attribute value
Parameters:
entityIndex - entity handle
Returns:
string pool index of entity valkue
Throws:
java.lang.Exception -  

lookupEntity

public int lookupEntity(int entityName)
                 throws java.lang.Exception
return a handle to an entity. This handle can then be passed to the other XMLEntityHandler methods on XMLValidator
Parameters:
entityName - string pool index of entity name
Returns:
entity Handle
Throws:
java.lang.Exception -  

isUnparsedEntity

public boolean isUnparsedEntity(int entityIndex)
                         throws java.lang.Exception
return true if entityIndex's entity is unparsed
Parameters:
entityIndex - entity handle
Returns:
true if entityIndex's entity is unparsed
Throws:
java.lang.Exception -  

isExternalEntity

public boolean isExternalEntity(int entityIndex)
                         throws java.lang.Exception
return true if entityIndex's entity is external
Parameters:
entityIndex - entity handle
Returns:
true if entityIndex's entity is external
Throws:
java.lang.Exception -  

getEntityValue

public int getEntityValue(int entityIndex)
                   throws java.lang.Exception
return the replacement text for entityIndex
Parameters:
entityIndex - entity handle
Returns:
the string pool index of entityIndex's replacement text
Throws:
java.lang.Exception -  

getPublicIdOfEntity

public java.lang.String getPublicIdOfEntity(int entityIndex)
                                     throws java.lang.Exception
return the public identifer for entityIndex
Parameters:
entityIndex - entity handle
Returns:
String containing entityIndex's public identifier
Throws:
java.lang.Exception -  

getSystemIdOfEntity

public java.lang.String getSystemIdOfEntity(int entityIndex)
                                     throws java.lang.Exception
return the system identifier for entityIndex
Parameters:
entityIndex - entity handle
Returns:
String containing entityIndex' system identifier
Throws:
java.lang.Exception -  

lookupParameterEntity

public int lookupParameterEntity(int peName)
                          throws java.lang.Exception
return a handle to a parameter entity - this handle can then be passed to other XMLEntityHandler methods on XMLValidator
Parameters:
peName - string pool index of a parameter entity name
Returns:
handle to the parameter entity named by peName
Throws:
java.lang.Exception -  

isExternalParameterEntity

public boolean isExternalParameterEntity(int peIndex)
                                  throws java.lang.Exception
return true if a parameter entity is external
Parameters:
peIndex - parameter entity handle
Returns:
true if peIndex's parameter entity is external
Throws:
java.lang.Exception -  

getParameterEntityValue

public int getParameterEntityValue(int peIndex)
                            throws java.lang.Exception
return the replacement text for a parameter entity
Parameters:
peIndex - parameter entity handle
Returns:
the string pool index of the replacment text for peIndex's parameter entity
Throws:
java.lang.Exception -  

getPublicIdOfParameterEntity

public java.lang.String getPublicIdOfParameterEntity(int peIndex)
                                              throws java.lang.Exception
return the public identifier for a parameter entity
Parameters:
peIndex - parameter entity handle
Returns:
a String containing the public identifier for peIndex's parameter entity
Throws:
java.lang.Exception -  

getSystemIdOfParameterEntity

public java.lang.String getSystemIdOfParameterEntity(int peIndex)
                                              throws java.lang.Exception
return the system identifier for a parameter entity
Parameters:
peIndex - parameter entity handle
Throws:
java.lang.Exception -  

checkContent

public int checkContent(int elementHandle,
                        int childCount,
                        int[] children)
                 throws java.lang.Exception
validate an element's content
Parameters:
elementHandle - handle of the element to be validated
childCount - the number of children to be checked
children - an array containing the indices of the children to be checked
Returns:
-1 if valid, otherwise the index of the child that caused the content to be invalid
Throws:
java.lang.Exception -  

getContentSpecAsString

public java.lang.String getContentSpecAsString(int elementIndex)
return elementIndex's content spec as a string
Parameters:
elementIndex - element handle
Returns:
String containing the content spec for elementIndex


Copyright © 1999 Apache XML Project. All Rights Reserved.