|
XML for Java EA2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.xml.framework.XMLDocumentScanner | +--com.ibm.xml.framework.XMLParser
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.
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/). |
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 |
protected static final java.lang.String SAX2_FEATURES_PREFIX
protected static final java.lang.String SAX2_PROPERTIES_PREFIX
protected static final java.lang.String SAX2_HANDLERS_PREFIX
protected static final java.lang.String XML4J_FEATURES_PREFIX
protected static final java.lang.String XML4J_PROPERTIES_PREFIX
protected boolean fParseInProgress
protected java.lang.String fNamespaceSep
protected XMLValidator fValidator
protected boolean fNamespacesEnabled
Constructor Detail |
protected XMLParser()
Method Detail |
public java.lang.String[] getFeaturesRecognized()
isFeatureRecognized(java.lang.String)
,
setFeature(java.lang.String, boolean)
,
getFeature(java.lang.String)
public boolean isFeatureRecognized(java.lang.String featureId)
getFeaturesRecognized()
,
setFeature(java.lang.String, boolean)
,
getFeature(java.lang.String)
public java.lang.String[] getPropertiesRecognized()
isPropertyRecognized(java.lang.String)
,
setProperty(java.lang.String, java.lang.Object)
,
getProperty(java.lang.String)
public boolean isPropertyRecognized(java.lang.String propertyId)
getPropertiesRecognized()
,
setProperty(java.lang.String, java.lang.Object)
,
getProperty(java.lang.String)
public void loadCatalog(InputSource source) throws java.lang.Exception
source
- The catalog source.public boolean parseSomeSetup(InputSource source) throws java.lang.Exception
XMLDocumentScanner.parseSome(boolean)
public void reset() throws java.lang.Exception
public void setLocator(Locator locator)
locator
- The new locator.public final Locator getLocator()
public void processingInstructionInDTD(int targetIndex, int dataIndex) throws java.lang.Exception
public void commentInDTD(int dataIndex) throws java.lang.Exception
public abstract void startDocument(int versionIndex, int encodingIndex, int standAloneIndex) throws java.lang.Exception
public abstract void endDocument() throws java.lang.Exception
public abstract void startNamespaceDeclScope(int prefix, int uri) throws java.lang.Exception
public abstract void endNamespaceDeclScope(int prefix) throws java.lang.Exception
public abstract void startElement(int elementType, XMLAttrList attrList, int attrListIndex) throws java.lang.Exception
public abstract void endElement(int elementType) throws java.lang.Exception
public abstract void startCDATA() throws java.lang.Exception
public abstract void endCDATA() throws java.lang.Exception
public abstract void processingInstruction(int targetIndex, int dataIndex) throws java.lang.Exception
public abstract void comment(int dataIndex) throws java.lang.Exception
public abstract void characters(int dataIndex) throws java.lang.Exception
public abstract void characters(char[] ch, int start, int length) throws java.lang.Exception
public abstract void ignorableWhitespace(int dataIndex) throws java.lang.Exception
public abstract void ignorableWhitespace(char[] ch, int start, int length) throws java.lang.Exception
public abstract void startDTD(int rootElementType, int publicId, int systemId) throws java.lang.Exception
public abstract void endDTD() throws java.lang.Exception
public abstract void elementDecl(int elementType, java.lang.String contentModel) throws java.lang.Exception
public abstract void attlistDecl(int elementType, int attrNameIndex, int attType, java.lang.String enumString, int attDefaultType, int attDefaultValue) throws java.lang.Exception
public abstract void internalPEDecl(int entityName, int entityValue) throws java.lang.Exception
public abstract void externalPEDecl(int entityName, int publicId, int systemId) throws java.lang.Exception
public abstract void internalEntityDecl(int entityName, int entityValue) throws java.lang.Exception
public abstract void externalEntityDecl(int entityName, int publicId, int systemId) throws java.lang.Exception
public abstract void unparsedEntityDecl(int entityName, int publicId, int systemId, int notationName) throws java.lang.Exception
public abstract void notationDecl(int notationName, int publicId, int systemId) throws java.lang.Exception
protected void setValidation(boolean validate) throws SAXException
This method is the equivalent to the feature:
http://xml.org/sax/features/validation
validate
- True to validate; false to not validate.getValidation()
,
setFeature(java.lang.String, boolean)
protected boolean getValidation() throws SAXException
setValidation(boolean)
protected void setExternalGeneralEntities(boolean expand) throws SAXException
Sets whether external general entities are expanded.
This method is the equivalent to the feature:
http://xml.org/sax/features/external-general-entities
expand
- True to expand external general entities; false
to not expand.#getExternalGeneralEntites
,
setFeature(java.lang.String, boolean)
protected boolean getExternalGeneralEntities() throws SAXException
Returns true if external general entities are expanded.
setExternalGeneralEntities(boolean)
protected void setExternalParameterEntities(boolean expand) throws SAXException
Sets whether external parameter entities are expanded.
This method is the equivalent to the feature:
http://xml.org/sax/features/external-parameter-entities
expand
- True to expand external parameter entities; false
to not expand.#getExternalParameterEntites
,
setFeature(java.lang.String, boolean)
protected boolean getExternalParameterEntities() throws SAXException
Returns true if external parameter entities are expanded.
setExternalParameterEntities(boolean)
protected void setNamespaces(boolean process) throws SAXException
This method is the equivalent to the feature:
http://xml.org/sax/features/namespaces
process
- True to process namespaces; false to not process.getNamespaces()
,
setFeature(java.lang.String, boolean)
protected boolean getNamespaces() throws SAXException
setNamespaces(boolean)
protected void setValidationDynamic(boolean dynamic) throws SAXException
This method is the equivalent to the feature:
http://ibm.com/xml/features/validation/dynamic
dynamic
- True to dynamically validate documents; false to
validate based on the validation feature.getValidationDynamic()
,
setFeature(java.lang.String, boolean)
protected boolean getValidationDynamic() throws SAXException
setValidationDynamic(boolean)
protected void setValidationWarnOnDuplicateAttdef(boolean warn) throws SAXException
This method is the equivalent to the feature:
http://ibm.com/xml/features/validation/warn-on-duplicate-attdef
warn
- True to warn; false to not warn.getValidationWarnOnDuplicateAttdef()
,
setFeature(java.lang.String, boolean)
protected boolean getValidationWarnOnDuplicateAttdef() throws SAXException
setValidationWarnOnDuplicateAttdef(boolean)
protected void setValidationWarnOnUndeclaredElemdef(boolean warn) throws SAXException
This method is the equivalent to the feature:
http://ibm.com/xml/features/validation/warn-on-undeclared-elemdef
warn
- True to warn; false to not warn.getValidationWarnOnUndeclaredElemdef()
,
setFeature(java.lang.String, boolean)
protected boolean getValidationWarnOnUndeclaredElemdef() throws SAXException
setValidationWarnOnUndeclaredElemdef(boolean)
protected void setAllowJavaEncodings(boolean allow) throws SAXException
This method is the equivalent to the feature:
http://ibm.com/xml/features/allow-java-encodings
allow
- True to allow Java encoding names; false to disallow.getAllowJavaEncodings()
,
setFeature(java.lang.String, boolean)
protected boolean getAllowJavaEncodings() throws SAXException
setAllowJavaEncodings(boolean)
protected void setContinueAfterFatalError(boolean continueAfterFatalError) throws SAXException
This method is the equivalent to the feature:
http://ibm.com/xml/features/continue-after-fatal-error
continueAfterFatalError
- True to continue; false to stop on
fatal error.getContinueAfterFatalError()
,
setFeature(java.lang.String, boolean)
protected boolean getContinueAfterFatalError() throws SAXException
setContinueAfterFatalError(boolean)
protected void setNamespaceSep(java.lang.String separator) throws SAXException
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
separator
- The new namespace separator.getNamespaceSep()
,
setProperty(java.lang.String, java.lang.Object)
protected java.lang.String getNamespaceSep() throws SAXException
setNamespaceSep(java.lang.String)
protected java.lang.String getXMLString() throws SAXException
This method is the equivalent to the property:
http://xml.org/sax/properties/xml-string
getProperty(java.lang.String)
protected void resetOrCopy() throws java.lang.Exception
protected com.ibm.xml.readers.XMLParserEntityHandler getEntityHandler()
protected com.ibm.xml.validators.schema.XSchemaValidator getSchemaValidator()
public void setErrorHandler(ErrorHandler handler)
handler
- The new error handler.public void parse(InputSource source) throws SAXException, java.io.IOException
source
- The input source.public void parse(java.lang.String systemId) throws SAXException, java.io.IOException
This method is equivalent to the following:
parse(new InputSource(systemId));
source
- The input source.public void setLocale(java.util.Locale locale) throws SAXException
locale
- The locale object to use for localization of messages.Parser
public void setEntityResolver(EntityResolver resolver)
XMLCatalogHandler
, then the resolver is added
as a catalog handler.resolver
- The new entity resolver.public void reportError(Locator locator, java.lang.String errorDomain, int majorCode, int minorCode, java.lang.Object[] args, int errorType) throws java.lang.Exception
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.XMLErrorReport#ERRORTYPE_WARNING
,
XMLErrorReport#ERRORTYPE_FATAL_ERROR
public void setFeature(java.lang.String featureId, boolean state) throws SAXException
featureId
- The unique identifier (URI) of the feature.state
- The requested state of the feature (true or false).public boolean getFeature(java.lang.String featureId) throws SAXException
featureId
- The unique identifier (URI) of the feature
being set.public void setProperty(java.lang.String propertyId, java.lang.Object value) throws SAXException
propertyId
- The unique identifier (URI) of the property
being set.Object
- The value to which the property is being set.public java.lang.Object getProperty(java.lang.String propertyId) throws SAXException
propertyId
- The unique identifier (URI) of the property
being set.Configurable.getProperty(java.lang.String)
protected boolean validVersionNum(java.lang.String version)
protected boolean validEncName(java.lang.String encoding)
protected int literalDataLength()
protected void literalDataAppend(int toCopy, int length) throws java.lang.Exception
protected void literalDataAppend(char ch)
protected void literalDataAppend(java.lang.String s)
protected int literalDataIndex(int dataOffset, int dataLength)
protected void callStartDocument(int versionIndex, int encodingIndex, int standaloneIndex) throws java.lang.Exception
protected void callEndDocument() throws java.lang.Exception
protected void callStartElement(int elementType) throws java.lang.Exception
protected boolean callEndElement(int elementType) throws java.lang.Exception
protected void callProcessingInstruction(int targetIndex, int dataIndex) throws java.lang.Exception
protected void callComment(int commentIndex) throws java.lang.Exception
protected void callCharacters(int ch) throws java.lang.Exception
protected void elementSpecified(int elementType) throws java.lang.Exception
protected boolean addAttrForElement(int elementTypeIndex, int attrNameIndex, int attrValueIndex) throws java.lang.Exception
protected int scanAttValue(int elementTypeIndex, int attrNameIndex) throws java.lang.Exception
protected int scanElementType(char fastchar) throws java.lang.Exception
protected boolean scanExpectedElementType(char fastchar) throws java.lang.Exception
protected int scanAttributeName() throws java.lang.Exception
protected void scanDoctypeDecl(boolean standalone) throws java.lang.Exception
public void processCharacters(char[] chars, int offset, int length) throws java.lang.Exception
public void processCharacters(int stringIndex) throws java.lang.Exception
public void processWhitespace(char[] chars, int offset, int length) throws java.lang.Exception
public void processWhitespace(int stringIndex) throws java.lang.Exception
public void setValidating(boolean flag) throws java.lang.Exception
public java.lang.String getPublicId()
InputSource
that we are processing.public java.lang.String getSystemId()
InputSource
that we are processing.public int getLineNumber()
public int getColumnNumber()
protected void setCharDataInterest(boolean interested, boolean sendCharDataAsCharArray)
|
XML for Java EA2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |