Enhydra 5.1 API

org.enhydra.xml.xmlc.parsers.xerces
Class XercesParser

java.lang.Object
  |
  +--org.apache.xerces.framework.XMLParser
        |
        +--org.enhydra.xml.xmlc.parsers.xerces.XercesParser
All Implemented Interfaces:
EntityResolver, XMLCParser, XMLDocumentHandler, XMLDocumentHandler.DTDHandler, XMLErrorReporter

public class XercesParser
extends XMLParser
implements XMLCParser, EntityResolver, XMLDocumentHandler, XMLDocumentHandler.DTDHandler

Parse using the Xerces parser.


Nested Class Summary
 
Nested classes inherited from class org.apache.xerces.framework.XMLDocumentHandler
XMLDocumentHandler.DTDHandler
 
Field Summary
 
Fields inherited from class org.apache.xerces.framework.XMLParser
fEntityHandler, fErrorReporter, fGrammarResolver, fParseInProgress, fScanner, fStringPool, fValidator, SAX2_FEATURES_PREFIX, SAX2_PROPERTIES_PREFIX, XERCES_FEATURES_PREFIX, XERCES_PROPERTIES_PREFIX
 
Fields inherited from interface org.apache.xerces.framework.XMLErrorReporter
ERRORTYPE_FATAL_ERROR, ERRORTYPE_RECOVERABLE_ERROR, ERRORTYPE_WARNING
 
Constructor Summary
XercesParser()
           
 
Method Summary
 void attlistDecl(QName elementDecl, QName attributeDecl, int attType, boolean attList, java.lang.String enumString, int attDefaultType, int attDefaultValue)
          
 void characters(char[] ch, int start, int length)
          Handle characters.
 void characters(int data)
          Not used.
 void comment(int comment)
          Handle a comment.
 void elementDecl(QName elementDecl, int contentSpecType, int contentSpecIndex, XMLContentSpec.Provider contentSpecProvider)
          
 void endCDATA()
          Handle for end of CDATA section.
 void endDocument()
          Handle end document.
 void endDTD()
          callback for the end of the DTD This function will be called at the end of the DTD.
 void endElement(QName element)
          Handle end element.
 void endEntityReference(int entityName, int entityType, int entityContext)
          Handle the end of an entity reference.
 void endNamespaceDeclScope(int prefix)
          Handle end of a namespace declaration scope.
 void externalEntityDecl(int entityName, int publicId, int systemId)
          
 void externalPEDecl(int entityName, int publicId, int systemId)
          
 void ignorableWhitespace(char[] ch, int start, int length)
          Handle ignorable whitespace.
 void ignorableWhitespace(int data)
          Not used.
 void internalEntityDecl(int entityName, int entityValue)
          
 void internalPEDecl(int entityName, int entityValue)
          
 void internalSubset(int internalSubset)
          Supports DOM Level 2 internalSubset additions.
 void notationDecl(int notationName, int publicId, int systemId)
          
 XMLCDocument parse(InputSource input, LineNumberMap lineNumberMap, XMLCDomFactory domFactory, MetaData metaData, ErrorReporter errorReporter, ParseTracer tracer)
          Parse a XML file (or any file, such as HTML, that can be converted into XML).
 void processingInstruction(int target, int data)
          Handle processing instruction.
 InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
          Resolve an entity.
 void startCDATA()
          Handle start of CDATA section.
 void startDocument()
          Handle start of document.
 void startDTD(QName rootElement, int publicId, int systemId)
          callback for the start of the DTD This function will be called when a <!DOCTYPE...> declaration is encountered.
 void startElement(QName element, XMLAttrList attrList, int attrListHandle)
          Handle start of element.
 void startEntityReference(int entityName, int entityType, int entityContext)
          Handle the start of an entity reference.
 void startNamespaceDeclScope(int prefix, int uri)
          Handle start of a namespace declaration scope.
 void textDecl(int version, int encoding)
          Signal the Text declaration of an external entity.
 void unparsedEntityDecl(int entityName, int publicId, int systemId, int notationName)
          
 void xmlDecl(int version, int encoding, int standalone)
          Signal the XML declaration of a document
 
