Piccolo is a small, high-performance SAX1 and SAX2 XML parser.
As per the SAX2 specification, namespace handling is on by
default. You can improve performance by turning it off.
Note that if used in SAX1 mode, namespace handling is
automatically turned off.
ANY
public static final short ANY
ATTLIST_START
public static final short ATTLIST_START
CDATA
public static final short CDATA
CLOSE_TAG
public static final short CLOSE_TAG
COMMA
public static final short COMMA
COMMENT
public static final short COMMENT
CONDITIONAL_START
public static final short CONDITIONAL_START
DOUBLE_RBRACKET_END
public static final short DOUBLE_RBRACKET_END
DTD_START
public static final short DTD_START
DTD_START_SKIPEXTERNAL
public static final short DTD_START_SKIPEXTERNAL
ELEMENT_DECL_START
public static final short ELEMENT_DECL_START
EMPTY
public static final short EMPTY
EMPTY_TAG
public static final short EMPTY_TAG
ENTITIES
public static final short ENTITIES
ENTITY
public static final short ENTITY
ENTITY_DECL_START
public static final short ENTITY_DECL_START
ENTITY_END
public static final short ENTITY_END
ENTITY_REF
public static final short ENTITY_REF
ENUMERATION
public static final short ENUMERATION
EQ
public static final short EQ
EXTERNAL_ENTITY_REF
public static final short EXTERNAL_ENTITY_REF
FIXED
public static final short FIXED
ID
public static final short ID
IDREF
public static final short IDREF
IDREFS
public static final short IDREFS
IGNORE
public static final short IGNORE
IGNORED_CONDITIONAL_START
public static final short IGNORED_CONDITIONAL_START
IMPLIED
public static final short IMPLIED
INCLUDE
public static final short INCLUDE
INTERNAL_ENTITY_REF
public static final short INTERNAL_ENTITY_REF
LBRACKET
public static final short LBRACKET
LPAREN
public static final short LPAREN
MODIFIER
public static final short MODIFIER
NAME
public static final short NAME
NDATA
public static final short NDATA
NMTOKEN
public static final short NMTOKEN
NMTOKENS
public static final short NMTOKENS
NOTATION
public static final short NOTATION
NOTATION_START
public static final short NOTATION_START
OPEN_TAG
public static final short OPEN_TAG
PCDATA
public static final short PCDATA
PERCENT
public static final short PERCENT
PI
public static final short PI
PIPE
public static final short PIPE
PLUS
public static final short PLUS
PREFIXED_NAME
public static final short PREFIXED_NAME
PUBLIC
public static final short PUBLIC
QUESTION
public static final short QUESTION
RBRACKET_END
public static final short RBRACKET_END
REQUIRED
public static final short REQUIRED
RPAREN
public static final short RPAREN
SKIPPED_ENTITY_REF
public static final short SKIPPED_ENTITY_REF
STAR
public static final short STAR
STRING
public static final short STRING
SYSTEM
public static final short SYSTEM
TAG_END
public static final short TAG_END
UNPREFIXED_NAME
public static final short UNPREFIXED_NAME
WHITESPACE
public static final short WHITESPACE
XML_DOC_DECL
public static final short XML_DOC_DECL
XML_DOC_OR_TEXT_DECL
public static final short XML_DOC_OR_TEXT_DECL
XML_TEXT_DECL
public static final short XML_TEXT_DECL
YYERRCODE
public static final short YYERRCODE
getColumnNumber
public int getColumnNumber()
Return the column number where the current document event ends.
This is one-based number of Java
char
values since
the last line end.
Warning: The return value from the method
is intended only as an approximation for the sake of diagnostics;
it is not intended to provide sufficient information
to edit the character content of the original XML document.
For example, when lines contain combining character sequences, wide
characters, surrogate pairs, or bi-directional text, the value may
not correspond to the column in a text editor's display.
The return value is an approximation of the column number
in the document entity or external parsed entity where the
markup triggering the event appears.
If possible, the SAX driver should provide the line position
of the first character after the text associated with the document
event. The first column in each line is column 1.
- getColumnNumber in interface Locator
- The column number, or -1 if none is available.
getDTDHandler
public DTDHandler getDTDHandler()
Return the current DTD handler.
- getDTDHandler in interface XMLReader
- The current DTD handler, or null if none
has been registered.
getEncoding
public String getEncoding()
getEntityResolver
public EntityResolver getEntityResolver()
Return the current entity resolver.
- getEntityResolver in interface XMLReader
- The current entity resolver, or null if none
has been registered.
getErrorHandler
public ErrorHandler getErrorHandler()
Return the current error handler.
- getErrorHandler in interface XMLReader
- The current error handler, or null if none
has been registered.
getFeature
public boolean getFeature(String name)
throws SAXNotSupportedException,
SAXNotRecognizedException
Look up the value of a feature flag.
The feature name is any fully-qualified URI. It is
possible for an XMLReader to recognize a feature name but
temporarily be unable to return its value.
Some feature values may be available only in specific
contexts, such as before, during, or after a parse.
Also, some feature values may not be programmatically accessible.
(In the case of an adapter for SAX1
Parser
, there is no
implementation-independent way to expose whether the underlying
parser is performing validation, expanding external entities,
and so forth.)
All XMLReaders are required to recognize the
http://xml.org/sax/features/namespaces and the
http://xml.org/sax/features/namespace-prefixes feature names.
Typical usage is something like this:
XMLReader r = new MySAXDriver();
// try to activate validation
try {
r.setFeature("http://xml.org/sax/features/validation", true);
} catch (SAXException e) {
System.err.println("Cannot activate validation.");
}
// register event handlers
r.setContentHandler(new MyContentHandler());
r.setErrorHandler(new MyErrorHandler());
// parse the first document
try {
r.parse("http://www.foo.com/mydoc.xml");
} catch (IOException e) {
System.err.println("I/O exception reading XML document");
} catch (SAXException e) {
System.err.println("XML exception reading document.");
}
Implementors are free (and encouraged) to invent their own features,
using names built on their own URIs.
- getFeature in interface XMLReader
name
- The feature name, which is a fully-qualified URI.
- The current value of the feature (true or false).
getLineNumber
public int getLineNumber()
Return the line number where the current document event ends.
Lines are delimited by line ends, which are defined in
the XML specification.
Warning: The return value from the method
is intended only as an approximation for the sake of diagnostics;
it is not intended to provide sufficient information
to edit the character content of the original XML document.
In some cases, these "line" numbers match what would be displayed
as columns, and in others they may not match the source text
due to internal entity expansion.
The return value is an approximation of the line number
in the document entity or external parsed entity where the
markup triggering the event appears.
If possible, the SAX driver should provide the line position
of the first character after the text associated with the document
event. The first line is line 1.
- getLineNumber in interface Locator
- The line number, or -1 if none is available.
getProperty
public Object getProperty(String name)
throws SAXNotRecognizedException,
SAXNotSupportedException
Look up the value of a property.
The property name is any fully-qualified URI. It is
possible for an XMLReader to recognize a property name but
temporarily be unable to return its value.
Some property values may be available only in specific
contexts, such as before, during, or after a parse.
XMLReaders are not required to recognize any specific
property names, though an initial core set is documented for
SAX2.
Implementors are free (and encouraged) to invent their own properties,
using names built on their own URIs.
- getProperty in interface XMLReader
name
- The property name, which is a fully-qualified URI.
- The current value of the property.
getPublicId
public String getPublicId()
Return the public identifier for the current document event.
The return value is the public identifier of the document
entity or of the external parsed entity in which the markup
triggering the event appears.
- getPublicId in interface Locator
- A string containing the public identifier, or
null if none is available.
getStartLocator
public Locator getStartLocator()
getSystemId
public String getSystemId()
Return the system identifier for the current document event.
The return value is the system identifier of the document
entity or of the external parsed entity in which the markup
triggering the event appears.
If the system identifier is a URL, the parser must resolve it
fully before passing it to the application. For example, a file
name must always be provided as a
file:... URL, and other
kinds of relative URI are also resolved against their bases.
- getSystemId in interface Locator
- A string containing the system identifier, or null
if none is available.
getVersion
public String getVersion()
parse
public void parse(String sysID)
throws IOException,
SAXException
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.
- parse in interface Parser
- parse in interface XMLReader
SAXException
- Any SAX exception, possibly
wrapping another exception.
setContentHandler
public void setContentHandler(ContentHandler handler)
Allow an application to register a content event handler.
If the application does not register a content handler, all
content events reported by the SAX parser will be silently
ignored.
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.
- setContentHandler in interface XMLReader
handler
- The content handler.
setDTDHandler
public void setDTDHandler(DTDHandler handler)
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.
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.
- setDTDHandler in interface Parser
- setDTDHandler in interface XMLReader
handler
- The DTD handler.
setDebug
public void setDebug(boolean debug)
setEntityResolver
public void setEntityResolver(EntityResolver resolver)
Allow an application to register an entity resolver.
If the application does not register an entity resolver,
the XMLReader will perform its own default resolution.
Applications may register a new or different resolver in the
middle of a parse, and the SAX parser must begin using the new
resolver immediately.
- setEntityResolver in interface Parser
- setEntityResolver in interface XMLReader
resolver
- The entity resolver.
setErrorHandler
public void setErrorHandler(ErrorHandler handler)
Allow an application to register an error event handler.
If the application does not register an error handler, all
error events reported by the SAX parser will be silently
ignored; however, normal processing may not continue. It is
highly recommended that all SAX applications implement an
error handler to avoid unexpected bugs.
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.
- setErrorHandler in interface Parser
- setErrorHandler in interface XMLReader
handler
- The error handler.
setFeature
public void setFeature(String name,
boolean value)
throws SAXNotSupportedException,
SAXNotRecognizedException
Set the value of a feature flag.
The feature name is any fully-qualified URI. It is
possible for an XMLReader to expose a feature value but
to be unable to change the current value.
Some feature values may be immutable or mutable only
in specific contexts, such as before, during, or after
a parse.
All XMLReaders are required to support setting
http://xml.org/sax/features/namespaces to true and
http://xml.org/sax/features/namespace-prefixes to false.
- setFeature in interface XMLReader
name
- The feature name, which is a fully-qualified URI.value
- The requested value of the feature (true or false).
setLocale
public void setLocale(java.util.Locale locale)
throws SAXException
setProperty
public void setProperty(String name,
Object value)
throws SAXNotRecognizedException,
SAXNotSupportedException
Set the value of a property.
The property name is any fully-qualified URI. It is
possible for an XMLReader to recognize a property name but
to be unable to change the current value.
Some property values may be immutable or mutable only
in specific contexts, such as before, during, or after
a parse.
XMLReaders are not required to recognize setting
any specific property names, though a core set is defined by
SAX2.
This method is also the standard mechanism for setting
extended handlers.
- setProperty in interface XMLReader
name
- The property name, which is a fully-qualified URI.value
- The requested value for the property.