uk.co.wilson.xml
Class MinML

java.lang.Object
  extended by uk.co.wilson.xml.MinML
All Implemented Interfaces:
DocumentHandler, ErrorHandler, Locator, Parser

public class MinML
extends java.lang.Object
implements Parser, Locator, DocumentHandler, ErrorHandler


Field Summary
static int change
           
static int decLevel
           
static int discardAndChange
           
static int discardSaveAndChange
           
static int emitCharacters
           
static int emitCharactersSave
           
static int emitEndElement
           
static int emitStartElement
           
static int endCDATA
           
static int endComment
           
static int endStartName
           
static int exitParser
           
static int inAttribute
           
static int inAttribute1
           
static int inAttributeQuotesValue
           
static int inAttributeQuoteValue
           
static int inAttributeValue
           
static int inCDATA
           
static int inCDATA1
           
static int inCharData
           
static int incLevel
           
static int inComment
           
static int inDTD
           
static int inETag
           
static int inETag1
           
static int inMTTag
           
static int inNextAttribute
           
static int inPI
           
static int inPI1
           
static int inPossiblyAttribute
           
static int inPossiblySkipping
           
static int inSkipping
           
static int inSTag
           
static int inTag
           
static int inTag1
           
static int parseError
           
static int possiblyEmitCharacters
           
static int processCharRef
           
static int saveAndChange
           
static int saveAttributeName
           
static int saveAttributeValue
           
static int startCDATA
           
static int startComment
           
static int writeCdata
           
 
Constructor Summary
MinML()
           
MinML(int initialBufferSize, int bufferIncrement)
           
 
Method Summary
 void characters(char[] ch, int start, int length)
          Receive notification of character data.
 void endDocument()
          Receive notification of the end of a document.
 void endElement(java.lang.String name)
          Receive notification of the end of an element.
 void error(SAXParseException e)
          Receive notification of a recoverable error.
 void fatalError(SAXParseException e)
          Receive notification of a non-recoverable error.
 int getColumnNumber()
          Return the column number where the current document event ends.
 int getLineNumber()
          Return the line number where the current document event ends.
 java.lang.String getPublicId()
          Return the public identifier for the current document event.
 java.lang.String getSystemId()
          Return the system identifier for the current document event.
 void ignorableWhitespace(char[] ch, int start, int length)
          Receive notification of ignorable whitespace in element content.
 void parse(InputSource source)
          Parse an XML document.
 void parse(java.io.Reader in)
           
 void parse(java.lang.String systemId)
          Parse an XML document from a system identifier (URI).
 void processingInstruction(java.lang.String target, java.lang.String data)
          Receive notification of a processing instruction.
 void setDocumentHandler(DocumentHandler handler)
          Allow an application to register a document event handler.
 void setDocumentHandler(DocumentHandler handler)
           
 void setDocumentLocator(Locator locator)
          Receive an object for locating the origin of SAX document events.
 void setDTDHandler(DTDHandler handler)
          Allow an application to register a DTD event handler.
 void setEntityResolver(EntityResolver resolver)
          Allow an application to register a custom entity resolver.
 void setErrorHandler(ErrorHandler handler)
          Allow an application to register an error event handler.
 void setLocale(java.util.Locale locale)
          Allow an application to request a locale for errors and warnings.
 void startDocument()
          Receive notification of the beginning of a document.
 java.io.Writer startDocument(java.io.Writer writer)
           
 void startElement(java.lang.String name, AttributeList attributes)
          Receive notification of the beginning of an element.
 java.io.Writer startElement(java.lang.String name, AttributeList attributes, java.io.Writer writer)
           
 void warning(SAXParseException e)
          Receive notification of a warning.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

endStartName

public static final int endStartName
See Also:
Constant Field Values

emitStartElement

public static final int emitStartElement
See Also:
Constant Field Values

emitEndElement

public static final int emitEndElement
See Also:
Constant Field Values

possiblyEmitCharacters

public static final int possiblyEmitCharacters
See Also:
Constant Field Values

emitCharacters

public static final int emitCharacters
See Also:
Constant Field Values

emitCharactersSave

public static final int emitCharactersSave
See Also:
Constant Field Values

saveAttributeName

public static final int saveAttributeName
See Also:
Constant Field Values

saveAttributeValue

public static final int saveAttributeValue
See Also:
Constant Field Values

startComment

public static final int startComment
See Also:
Constant Field Values

endComment

public static final int endComment
See Also:
Constant Field Values

incLevel

public static final int incLevel
See Also:
Constant Field Values

decLevel

public static final int decLevel
See Also:
Constant Field Values

startCDATA

public static final int startCDATA
See Also:
Constant Field Values

endCDATA

public static final int endCDATA
See Also:
Constant Field Values

processCharRef

public static final int processCharRef
See Also:
Constant Field Values

writeCdata

public static final int writeCdata
See Also:
Constant Field Values

exitParser

public static final int exitParser
See Also:
Constant Field Values

parseError

public static final int parseError
See Also:
Constant Field Values

discardAndChange

public static final int discardAndChange
See Also:
Constant Field Values

discardSaveAndChange

public static final int discardSaveAndChange
See Also:
Constant Field Values

saveAndChange

public static final int saveAndChange
See Also:
Constant Field Values

change

public static final int change
See Also:
Constant Field Values

inSkipping

public static final int inSkipping
See Also:
Constant Field Values

inSTag

public static final int inSTag
See Also:
Constant Field Values

inPossiblyAttribute

public static final int inPossiblyAttribute
See Also:
Constant Field Values

inNextAttribute

public static final int inNextAttribute
See Also:
Constant Field Values

inAttribute

public static final int inAttribute
See Also:
Constant Field Values

inAttribute1

public static final int inAttribute1
See Also:
Constant Field Values

inAttributeValue

public static final int inAttributeValue
See Also:
Constant Field Values

inAttributeQuoteValue

public static final int inAttributeQuoteValue
See Also:
Constant Field Values

inAttributeQuotesValue

public static final int inAttributeQuotesValue
See Also:
Constant Field Values

inETag

public static final int inETag
See Also:
Constant Field Values

inETag1

public static final int inETag1
See Also:
Constant Field Values

inMTTag

public static final int inMTTag
See Also:
Constant Field Values

inTag

public static final int inTag
See Also:
Constant Field Values

inTag1

public static final int inTag1
See Also:
Constant Field Values

inPI

public static final int inPI
See Also:
Constant Field Values

inPI1

public static final int inPI1
See Also:
Constant Field Values

inPossiblySkipping

public static final int inPossiblySkipping
See Also:
Constant Field Values

inCharData

public static final int inCharData
See Also:
Constant Field Values

inCDATA

public static final int inCDATA
See Also:
Constant Field Values

inCDATA1

public static final int inCDATA1
See Also:
Constant Field Values

inComment

public static final int inComment
See Also:
Constant Field Values

inDTD

public static final int inDTD
See Also:
Constant Field Values
Constructor Detail

MinML

public MinML(int initialBufferSize,
             int bufferIncrement)

MinML

public MinML()
Method Detail

parse

public void parse(java.io.Reader in)
           throws SAXException,
                  java.io.IOException
Throws:
SAXException
java.io.IOException

parse

public void parse(InputSource source)
           throws SAXException,
                  java.io.IOException
Description copied from interface: Parser
Parse an XML document.

The application can use this method to instruct the SAX parser to begin parsing an XML document from any valid input source (a character stream, a byte stream, or a URI).

Applications may not invoke this method while a parse is in progress (they should create a new Parser instead for each additional XML document). Once a parse is complete, an application may reuse the same Parser object, possibly with a different input source.

Specified by:
parse in interface Parser
Parameters:
source - The input source for the top-level of the XML document.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
java.io.IOException - An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
See Also:
InputSource, Parser.parse(java.lang.String), Parser.setEntityResolver(org.xml.sax.EntityResolver), Parser.setDTDHandler(org.xml.sax.DTDHandler), Parser.setDocumentHandler(org.xml.sax.DocumentHandler), Parser.setErrorHandler(org.xml.sax.ErrorHandler)

parse

public void parse(java.lang.String systemId)
           throws SAXException,
                  java.io.IOException
Description copied from interface: Parser
Parse an XML document from a system identifier (URI).

This method is a shortcut for the common case of reading a document from a system identifier. It is the exact equivalent of the following:

 parse(new InputSource(systemId));
 

If the system identifier is a URL, it must be fully resolved by the application before it is passed to the parser.

Specified by:
parse in interface Parser
Parameters:
systemId - The system identifier (URI).
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
java.io.IOException - An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
See Also:
Parser.parse(org.xml.sax.InputSource)

setLocale

public void setLocale(java.util.Locale locale)
               throws SAXException
Description copied from interface: Parser
Allow an application to request a locale for errors and warnings.

SAX parsers are not required to provide localisation for errors and warnings; if they cannot support the requested locale, however, they must throw a SAX exception. Applications may not request a locale change in the middle of a parse.

Specified by:
setLocale in interface Parser
Parameters:
locale - A Java Locale object.
Throws:
SAXException - Throws an exception (using the previous or default locale) if the requested locale is not supported.
See Also:
SAXException, SAXParseException

setEntityResolver

public void setEntityResolver(EntityResolver resolver)
Description copied from interface: Parser
Allow an application to register a custom entity resolver.

If the application does not register an entity resolver, the SAX parser will resolve system identifiers and open connections to entities itself (this is the default behaviour implemented in HandlerBase).

Applications may register a new or different entity resolver in the middle of a parse, and the SAX parser must begin using the new resolver immediately.

Specified by:
setEntityResolver in interface Parser
Parameters:
resolver - The object for resolving entities.
See Also:
EntityResolver, HandlerBase

setDTDHandler

public void setDTDHandler(DTDHandler handler)
Description copied from interface: Parser
Allow an application to register a DTD event handler.

If the application does not register a DTD handler, all DTD events reported by the SAX parser will be silently ignored (this is the default behaviour implemented by HandlerBase).

Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.

Specified by:
setDTDHandler in interface Parser
Parameters:
handler - The DTD handler.
See Also:
DTDHandler, HandlerBase

setDocumentHandler

public void setDocumentHandler(DocumentHandler handler)
Description copied from interface: Parser
Allow an application to register a document event handler.

If the application does not register a document handler, all document events reported by the SAX parser will be silently ignored (this is the default behaviour implemented by HandlerBase).

Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.

Specified by:
setDocumentHandler in interface Parser
Parameters:
handler - The document handler.
See Also:
DocumentHandler, HandlerBase

setDocumentHandler

public void setDocumentHandler(DocumentHandler handler)

setErrorHandler

public void setErrorHandler(ErrorHandler handler)
Description copied from interface: Parser
Allow an application to register an error event handler.

If the application does not register an error event handler, all error events reported by the SAX parser will be silently ignored, except for fatalError, which will throw a SAXException (this is the default behaviour implemented by HandlerBase).

Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.

Specified by:
setErrorHandler in interface Parser
Parameters:
handler - The error handler.
See Also:
ErrorHandler, SAXException, HandlerBase

setDocumentLocator

public void setDocumentLocator(Locator locator)
Description copied from interface: DocumentHandler
Receive an object for locating the origin of SAX document events.

SAX parsers are strongly encouraged (though not absolutely required) to supply a locator: if it does so, it must supply the locator to the application by invoking this method before invoking any of the other methods in the DocumentHandler interface.