Methods inherited from class org.apache.xerces.framework.XMLParser
addRecognizer, getAllowJavaEncodings, getContinueAfterFatalError, getEntityResolver, getErrorHandler, getExternalGeneralEntities, getExternalParameterEntities, getFeature, getFeaturesRecognized, getfgDatatypeMessages, getfgImplementationMessages, getfgSchemaMessages, getfgXMLMessages, getfLocale, getLoadDTDGrammar, getLoadExternalDTD, getLocator, getNamespaces, getNormalizeContents, getPropertiesRecognized, getProperty, getValidation, getValidationDynamic, getValidationSchema, getValidationSchemaFullChecking, getValidationWarnOnDuplicateAttdef, getValidationWarnOnUndeclaredElemdef, getXMLString, initHandlers, isFeatureRecognized, isPropertyRecognized, parse, parse, parseSome, parseSomeSetup, reportError, reset, resetOrCopy, setAllowJavaEncodings, setContinueAfterFatalError, setEntityResolver, setErrorHandler, setExternalGeneralEntities, setExternalNoNamespaceSchemaLocation, setExternalParameterEntities, setExternalSchemaLocation, setFeature, setLoadDTDGrammar, setLoadExternalDTD, setLocale, setNamespaces, setNormalizeAttributeValues, setNormalizeContents, setProperty, setReaderFactory, setValidation, setValidationDynamic, setValidationSchema, setValidationSchemaFullChecking, setValidationWarnOnDuplicateAttdef, setValidationWarnOnUndeclaredElemdef
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XercesParser

public XercesParser()
Method Detail

parse

public XMLCDocument parse(InputSource input,
                          LineNumberMap lineNumberMap,
                          XMLCDomFactory domFactory,
                          MetaData metaData,
                          ErrorReporter errorReporter,
                          ParseTracer tracer)
                   throws java.io.IOException,
                          XMLCException,
                          SAXException
Description copied from interface: XMLCParser
Parse a XML file (or any file, such as HTML, that can be converted into XML).

Specified by:
parse in interface XMLCParser
Parameters:
input - The input source to parse.
lineNumberMap - If not null, a dynamic map of input stream line numbers and offsets to source files and line numbers. This object is dynamically updated as input is read. It may not have valid mappings for characeters that have not been read.
domFactory - The DOM factory object.
metaData - MetaData for the document.
errorReporter - Object for reporting errors during the parse.
tracer - Object for parser info tracing.
Returns:
A XMLC document object that contains the actual DOM Document.
Throws:
XMLCException - Thrown for fatal errors found parsing the document.
java.io.IOException
SAXException
See Also:
XMLCParser

resolveEntity

public InputSource resolveEntity(java.lang.String publicId,
                                 java.lang.String systemId)
                          throws SAXException,
                                 java.io.IOException
Resolve an entity.

Specified by:
resolveEntity in interface EntityResolver
Parameters:
publicId - The public identifier of the external entity being referenced, or null if none was supplied.
systemId - The system identifier of the external entity being referenced.
Returns:
An InputSource object describing the new input source, or null to request that the parser open a regular URI connection to the system identifier.
Throws:
java.io.IOException - A Java-specific IO exception, possibly the result of creating a new InputStream or Reader for the InputSource.
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
EntityResolver.resolveEntity(java.lang.String, java.lang.String)

startDocument

public void startDocument()
                   throws java.lang.Exception
Handle start of document.

Specified by:
startDocument in interface XMLDocumentHandler
Throws:
java.lang.Exception
See Also:
XMLDocumentHandler.startDocument()

endDocument

public void endDocument()
                 throws java.lang.Exception
Handle end document.

Specified by:
endDocument in interface XMLDocumentHandler
Throws:
java.lang.Exception
See Also:
XMLDocumentHandler.endDocument()

xmlDecl

public void xmlDecl(int version,
                    int encoding,
                    int standalone)
             throws java.lang.Exception
Description copied from interface: XMLDocumentHandler
Signal the XML declaration of a document

Specified by:
xmlDecl in interface XMLDocumentHandler
Parameters:
version - the handle in the string pool for the version number
encoding - the handle in the string pool for the encoding
Throws:
java.lang.Exception
See Also:
XMLDocumentHandler.xmlDecl(int, int, int)

textDecl

public void textDecl(int version,
                     int encoding)
              throws java.lang.Exception
Description copied from interface: XMLDocumentHandler
Signal the Text declaration of an external entity.

Specified by:
textDecl in interface XMLDocumentHandler
Throws:
java.lang.Exception
See Also:
XMLDocumentHandler.textDecl(int, int), XMLDocumentHandler.DTDHandler#textDecl

startNamespaceDeclScope

public void startNamespaceDeclScope(int prefix,
                                    int uri)
                             throws java.lang.Exception
Handle start of a namespace declaration scope.

Specified by:
startNamespaceDeclScope in interface XMLDocumentHandler
Parameters:
prefix - string pool index of the namespace prefix being declared
uri - string pool index of the namespace uri begin bound
java.lang.Exception
See Also:
XMLDocumentHandler.startNamespaceDeclScope(int, int)

endNamespaceDeclScope

public void endNamespaceDeclScope(int prefix)
                           throws java.lang.Exception
Handle end of a namespace declaration scope.

Specified by:
endNamespaceDeclScope in interface XMLDocumentHandler
Parameters:
prefix - string pool index of the namespace prefix being declared
Throws:
java.lang.Exception
See Also:
XMLDocumentHandler.startNamespaceDeclScope(int, int)

startElement

public void startElement(QName element,
                         XMLAttrList attrList,
                         int attrListHandle)
                  throws java.lang.Exception
Handle start of element.

Specified by:
startElement in interface XMLDocumentHandler
Parameters:
attrList - attrList containing the attributes of the element
attrListHandle - handle into attrList. Allows attributes to be retreived.
Throws:
java.lang.Exception
See Also:
XMLDocumentHandler.startElement(org.apache.xerces.utils.QName, org.apache.xerces.framework.XMLAttrList, int)

endElement

public void endElement(QName element)
                throws java.lang.Exception
Handle end element.

Specified by:
endElement in interface XMLDocumentHandler
Throws:
java.lang.Exception
See Also:
XMLDocumentHandler.endElement(org.apache.xerces.utils.QName)

startEntityReference

public void startEntityReference(int entityName,
                                 int entityType,
                                 int entityContext)
                          throws java.lang.Exception
Handle the start of an entity reference. If it's is one of the standard character entity references, we don't push the create the node, we just let the child be appended directly in its place.

Specified by:
startEntityReference in interface XMLDocumentHandler
Parameters:
entityName - string pool index of the entity name
entityType - the XMLEntityHandler.ENTITYTYPE_* type
entityContext - the XMLEntityHandler.ENTITYREF_* type for where the entity reference appears
Throws:
java.lang.Exception
See Also:
XMLDocumentHandler.startEntityReference(int, int, int)

endEntityReference

public void endEntityReference(int entityName,
                               int entityType,
                               int entityContext)
                        throws java.lang.Exception
Handle the end of an entity reference.

Specified by:
endEntityReference in interface XMLDocumentHandler
Parameters:
entityName - string pool index of the entity anem
entityType - the XMLEntityHandler.ENTITYTYPE_* type
entityContext - the XMLEntityHandler.ENTITYREF_* type for where the entity reference appears
Throws:
java.lang.Exception
See Also:
XMLDocumentHandler.endEntityReference(int, int, int)

characters

public void characters(int data)
                throws java.lang.Exception
Not used.

Specified by:
characters in interface XMLDocumentHandler
Parameters:
data - string pool index of the characters that were scanned
Throws:
java.lang.Exception
See Also:
XMLDocumentHandler.characters(int)

ignorableWhitespace

public void ignorableWhitespace(int data)
                         throws java.lang.Exception
Not used.

Specified by:
ignorableWhitespace in interface XMLDocumentHandler
Parameters:
data - string pool index of ignorable whitespace
Throws:
java.lang.Exception
See Also:
XMLDocumentHandler.ignorableWhitespace(int)

startCDATA

public void startCDATA()
Handle start of CDATA section.

Specified by:
startCDATA in interface XMLDocumentHandler
See Also:
XMLDocumentHandler.startCDATA()

endCDATA

public void endCDATA()
Handle for end of CDATA section.

Specified by:
endCDATA in interface XMLDocumentHandler
See Also:
XMLDocumentHandler.endCDATA()

processingInstruction

public void processingInstruction(int target,
                                  int data)
                           throws java.lang.Exception
Handle processing instruction.

Specified by:
processingInstruction in interface XMLDocumentHandler
Parameters:
target - string pool index of the PI target
data - string pool index of the PI data
Throws:
java.lang.Exception
See Also:
XMLDocumentHandler.processingInstruction(int, int), XMLDocumentHandler.DTDHandler#processingInstruction

comment

public void comment(int comment)
             throws java.lang.Exception
Handle a comment.

Specified by:
comment in interface XMLDocumentHandler
Parameters:
comment - string pool index of the comment text
Throws:
java.lang.Exception
See Also:
XMLDocumentHandler.comment(int)

characters

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

Specified by:
characters in interface XMLDocumentHandler
Parameters:
ch - character array containing the characters that were scanned
start - offset in ch where scanned characters begin
length - length of scanned characters in ch
Throws:
java.lang.Exception
See Also:
XMLDocumentHandler.characters(int)

ignorableWhitespace

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

Specified by:
ignorableWhitespace in interface XMLDocumentHandler
Parameters:
ch - character array containing the whitespace that was scanned
start - offset in ch where scanned whitespace begins
length - length of scanned whitespace in ch
Throws:
java.lang.Exception
See Also:
XMLDocumentHandler.ignorableWhitespace(int)

startDTD

