XML for Java EA2

com.ibm.xml.framework
Class XMLParser

java.lang.Object
  |
  +--com.ibm.xml.framework.XMLDocumentScanner
        |
        +--com.ibm.xml.framework.XMLParser
Direct Known Subclasses:
DOMParser, SAXParser

public abstract class XMLParser
extends XMLDocumentScanner
implements XMLErrorReporter, com.ibm.xml.validators.dtd.DTDValidator.EventHandler, com.ibm.xml.readers.XMLEntityHandler.CharDataConduit, Configurable, Locator

This is the base class of all parsers.

This class implements the XMLDocumentTypeHandler, XMLDocumentHandler, and XMLErrorHandler interfaces. This is provided as a convenience to parser subclasses so that they can implement these interfaces directly in the subclass instead of needing a separate class.

Version:
Revision: %M% %I% %W% %Q%
See Also:
InputSource, Locator

Field Summary
protected  boolean fNamespacesEnabled
           
protected  java.lang.String fNamespaceSep
           
protected  boolean fParseInProgress
           
protected  XMLValidator fValidator
           
protected static java.lang.String SAX2_FEATURES_PREFIX
          SAX2 features prefix (http://xml.org/sax/features/).
protected static java.lang.String SAX2_HANDLERS_PREFIX
          SAX2 handlers prefix (http://xml.org/sax/handlers/).
protected static java.lang.String SAX2_PROPERTIES_PREFIX
          SAX2 properties prefix (http://xml.org/sax/properties/).
protected static java.lang.String XML4J_FEATURES_PREFIX
          XML4J features prefix (http://ibm.com/xml/features/).
protected static java.lang.String XML4J_PROPERTIES_PREFIX
          XML4J properties prefix (http://ibm.com/xml/properties/).
 
Fields inherited from class com.ibm.xml.framework.XMLDocumentScanner
fCurrentElementEntity, fCurrentElementType, fElementDepth, fEntityHandler, fEntityReader, fErrorReporter, fInElementContent, fReaderId, fStringPool, SCANNER_STATE_ATTRIBUTE_LIST, SCANNER_STATE_ATTRIBUTE_NAME, SCANNER_STATE_ATTRIBUTE_VALUE, SCANNER_STATE_COMMENT, SCANNER_STATE_CONTENT, SCANNER_STATE_DOCTYPE, SCANNER_STATE_ELEMENT, SCANNER_STATE_MISC_OR_DOCTYPE, SCANNER_STATE_MISC_OR_ROOT_ELEMENT, SCANNER_STATE_PI, SCANNER_STATE_SETUP, SCANNER_STATE_START_OF_MARKUP, SCANNER_STATE_STRING_LITERAL, SCANNER_STATE_TRAILING_MISC, SCANNER_STATE_UNKNOWN, SCANNER_STATE_XML_DECL
 
Constructor Summary
protected XMLParser()
          Constructor
 
Method Summary
protected  boolean addAttrForElement(int elementTypeIndex, int attrNameIndex, int attrValueIndex)
          Adds an attribute for an element.
abstract  void attlistDecl(int elementType, int attrNameIndex, int attType, java.lang.String enumString, int attDefaultType, int attDefaultValue)
          Attribute list declaration.
protected  void callCharacters(int ch)
          Calls characters.
protected  void callComment(int commentIndex)
          Calls comment.
protected  void callEndDocument()
          Calls the end document.
protected  boolean callEndElement(int elementType)
          Calls end element.
protected  void callProcessingInstruction(int targetIndex, int dataIndex)
          Calls processing instruction.
protected  void callStartDocument(int versionIndex, int encodingIndex, int standaloneIndex)
          Calls the start document.
protected  void callStartElement(int elementType)
          Calls start element.
abstract  void characters(char[] ch, int start, int length)
          Characters.
abstract  void characters(int dataIndex)
          Characters.
abstract  void comment(int dataIndex)
          Comment.
 void commentInDTD(int dataIndex)
          Comment in DTD.
abstract  void elementDecl(int elementType, java.lang.String contentModel)
          Element declaration.
protected  void elementSpecified(int elementType)
          Initializes the attributes for an element.
abstract  void endCDATA()
          End CDATA section.
abstract  void endDocument()
          End document.
abstract  void endDTD()
          This function will be called at the end of the DTD.
abstract  void endElement(int elementType)
          End element.
abstract  void endNamespaceDeclScope(int prefix)
          Report the end of the scope of a namespace declaration.
abstract  void externalEntityDecl(int entityName, int publicId, int systemId)
          External general entity declaration.
abstract  void externalPEDecl(int entityName, int publicId, int systemId)
          External parameter entity declaration.
protected  boolean getAllowJavaEncodings()
          Returns true if Java encoding names are allowed in the XML document.
 int getColumnNumber()
          Return the column number of the current position within the document that we are processing.
protected  boolean getContinueAfterFatalError()
          Returns true if the parser continues after a fatal error.
protected  com.ibm.xml.readers.XMLParserEntityHandler getEntityHandler()
          Returns the XML parser entity handler.
protected  boolean getExternalGeneralEntities()
          Note: This feature is always true. Returns true if external general entities are expanded.
protected  boolean getExternalParameterEntities()
          Note: This feature is always true. Returns true if external parameter entities are expanded.
 boolean getFeature(java.lang.String featureId)
          Query the state of a feature.
 java.lang.String[] getFeaturesRecognized()
          Returns a list of features that this parser recognizes.
 int getLineNumber()
          Return the line number of the current position within the document that we are processing.
 Locator getLocator()
          Returns the locator.
protected  boolean getNamespaces()
          Returns true if the parser preprocesses namespaces.
protected  java.lang.String getNamespaceSep()
          Returns the namespace separator.
 java.lang.String[] getPropertiesRecognized()
          Returns a list of properties that this parser recognizes.
 java.lang.Object getProperty(java.lang.String propertyId)
          Query the value of a property.
 java.lang.String getPublicId()
          Return the public identifier of the InputSource that we are processing.
protected  com.ibm.xml.validators.schema.XSchemaValidator getSchemaValidator()
          Returns the XML Schema validator.
 java.lang.String getSystemId()
          Return the system identifier of the InputSource that we are processing.
protected  boolean getValidation()
          Returns true if validation is turned on.
protected  boolean getValidationDynamic()
          Returns true if validation is based on whether a document contains a grammar.
protected  boolean getValidationWarnOnDuplicateAttdef()
          Returns true if an error is emitted when an attribute is redefined in the grammar.
protected  boolean getValidationWarnOnUndeclaredElemdef()
          Returns true if the parser emits an error when an undeclared element is referenced in the grammar.
protected  java.lang.String getXMLString()
          Note: This property is currently not supported because it is not well defined. Querying its value will throw a SAXNotSupportedException.
abstract  void ignorableWhitespace(char[] ch, int start, int length)
          Ignorable whitespace.
abstract  void ignorableWhitespace(int dataIndex)
          Ignorable whitespace.
abstract  void internalEntityDecl(int entityName, int entityValue)
          Internal general entity declaration.
abstract  void internalPEDecl(int entityName, int entityValue)
          Internal parameter entity declaration.
 boolean isFeatureRecognized(java.lang.String featureId)
          Returns true if the specified feature is recognized.
 boolean isPropertyRecognized(java.lang.String propertyId)
          Returns true if the specified property is recognized.
protected  void literalDataAppend(char ch)
          Appends to the literal data.
protected  void literalDataAppend(int toCopy, int length)
          Appends to the literal data.
protected  void literalDataAppend(java.lang.String s)
          Appends to the literal data.
protected  int literalDataIndex(int dataOffset, int dataLength)
          Returns the literal data index.
protected  int literalDataLength()
          Returns the literal data length.
 void loadCatalog(InputSource source)
          Loads the catalog stream specified by the given input source and appends the contents to the catalog.
abstract  void notationDecl(int notationName, int publicId, int systemId)
          Notation declaration.
 void parse(InputSource source)
          Parses the specified input source.
 void parse(java.lang.String systemId)
          Parses the input source specified by the given system identifier.
 boolean parseSomeSetup(InputSource source)
          Setup for application-driven parsing.
 void processCharacters(char[] chars, int offset, int length)
          Character data.
 void processCharacters(int stringIndex)
          Character data.
abstract  void processingInstruction(int targetIndex, int dataIndex)
          Processing instruction.
 void processingInstructionInDTD(int targetIndex, int dataIndex)
          Processing instruction in DTD.
 void processWhitespace(char[] chars, int offset, int length)
          White space.
 void processWhitespace(int stringIndex)
          White space.
 void reportError(Locator locator, java.lang.String errorDomain, int majorCode, int minorCode, java.lang.Object[] args, int errorType)
          Report an error.
 void reset()
          Reset parser.
protected  void resetOrCopy()
          Reset or copy parser.
protected  int scanAttributeName()
          Scans an attribute name.
protected  int scanAttValue(int elementTypeIndex, int attrNameIndex)
          Scans an attribute value.
protected  void scanDoctypeDecl(boolean standalone)
          Scan doctype decl.
protected  int scanElementType(char fastchar)
          Scans an element type.
protected  boolean scanExpectedElementType(char fastchar)
          Scans an expected element type.
protected  void setAllowJavaEncodings(boolean allow)
          Allows the use of Java encoding names in the XMLDecl and TextDecl lines in an XML document.
protected  void setCharDataInterest(boolean interested, boolean sendCharDataAsCharArray)
           
protected  void setContinueAfterFatalError(boolean continueAfterFatalError)
          Allows the parser to continue after a fatal error.
 void setEntityResolver(EntityResolver resolver)
          Sets the entity resolver.
 void setErrorHandler(ErrorHandler handler)
          Sets the error handler.
protected  void setExternalGeneralEntities(boolean expand)
          Note: Currently, this parser always expands external general entities. Setting this feature to false will throw a SAXNotSupportedException.
protected  void setExternalParameterEntities(boolean expand)
          Note: Currently, this parser always expands external parameter entities. Setting this feature to false will throw a SAXNotSupportedException.
 void setFeature(java.lang.String featureId, boolean state)
          Set the state of a feature.
 void setLocale(java.util.Locale locale)
          Set the locale to use for messages.
 void setLocator(Locator locator)
          Sets the locator.
protected  void setNamespaces(boolean process)
          Sets whether the parser preprocesses namespaces.
protected  void setNamespaceSep(java.lang.String separator)
          Set the separator to be used between the URI part of a name and the local part of a name when namespace processing is being performed (see the http://xml.org/sax/features/namespaces feature).
 void setProperty(java.lang.String propertyId, java.lang.Object value)
          Set the value of a property.
 void setValidating(boolean flag)
           
protected  void setValidation(boolean validate)
          Sets whether the parser validates.
protected  void setValidationDynamic(boolean dynamic)
          Allows the parser to validate a document only when it contains a grammar.
protected  void setValidationWarnOnDuplicateAttdef(boolean warn)
          Sets whether an error is emitted when an attribute is redefined in the grammar.
protected  void setValidationWarnOnUndeclaredElemdef(boolean warn)
          Sets whether the parser emits an error when an element's content model references an element by name that is not declared in the grammar.
abstract  void startCDATA()
          Start CDATA section.
abstract  void startDocument(int versionIndex, int encodingIndex, int standAloneIndex)
          If the there is no version info, encoding info, or standalone info, the corresponding index will be set to -1.
abstract  void startDTD(int rootElementType, int publicId, int systemId)
          This function will be called when a <!DOCTYPE...> declaration is encountered.
abstract  void startElement(int elementType, XMLAttrList attrList, int attrListIndex)
          Start element.
abstract  void startNamespaceDeclScope(int prefix, int uri)
          Report the start of the scope of a namespace declaration.
abstract  void unparsedEntityDecl(int entityName, int publicId, int systemId, int notationName)
          Unparsed entity declaration.
protected  boolean validEncName(java.lang.String encoding)
          Returns true if the specified encoding is valid.
protected  boolean validVersionNum(java.lang.String version)
          Returns true if the specified version is valid.
 
Methods inherited from class com.ibm.xml.framework.XMLDocumentScanner
abortMarkup, abortMarkup, abortMarkup, abortMarkup, checkXMLLangAttributeValue, decreaseMarkupDepth, endOfInput, getScannerState, increaseMarkupDepth, markupDepth, parseSome, readerChange, reportFatalXMLError, reportFatalXMLError, reportFatalXMLError, reportFatalXMLError, reportFatalXMLError, reportFatalXMLError, scanComplexAttValue, setEntityHandler, setErrorReporter, skipPastEndOfCurrentMarkup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SAX2_FEATURES_PREFIX

protected static final java.lang.String SAX2_FEATURES_PREFIX
SAX2 features prefix (http://xml.org/sax/features/).

SAX2_PROPERTIES_PREFIX

protected static final java.lang.String SAX2_PROPERTIES_PREFIX
SAX2 properties prefix (http://xml.org/sax/properties/).

SAX2_HANDLERS_PREFIX

protected static final java.lang.String SAX2_HANDLERS_PREFIX
SAX2 handlers prefix (http://xml.org/sax/handlers/).

XML4J_FEATURES_PREFIX

protected static final java.lang.String XML4J_FEATURES_PREFIX
XML4J features prefix (http://ibm.com/xml/features/).

XML4J_PROPERTIES_PREFIX

protected static final java.lang.String XML4J_PROPERTIES_PREFIX
XML4J properties prefix (http://ibm.com/xml/properties/).

fParseInProgress

protected boolean fParseInProgress

fNamespaceSep

protected java.lang.String fNamespaceSep

fValidator

protected XMLValidator fValidator

fNamespacesEnabled

protected boolean fNamespacesEnabled
Constructor Detail

XMLParser

protected XMLParser()
Constructor
Method Detail

getFeaturesRecognized

public java.lang.String[] getFeaturesRecognized()
Returns a list of features that this parser recognizes. This method will never return null; if no features are recognized, this method will return a zero length array.
See Also:
isFeatureRecognized(java.lang.String), setFeature(java.lang.String, boolean), getFeature(java.lang.String)

isFeatureRecognized

public boolean isFeatureRecognized(java.lang.String featureId)
Returns true if the specified feature is recognized.
See Also:
getFeaturesRecognized(), setFeature(java.lang.String, boolean), getFeature(java.lang.String)

getPropertiesRecognized

public java.lang.String[] getPropertiesRecognized()
Returns a list of properties that this parser recognizes. This method will never return null; if no properties are recognized, this method will return a zero length array.
See Also:
isPropertyRecognized(java.lang.String), setProperty(java.lang.String, java.lang.Object), getProperty(java.lang.String)

isPropertyRecognized

public boolean isPropertyRecognized(java.lang.String propertyId)
Returns true if the specified property is recognized.
See Also:
getPropertiesRecognized(), setProperty(java.lang.String, java.lang.Object), getProperty(java.lang.String)

loadCatalog

public void loadCatalog(InputSource source)
                 throws java.lang.Exception
Loads the catalog stream specified by the given input source and appends the contents to the catalog.
Parameters:
source - The catalog source.
Throws:
java.lang.Exception - Throws an exception if an error occurs while loading the catalog source.

parseSomeSetup

public boolean parseSomeSetup(InputSource source)
                       throws java.lang.Exception
Setup for application-driven parsing.
See Also:
XMLDocumentScanner.parseSome(boolean)

reset

public void reset()
           throws java.lang.Exception
Reset parser.
Overrides:
reset in class XMLDocumentScanner

setLocator

public void setLocator(Locator locator)
Sets the locator.
Specified by:
setLocator in interface XMLErrorReporter
Parameters:
locator - The new locator.

getLocator

public final Locator getLocator()
Returns the locator.
Specified by:
getLocator in interface XMLErrorReporter

processingInstructionInDTD

public void processingInstructionInDTD(int targetIndex,
                                       int dataIndex)
                                throws java.lang.Exception
Processing instruction in DTD.
Specified by:
processingInstructionInDTD in interface com.ibm.xml.validators.dtd.DTDValidator.EventHandler

commentInDTD

public void commentInDTD(int dataIndex)
                  throws java.lang.Exception
Comment in DTD.
Specified by:
commentInDTD in interface com.ibm.xml.validators.dtd.DTDValidator.EventHandler

startDocument

public abstract void startDocument(int versionIndex,
                                   int encodingIndex,
                                   int standAloneIndex)
                            throws java.lang.Exception
If the there is no version info, encoding info, or standalone info, the corresponding index will be set to -1.

endDocument

public abstract void endDocument()
                          throws java.lang.Exception
End document.

startNamespaceDeclScope

public abstract void startNamespaceDeclScope(int prefix,
                                             int uri)
                                      throws java.lang.Exception
Report the start of the scope of a namespace declaration.
Specified by:
startNamespaceDeclScope in interface com.ibm.xml.validators.dtd.DTDValidator.EventHandler

endNamespaceDeclScope

public abstract void endNamespaceDeclScope(int prefix)
                                    throws java.lang.Exception
Report the end of the scope of a namespace declaration.
Specified by:
endNamespaceDeclScope in interface com.ibm.xml.validators.dtd.DTDValidator.EventHandler

startElement

public abstract void startElement(int elementType,
                                  XMLAttrList attrList,
                                  int attrListIndex)
                           throws java.lang.Exception
Start element.

endElement

public abstract void endElement(int elementType)
                         throws java.lang.Exception
End element.

startCDATA

public abstract void startCDATA()
                         throws java.lang.Exception
Start CDATA section.
Overrides:
startCDATA in class XMLDocumentScanner

endCDATA

public abstract void endCDATA()
                       throws java.lang.Exception
End CDATA section.
Overrides:
endCDATA in class XMLDocumentScanner

processingInstruction

public abstract void processingInstruction(int targetIndex,
                                           int dataIndex)
                                    throws java.lang.Exception
Processing instruction.

comment

public abstract void comment(int dataIndex)
                      throws java.lang.Exception
Comment.

characters

public abstract void characters(int dataIndex)
                         throws java.lang.Exception
Characters.

characters

public abstract void characters(char[] ch,
                                int start,
                                int length)
                         throws java.lang.Exception
Characters.

ignorableWhitespace

public abstract void ignorableWhitespace(int dataIndex)
                                  throws java.lang.Exception
Ignorable whitespace.

ignorableWhitespace

public abstract void ignorableWhitespace(char[] ch,
                                         int start,
                                         int length)
                                  throws java.lang.Exception
Ignorable whitespace.

startDTD

public abstract void startDTD(int rootElementType,
                              int publicId,
                              int systemId)
                       throws java.lang.Exception
This function will be called when a <!DOCTYPE...> declaration is encountered.
Specified by:
startDTD in interface com.ibm.xml.validators.dtd.DTDValidator.EventHandler

endDTD

public abstract void endDTD()
                     throws java.lang.Exception
This function will be called at the end of the DTD.
Specified by:
endDTD in interface com.ibm.xml.validators.dtd.DTDValidator.EventHandler

elementDecl

public abstract void elementDecl(int elementType,
                                 java.lang.String contentModel)
                          throws java.lang.Exception
Element declaration.
Specified by:
elementDecl in interface com.ibm.xml.validators.dtd.DTDValidator.EventHandler

attlistDecl

public abstract void attlistDecl(int elementType,
                                 int attrNameIndex,
                                 int attType,
                                 java.lang.String enumString,
                                 int attDefaultType,
                                 int attDefaultValue)
                          throws java.lang.Exception
Attribute list declaration.
Specified by:
attlistDecl in interface com.ibm.xml.validators.dtd.DTDValidator.EventHandler

internalPEDecl

public abstract void internalPEDecl(int entityName,
                                    int entityValue)
                             throws java.lang.Exception
Internal parameter entity declaration.
Specified by:
internalPEDecl in interface com.ibm.xml.validators.dtd.DTDValidator.EventHandler

externalPEDecl

public abstract void externalPEDecl(int entityName,
                                    int publicId,
                                    int systemId)
                             throws java.lang.Exception
External parameter entity declaration.
Specified by:
externalPEDecl in interface com.ibm.xml.validators.dtd.DTDValidator.EventHandler

internalEntityDecl

public abstract void internalEntityDecl(int entityName,
                                        int entityValue)
                                 throws java.lang.Exception
Internal general entity declaration.
Specified by:
internalEntityDecl in interface com.ibm.xml.validators.dtd.DTDValidator.EventHandler

externalEntityDecl

public abstract void externalEntityDecl(int entityName,
                                        int publicId,
                                        int systemId)
                                 throws java.lang.Exception
External general entity declaration.
Specified by:
externalEntityDecl in interface com.ibm.xml.validators.dtd.DTDValidator.EventHandler

unparsedEntityDecl

public abstract void unparsedEntityDecl(int entityName,
                                        int publicId,
                                        int systemId,
                                        int notationName)
                                 throws java.lang.Exception
Unparsed entity declaration.
Specified by:
unparsedEntityDecl in interface com.ibm.xml.validators.dtd.DTDValidator.EventHandler

notationDecl

public abstract void notationDecl(int notationName,
                                  int publicId,
                                  int systemId)
                           throws java.lang.Exception
Notation declaration.
Specified by:
notationDecl in interface com.ibm.xml.validators.dtd.DTDValidator.EventHandler

setValidation

protected void setValidation(boolean validate)
                      throws SAXException
Sets whether the parser validates.

This method is the equivalent to the feature:

 http://xml.org/sax/features/validation
 
Parameters:
validate - True to validate; false to not validate.
See Also:
getValidation(), setFeature(java.lang.String, boolean)

getValidation

protected boolean getValidation()
                         throws SAXException
Returns true if validation is turned on.
See Also:
setValidation(boolean)

setExternalGeneralEntities

protected void setExternalGeneralEntities(boolean expand)
                                   throws SAXException
Note: Currently, this parser always expands external general entities. Setting this feature to false will throw a SAXNotSupportedException.

Sets whether external general entities are expanded.

This method is the equivalent to the feature:

 http://xml.org/sax/features/external-general-entities
 
Parameters:
expand - True to expand external general entities; false to not expand.
See Also:
#getExternalGeneralEntites, setFeature(java.lang.String, boolean)

getExternalGeneralEntities

protected boolean getExternalGeneralEntities()
                                      throws SAXException
Note: This feature is always true.

Returns true if external general entities are expanded.

See Also:
setExternalGeneralEntities(boolean)

setExternalParameterEntities

protected void setExternalParameterEntities(boolean expand)
                                     throws SAXException
Note: Currently, this parser always expands external parameter entities. Setting this feature to false will throw a SAXNotSupportedException.

Sets whether external parameter entities are expanded.

This method is the equivalent to the feature:

 http://xml.org/sax/features/external-parameter-entities
 
Parameters:
expand - True to expand external parameter entities; false to not expand.
See Also:
#getExternalParameterEntites, setFeature(java.lang.String, boolean)

getExternalParameterEntities

protected boolean getExternalParameterEntities()
                                        throws SAXException
Note: This feature is always true.

Returns true if external parameter entities are expanded.

See Also:
setExternalParameterEntities(boolean)

setNamespaces

protected void setNamespaces(boolean process)
                      throws SAXException
Sets whether the parser preprocesses namespaces.

This method is the equivalent to the feature:

 http://xml.org/sax/features/namespaces
 
Parameters:
process - True to process namespaces; false to not process.
See Also:
getNamespaces(), setFeature(java.lang.String, boolean)

getNamespaces

protected boolean getNamespaces()
                         throws SAXException
Returns true if the parser preprocesses namespaces.
See Also:
setNamespaces(boolean)

setValidationDynamic

protected void setValidationDynamic(boolean dynamic)
                             throws SAXException
Allows the parser to validate a document only when it contains a grammar. Validation is turned on/off based on each document instance, automatically.

This method is the equivalent to the feature:

 http://ibm.com/xml/features/validation/dynamic
 
Parameters:
dynamic - True to dynamically validate documents; false to validate based on the validation feature.
See Also:
getValidationDynamic(), setFeature(java.lang.String, boolean)

getValidationDynamic

protected boolean getValidationDynamic()
                                throws SAXException
Returns true if validation is based on whether a document contains a grammar.
See Also:
setValidationDynamic(boolean)

setValidationWarnOnDuplicateAttdef

protected void setValidationWarnOnDuplicateAttdef(boolean warn)
                                           throws SAXException
Sets whether an error is emitted when an attribute is redefined in the grammar.

This method is the equivalent to the feature:

 http://ibm.com/xml/features/validation/warn-on-duplicate-attdef
 
Parameters:
warn - True to warn; false to not warn.
See Also:
getValidationWarnOnDuplicateAttdef(), setFeature(java.lang.String, boolean)

getValidationWarnOnDuplicateAttdef

protected boolean getValidationWarnOnDuplicateAttdef()
                                              throws SAXException
Returns true if an error is emitted when an attribute is redefined in the grammar.
See Also:
setValidationWarnOnDuplicateAttdef(boolean)

setValidationWarnOnUndeclaredElemdef

protected void setValidationWarnOnUndeclaredElemdef(boolean warn)
                                             throws SAXException
Sets whether the parser emits an error when an element's content model references an element by name that is not declared in the grammar.

This method is the equivalent to the feature:

 http://ibm.com/xml/features/validation/warn-on-undeclared-elemdef
 
Parameters:
warn - True to warn; false to not warn.
See Also:
getValidationWarnOnUndeclaredElemdef(), setFeature(java.lang.String, boolean)

getValidationWarnOnUndeclaredElemdef

protected boolean getValidationWarnOnUndeclaredElemdef()
                                                throws SAXException
Returns true if the parser emits an error when an undeclared element is referenced in the grammar.
See Also:
setValidationWarnOnUndeclaredElemdef(boolean)

setAllowJavaEncodings

protected void setAllowJavaEncodings(boolean allow)
                              throws SAXException
Allows the use of Java encoding names in the XMLDecl and TextDecl lines in an XML document.

This method is the equivalent to the feature:

 http://ibm.com/xml/features/allow-java-encodings
 
Parameters:
allow - True to allow Java encoding names; false to disallow.
See Also:
getAllowJavaEncodings(), setFeature(java.lang.String, boolean)

getAllowJavaEncodings

protected boolean getAllowJavaEncodings()
                                 throws SAXException
Returns true if Java encoding names are allowed in the XML document.
See Also:
setAllowJavaEncodings(boolean)

setContinueAfterFatalError

protected void setContinueAfterFatalError(boolean continueAfterFatalError)
                                   throws SAXException
Allows the parser to continue after a fatal error. Normally, a fatal error would stop the parse.

This method is the equivalent to the feature:

 http://ibm.com/xml/features/continue-after-fatal-error
 
Parameters:
continueAfterFatalError - True to continue; false to stop on fatal error.
See Also:
getContinueAfterFatalError(), setFeature(java.lang.String, boolean)

getContinueAfterFatalError

protected boolean getContinueAfterFatalError()
                                      throws SAXException
Returns true if the parser continues after a fatal error.
See Also:
setContinueAfterFatalError(boolean)

setNamespaceSep

protected void setNamespaceSep(java.lang.String separator)
                        throws SAXException
Set the separator to be used between the URI part of a name and the local part of a name when namespace processing is being performed (see the http://xml.org/sax/features/namespaces feature). By default, the separator is a single space.

This property may not be set while a parse is in progress (throws a SAXNotSupportedException).

This method is the equivalent to the property:

 http://xml.org/sax/properties/namespace-sep
 
Parameters:
separator - The new namespace separator.
See Also:
getNamespaceSep(), setProperty(java.lang.String, java.lang.Object)

getNamespaceSep

protected java.lang.String getNamespaceSep()
                                    throws SAXException
Returns the namespace separator.
See Also:
setNamespaceSep(java.lang.String)

getXMLString

protected java.lang.String getXMLString()
                                 throws SAXException
Note: This property is currently not supported because it is not well defined. Querying its value will throw a SAXNotSupportedException.

This method is the equivalent to the property:

 http://xml.org/sax/properties/xml-string
 
See Also:
getProperty(java.lang.String)

resetOrCopy

protected void resetOrCopy()
                    throws java.lang.Exception
Reset or copy parser.
Overrides:
resetOrCopy in class XMLDocumentScanner

getEntityHandler

protected com.ibm.xml.readers.XMLParserEntityHandler getEntityHandler()
Returns the XML parser entity handler.

getSchemaValidator

protected com.ibm.xml.validators.schema.XSchemaValidator getSchemaValidator()
Returns the XML Schema validator.

setErrorHandler

public void setErrorHandler(ErrorHandler handler)
Sets the error handler.
Parameters:
handler - The new error handler.

parse

public void parse(InputSource source)
           throws SAXException,
                  java.io.IOException
Parses the specified input source.
Parameters:
source - The input source.
Throws:
SAXException - Throws exception on SAX error.
java.io.IOException - Throws exception on i/o error.

parse

public void parse(java.lang.String systemId)
           throws SAXException,
                  java.io.IOException
Parses the input source specified by the given system identifier.

This method is equivalent to the following:

     parse(new InputSource(systemId));
 
Parameters:
source - The input source.
Throws:
SAXException - Throws exception on SAX error.
java.io.IOException - Throws exception on i/o error.

setLocale

public void setLocale(java.util.Locale locale)
               throws SAXException
Set the locale to use for messages.
Parameters:
locale - The locale object to use for localization of messages.
Throws:
SAXException - An exception thrown if the parser does not support the specified locale.
See Also:
Parser

setEntityResolver

public void setEntityResolver(EntityResolver resolver)
Sets the entity resolver. If the entity resolver is of type XMLCatalogHandler, then the resolver is added as a catalog handler.
Parameters:
resolver - The new entity resolver.

reportError

public void reportError(Locator locator,
                        java.lang.String errorDomain,
                        int majorCode,
                        int minorCode,
                        java.lang.Object[] args,
                        int errorType)
                 throws java.lang.Exception
Report an error.
Specified by:
reportError in interface XMLErrorReporter
Parameters:
locator - Location of error.
errorDomain - The error domain.
majorCode - The major code of the error.
minorCode - The minor code of the error.
args - Arguments for replacement text.
errorType - The type of the error.
Throws:
java.lang.Exception - Thrown on error.
See Also:
XMLErrorReport#ERRORTYPE_WARNING, XMLErrorReport#ERRORTYPE_FATAL_ERROR

setFeature

public void setFeature(java.lang.String featureId,
                       boolean state)
                throws SAXException
Set the state of a feature. Set the state of any feature in a SAX2 parser. The parser might not recognize the feature, and if it does recognize it, it might not be able to fulfill the request.
Specified by:
setFeature in interface Configurable
Parameters:
featureId - The unique identifier (URI) of the feature.
state - The requested state of the feature (true or false).
Throws:
SAXNotRecognizedException - If the requested feature is not known.
SAXNotSupportedException - If the requested feature is known, but the requested state is not supported.
SAXException - If there is any other problem fulfilling the request.

getFeature

public boolean getFeature(java.lang.String featureId)
                   throws SAXException
Query the state of a feature. Query the current state of any feature in a SAX2 parser. The parser might not recognize the feature.
Specified by:
getFeature in interface Configurable
Parameters:
featureId - The unique identifier (URI) of the feature being set.
Returns:
The current state of the feature.
Throws:
SAXNotRecognizedException - If the requested feature is not known.
SAXException - If there is any other problem fulfilling the request.

setProperty

public void setProperty(java.lang.String propertyId,
                        java.lang.Object value)
                 throws SAXException
Set the value of a property. Set the value of any property in a SAX2 parser. The parser might not recognize the property, and if it does recognize it, it might not support the requested value.
Specified by:
setProperty in interface Configurable
Parameters:
propertyId - The unique identifier (URI) of the property being set.
Object - The value to which the property is being set.
Throws:
SAXNotRecognizedException - If the requested property is not known.
SAXNotSupportedException - If the requested property is known, but the requested value is not supported.
SAXException - If there is any other problem fulfilling the request.

getProperty

public java.lang.Object getProperty(java.lang.String propertyId)
                             throws SAXException
Query the value of a property. Return the current value of a property in a SAX2 parser. The parser might not recognize the property.
Specified by:
getProperty in interface Configurable
Parameters:
propertyId - The unique identifier (URI) of the property being set.
Returns:
The current value of the property.
Throws:
SAXNotRecognizedException - If the requested property is not known.
SAXException - If there is any other problem fulfilling the request.
See Also:
Configurable.getProperty(java.lang.String)

validVersionNum

protected boolean validVersionNum(java.lang.String version)
Returns true if the specified version is valid.
Overrides:
validVersionNum in class XMLDocumentScanner

validEncName

protected boolean validEncName(java.lang.String encoding)
Returns true if the specified encoding is valid.
Overrides:
validEncName in class XMLDocumentScanner

literalDataLength

protected int literalDataLength()
Returns the literal data length.
Overrides:
literalDataLength in class XMLDocumentScanner

literalDataAppend

protected void literalDataAppend(int toCopy,
                                 int length)
                          throws java.lang.Exception
Appends to the literal data.
Overrides:
literalDataAppend in class XMLDocumentScanner

literalDataAppend

protected void literalDataAppend(char ch)
Appends to the literal data.
Overrides:
literalDataAppend in class XMLDocumentScanner

literalDataAppend

protected void literalDataAppend(java.lang.String s)
Appends to the literal data.

literalDataIndex

protected int literalDataIndex(int dataOffset,
                               int dataLength)
Returns the literal data index.
Overrides:
literalDataIndex in class XMLDocumentScanner

callStartDocument

protected void callStartDocument(int versionIndex,
                                 int encodingIndex,
                                 int standaloneIndex)
                          throws java.lang.Exception
Calls the start document.
Overrides:
callStartDocument in class XMLDocumentScanner

callEndDocument

protected void callEndDocument()
                        throws java.lang.Exception
Calls the end document.
Overrides:
callEndDocument in class XMLDocumentScanner

callStartElement

protected void callStartElement(int elementType)
                         throws java.lang.Exception
Calls start element.
Overrides:
callStartElement in class XMLDocumentScanner

callEndElement

protected boolean callEndElement(int elementType)
                          throws java.lang.Exception
Calls end element.
Overrides:
callEndElement in class XMLDocumentScanner

callProcessingInstruction

protected void callProcessingInstruction(int targetIndex,
                                         int dataIndex)
                                  throws java.lang.Exception
Calls processing instruction.
Overrides:
callProcessingInstruction in class XMLDocumentScanner

callComment

protected void callComment(int commentIndex)
                    throws java.lang.Exception
Calls comment.
Overrides:
callComment in class XMLDocumentScanner

callCharacters

protected void callCharacters(int ch)
                       throws java.lang.Exception
Calls characters.
Overrides:
callCharacters in class XMLDocumentScanner

elementSpecified

protected void elementSpecified(int elementType)
                         throws java.lang.Exception
Initializes the attributes for an element.
Overrides:
elementSpecified in class XMLDocumentScanner

addAttrForElement

protected boolean addAttrForElement(int elementTypeIndex,
                                    int attrNameIndex,
                                    int attrValueIndex)
                             throws java.lang.Exception
Adds an attribute for an element.
Overrides:
addAttrForElement in class XMLDocumentScanner

scanAttValue

protected int scanAttValue(int elementTypeIndex,
                           int attrNameIndex)
                    throws java.lang.Exception
Scans an attribute value.
Overrides:
scanAttValue in class XMLDocumentScanner

scanElementType

protected int scanElementType(char fastchar)
                       throws java.lang.Exception
Scans an element type.
Overrides:
scanElementType in class XMLDocumentScanner

scanExpectedElementType

protected boolean scanExpectedElementType(char fastchar)
                                   throws java.lang.Exception
Scans an expected element type.
Overrides:
scanExpectedElementType in class XMLDocumentScanner

scanAttributeName

protected int scanAttributeName()
                         throws java.lang.Exception
Scans an attribute name.
Overrides:
scanAttributeName in class XMLDocumentScanner

scanDoctypeDecl

protected void scanDoctypeDecl(boolean standalone)
                        throws java.lang.Exception
Scan doctype decl.
Overrides:
scanDoctypeDecl in class XMLDocumentScanner

processCharacters

public void processCharacters(char[] chars,
                              int offset,
                              int length)
                       throws java.lang.Exception
Character data.
Specified by:
processCharacters in interface com.ibm.xml.readers.XMLEntityHandler.CharDataConduit

processCharacters

public void processCharacters(int stringIndex)
                       throws java.lang.Exception
Character data.
Specified by:
processCharacters in interface com.ibm.xml.readers.XMLEntityHandler.CharDataConduit

processWhitespace

public void processWhitespace(char[] chars,
                              int offset,
                              int length)
                       throws java.lang.Exception
White space.
Specified by:
processWhitespace in interface com.ibm.xml.readers.XMLEntityHandler.CharDataConduit

processWhitespace

public void processWhitespace(int stringIndex)
                       throws java.lang.Exception
White space.
Specified by:
processWhitespace in interface com.ibm.xml.readers.XMLEntityHandler.CharDataConduit

setValidating

public void setValidating(boolean flag)
                   throws java.lang.Exception
Specified by:
setValidating in interface com.ibm.xml.validators.dtd.DTDValidator.EventHandler

getPublicId

public java.lang.String getPublicId()
Return the public identifier of the InputSource that we are processing.
Specified by:
getPublicId in interface Locator
Returns:
The public identifier, or null if not provided.

getSystemId

public java.lang.String getSystemId()
Return the system identifier of the InputSource that we are processing.
Specified by:
getSystemId in interface Locator
Returns:
The system identifier, or null if not provided.

getLineNumber

public int getLineNumber()
Return the line number of the current position within the document that we are processing.
Specified by:
getLineNumber in interface Locator
Returns:
The current line number.

getColumnNumber

public int getColumnNumber()
Return the column number of the current position within the document that we are processing.
Specified by:
getColumnNumber in interface Locator
Returns:
The current column number.

setCharDataInterest

protected void setCharDataInterest(boolean interested,
                                   boolean sendCharDataAsCharArray)

XML for Java EA2