The locator allows the application to determine the end position of any document-related event, even if the parser is not reporting an error. Typically, the application will use this information for reporting its own errors (such as character content that does not match an application's business rules). The information returned by the locator is probably not sufficient for use with a search engine.

Note that the locator will return correct information only during the invocation of the events in this interface. The application should not attempt to use it at any other time.

Specified by:
setDocumentLocator in interface DocumentHandler
Parameters:
locator - An object that can return the location of any SAX document event.
See Also:
Locator

startDocument

public void startDocument()
                   throws SAXException
Description copied from interface: DocumentHandler
Receive notification of the beginning of a document.

The SAX parser will invoke this method only once, before any other methods in this interface or in DTDHandler (except for setDocumentLocator).

Specified by:
startDocument in interface DocumentHandler
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.

startDocument

public java.io.Writer startDocument(java.io.Writer writer)
                             throws SAXException
Throws:
SAXException

endDocument

public void endDocument()
                 throws SAXException
Description copied from interface: DocumentHandler
Receive notification of the end of a document.

The SAX parser will invoke this method only once, and it will be the last method invoked during the parse. The parser shall not invoke this method until it has either abandoned parsing (because of an unrecoverable error) or reached the end of input.

Specified by:
endDocument in interface DocumentHandler
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.

startElement

public void startElement(java.lang.String name,
                         AttributeList attributes)
                  throws SAXException
Description copied from interface: DocumentHandler
Receive notification of the beginning of an element.

The Parser will invoke this method at the beginning of every element in the XML document; there will be a corresponding endElement() event for every startElement() event (even when the element is empty). All of the element's content will be reported, in order, before the corresponding endElement() event.

If the element name has a namespace prefix, the prefix will still be attached. Note that the attribute list provided will contain only attributes with explicit values (specified or defaulted): #IMPLIED attributes will be omitted.

Specified by:
startElement in interface DocumentHandler
Parameters:
name - The element type name.
attributes - The attributes attached to the element, if any.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
DocumentHandler.endElement(java.lang.String), AttributeList

startElement

public java.io.Writer startElement(java.lang.String name,
                                   AttributeList attributes,
                                   java.io.Writer writer)
                            throws SAXException
Throws:
SAXException

endElement

public void endElement(java.lang.String name)
                throws SAXException
Description copied from interface: DocumentHandler
Receive notification of the end of an element.

The SAX parser will invoke this method at the end of every element in the XML document; there will be a corresponding startElement() event for every endElement() event (even when the element is empty).

If the element name has a namespace prefix, the prefix will still be attached to the name.

Specified by:
endElement in interface DocumentHandler
Parameters:
name - The element type name
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Description copied from interface: DocumentHandler
Receive notification of character data.

The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.

The application must not attempt to read from the array outside of the specified range.

Note that some parsers will report whitespace using the ignorableWhitespace() method rather than this one (validating parsers must do so).

Specified by:
characters in interface DocumentHandler
Parameters:
ch - The characters from the XML document.
start - The start position in the array.
length - The number of characters to read from the array.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
DocumentHandler.ignorableWhitespace(char[], int, int), Locator

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws SAXException
Description copied from interface: DocumentHandler
Receive notification of ignorable whitespace in element content.

Validating Parsers must use this method to report each chunk of ignorable whitespace (see the W3C XML 1.0 recommendation, section 2.10): non-validating parsers may also use this method if they are capable of parsing and using content models.

SAX parsers may return all contiguous whitespace in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.

The application must not attempt to read from the array outside of the specified range.

Specified by:
ignorableWhitespace in interface DocumentHandler
Parameters:
ch - The characters from the XML document.
start - The start position in the array.
length - The number of characters to read from the array.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
DocumentHandler.characters(char[], int, int)

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws SAXException
Description copied from interface: DocumentHandler
Receive notification of a processing instruction.

The Parser will invoke this method once for each processing instruction found: note that processing instructions may occur before or after the main document element.

A SAX parser should never report an XML declaration (XML 1.0, section 2.8) or a text declaration (XML 1.0, section 4.3.1) using this method.

Specified by:
processingInstruction in interface DocumentHandler
Parameters:
target - The processing instruction target.
data - The processing instruction data, or null if none was supplied.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.

warning

public void warning(SAXParseException e)
             throws SAXException
Description copied from interface: ErrorHandler
Receive notification of a warning.

SAX parsers will use this method to report conditions that are not errors or fatal errors as defined by the XML 1.0 recommendation. The default behaviour is to take no action.

The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end.

Specified by:
warning in interface ErrorHandler
Parameters:
e - The warning information encapsulated in a SAX parse exception.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
SAXParseException

error

public void error(SAXParseException e)
           throws SAXException
Description copied from interface: ErrorHandler
Receive notification of a recoverable error.

This corresponds to the definition of "error" in section 1.2 of the W3C XML 1.0 Recommendation. For example, a validating parser would use this callback to report the violation of a validity constraint. The default behaviour is to take no action.

The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end. If the application cannot do so, then the parser should report a fatal error even if the XML 1.0 recommendation does not require it to do so.

Specified by:
error in interface ErrorHandler
Parameters:
e - The error information encapsulated in a SAX parse exception.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
SAXParseException

fatalError

public void fatalError(SAXParseException e)
                throws SAXException
Description copied from interface: ErrorHandler
Receive notification of a non-recoverable error.

This corresponds to the definition of "fatal error" in section 1.2 of the W3C XML 1.0 Recommendation. For example, a parser would use this callback to report the violation of a well-formedness constraint.

The application must assume that the document is unusable after the parser has invoked this method, and should continue (if at all) only for the sake of collecting addition error messages: in fact, SAX parsers are free to stop reporting any other events once this method has been invoked.

Specified by:
fatalError in interface ErrorHandler
Parameters:
e - The error information encapsulated in a SAX parse exception.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
SAXParseException

getPublicId

public java.lang.String getPublicId()
Description copied from interface: Locator
Return the public identifier for the current document event.

This will be the public identifier

Specified by:
getPublicId in interface Locator
Returns:
A string containing the public identifier, or null if none is available.
See Also:
Locator.getSystemId()

getSystemId

public java.lang.String getSystemId()
Description copied from interface: Locator
Return the system identifier for the current document event.

If the system identifier is a URL, the parser must resolve it fully before passing it to the application.

Specified by:
getSystemId in interface Locator
Returns:
A string containing the system identifier, or null if none is available.
See Also:
Locator.getPublicId()

getLineNumber

public int getLineNumber()
Description copied from interface: Locator
Return the line number where the current document event ends. Note that this is the line position of the first character after the text associated with the document event.

Specified by:
getLineNumber in interface Locator
Returns:
The line number, or -1 if none is available.
See Also:
Locator.getColumnNumber()

getColumnNumber

public int getColumnNumber()
Description copied from interface: Locator
Return the column number where the current document event ends. Note that this is the column number of the first character after the text associated with the document event. The first column in a line is position 1.

Specified by:
getColumnNumber in interface Locator
Returns:
The column number, or -1 if none is available.
See Also:
Locator.getLineNumber()


Copyright 2001-2001-2005 Apache Software Foundation. All Rights Reserved.