public void startDTD(QName rootElement,
                     int publicId,
                     int systemId)
Description copied from interface: XMLDocumentHandler.DTDHandler
callback for the start of the DTD This function will be called when a <!DOCTYPE...> declaration is encountered.

Specified by:
startDTD in interface XMLDocumentHandler.DTDHandler
Parameters:
publicId - string pool index of the DTD's public ID
systemId - string pool index of the DTD's system ID
See Also:
XMLDocumentHandler.DTDHandler#startDTD

internalSubset

public void internalSubset(int internalSubset)
Description copied from interface: XMLDocumentHandler.DTDHandler
Supports DOM Level 2 internalSubset additions. Called when the internal subset is completely scanned.

Specified by:
internalSubset in interface XMLDocumentHandler.DTDHandler
See Also:
XMLDocumentHandler.DTDHandler#internalSubset

endDTD

public void endDTD()
Description copied from interface: XMLDocumentHandler.DTDHandler
callback for the end of the DTD This function will be called at the end of the DTD.

Specified by:
endDTD in interface XMLDocumentHandler.DTDHandler
See Also:
XMLDocumentHandler.DTDHandler#endDTD

elementDecl

public void elementDecl(QName elementDecl,
                        int contentSpecType,
                        int contentSpecIndex,
                        XMLContentSpec.Provider contentSpecProvider)
                 throws java.lang.Exception

Specified by:
elementDecl in interface XMLDocumentHandler.DTDHandler
Throws:
java.lang.Exception
See Also:
XMLDocumentHandler.DTDHandler#elementDecl

attlistDecl

public void attlistDecl(QName elementDecl,
                        QName attributeDecl,
                        int attType,
                        boolean attList,
                        java.lang.String enumString,
                        int attDefaultType,
                        int attDefaultValue)
                 throws java.lang.Exception

Specified by:
attlistDecl in interface XMLDocumentHandler.DTDHandler
Parameters:
attType - type of attribute
enumString - String representing the values of the enumeration, if the attribute is of enumerated type, or null if it is not.
attDefaultType - an integer value denoting the DefaultDecl value
attDefaultValue - string pool index of this attribute's default value or -1 if there is no defaultvalue
Throws:
java.lang.Exception
See Also:
XMLDocumentHandler.DTDHandler#attlistDecl

internalPEDecl

public void internalPEDecl(int entityName,
                           int entityValue)

Specified by:
internalPEDecl in interface XMLDocumentHandler.DTDHandler
Parameters:
entityName - string pool index of the entity name
entityValue - string pool index of the entity replacement text
See Also:
XMLDocumentHandler.DTDHandler#internalPEDecl

externalPEDecl

public void externalPEDecl(int entityName,
                           int publicId,
                           int systemId)

Specified by:
externalPEDecl in interface XMLDocumentHandler.DTDHandler
Parameters:
entityName - string pool index of the entity name
publicId - string pool index of the entity's public id.
systemId - string pool index of the entity's system id.
See Also:
XMLDocumentHandler.DTDHandler#externalPEDecl

internalEntityDecl

public void internalEntityDecl(int entityName,
                               int entityValue)

Specified by:
internalEntityDecl in interface XMLDocumentHandler.DTDHandler
Parameters:
entityName - string pool index of the entity name
entityValue - string pool index of the entity replacement text
See Also:
XMLDocumentHandler.DTDHandler#internalEntityDecl

externalEntityDecl

public void externalEntityDecl(int entityName,
                               int publicId,
                               int systemId)

Specified by:
externalEntityDecl in interface XMLDocumentHandler.DTDHandler
Parameters:
entityName - string pool index of the entity name
publicId - string pool index of the entity's public id.
systemId - string pool index of the entity's system id.
See Also:
XMLDocumentHandler.DTDHandler#externalEntityDecl

unparsedEntityDecl

public void unparsedEntityDecl(int entityName,
                               int publicId,
                               int systemId,
                               int notationName)

Specified by:
unparsedEntityDecl in interface XMLDocumentHandler.DTDHandler
Parameters:
entityName - string pool index of the entity name
publicId - string pool index of the entity's public id.
systemId - string pool index of the entity's system id.
notationName - string pool index of the notation name.
See Also:
XMLDocumentHandler.DTDHandler#unparsedEntityDecl

notationDecl

public void notationDecl(int notationName,
                         int publicId,
                         int systemId)

Specified by:
notationDecl in interface XMLDocumentHandler.DTDHandler
Parameters:
notationName - string pool index of the notation name
publicId - string pool index of the notation's public id.
systemId - string pool index of the notation's system id.
See Also:
XMLDocumentHandler.DTDHandler#notationDecl

Enhydra 5.1 API