public class XMLScanner
extends java.lang.Object
An XMLScanner
provides a convenient packaging of a
JAXP-based SAX 2 XML Parser.
Each of the methods scanXML(InputSource,DefaultHandler)
and
scanXMLText(String,DefaultHandler)
takes some form of XML source and a DefaultHandler
(or sub-class) instance as arguments, and
invokes the parser on that XML source -- resulting in the
delivery of a sequence of SAX events to the handler.
[This version spent some time in the package xml.newsax, while an older version was here in pagckage xml. This version differs from the older one in that it responds to the various SAX and IO exceptions by throwing an instance of an internally defined ScanException class rather than by simply aborting the JVM.]
Modifier and Type | Class and Description |
---|---|
static class |
XMLScanner.ScanException
All-purpose scanner exception class.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
SAX_NAMESPACES
SAX namespaces feature name.
|
static java.lang.String |
SAX_NS_PREFIXES
SAX namespace prefixes feature name.
|
static java.lang.String |
SAX_STRING_INTERN
SAX string interning feature name.
|
Constructor and Description |
---|
XMLScanner(java.lang.String intag)
Constructs a new validating scanner with the given idenfification tag.
|
XMLScanner(java.lang.String intag,
boolean validate)
Constructs a new scanner with the given idenfification tag,
performing XML validataion or not, as specified.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getSPXLineColText(org.xml.sax.SAXParseException spx)
Returns line and column number text for the given SAX parse exception.
|
static java.lang.String |
getSPXLocationText(org.xml.sax.SAXParseException spx)
Returns a full location text, including System Id if available,
for the given SAX parse exception.
|
void |
scanXML(org.xml.sax.InputSource insrc,
org.xml.sax.helpers.DefaultHandler hndlr)
Parses the given source XML document, feeding SAX parse events
to the given handler.
|
void |
scanXML(java.lang.String inuri,
org.xml.sax.helpers.DefaultHandler hndlr)
Parses the source XML document with the given URI, feeding SAX parse
events to the given handler.
|
void |
scanXMLText(java.lang.String txt,
org.xml.sax.helpers.DefaultHandler hndlr)
Parses the given XML document text, feeding SAX parse events
to the given handler.
|
public static final java.lang.String SAX_NAMESPACES
public static final java.lang.String SAX_NS_PREFIXES
public static final java.lang.String SAX_STRING_INTERN
public XMLScanner(java.lang.String intag) throws XMLScanner.ScanException
XMLScanner.ScanException
public XMLScanner(java.lang.String intag, boolean validate) throws XMLScanner.ScanException
XMLScanner.ScanException
public void scanXML(org.xml.sax.InputSource insrc, org.xml.sax.helpers.DefaultHandler hndlr) throws XMLScanner.ScanException
XMLScanner.ScanException
public void scanXML(java.lang.String inuri, org.xml.sax.helpers.DefaultHandler hndlr) throws XMLScanner.ScanException
XMLScanner.ScanException
public void scanXMLText(java.lang.String txt, org.xml.sax.helpers.DefaultHandler hndlr) throws XMLScanner.ScanException
XMLScanner.ScanException
public static java.lang.String getSPXLocationText(org.xml.sax.SAXParseException spx)
public static java.lang.String getSPXLineColText(org.xml.sax.SAXParseException spx)