|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.semanticdesktop.aperture.util.SimpleSAXParser
public class SimpleSAXParser
An XML parser that generates "simple" SAX-like events from a limited subset of XML documents. The SimpleSAXParser can parse simple XML documents; it doesn't support processing instructions or elements that contain both sub-element and character data; character data is only supported in the "leaves" of the XML element tree.
Parsing the following XML:
<?xml version='1.0' encoding='UTF-8'?> <xml-doc> <foo a="1" b="2&3"/> <bar>Hello World!</bar> </xml-doc>
will result in the following method calls to the SimpleSAXListener:
startDocument() startTag("xml-doc", emptyMap, "") startTag("foo", a_b_Map, "") endTag("foo") startTag("bar", emptyMap, "Hello World!") endTag("bar") endTag("xml-doc") endDocument()
Constructor Summary | |
---|---|
SimpleSAXParser()
Creates a new SimpleSAXParser that will create a new SAXParser using a SAXParserFactory for parsing the XML. |
|
SimpleSAXParser(SAXParser saxParser)
Creates a new SimpleSAXParser that will use the supplied SAXParser for parsing the XML. |
Method Summary | |
---|---|
SimpleSAXListener |
getListener()
Gets the listener that currently receives the events from this parser. |
boolean |
getTrimWhitespace()
Returns whether textual content is trimmed before being reported to the SimpleSAXListener. |
void |
parse(File file)
Parses the content of the supplied File as XML. |
void |
parse(InputStream in)
Parses the content of the supplied InputStream as XML. |
void |
parse(InputStream in,
String systemId)
Parses the content of the supplied InputStream as XML. |
void |
setListener(SimpleSAXListener listener)
Sets the (new) listener that should receive any events from this parser. |
void |
setTrimWhiteSpace(boolean trimWhitespace)
Sets whether returned textual content needs to be trimmed before being reported to the SimpleSAXListener. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SimpleSAXParser(SAXParser saxParser)
saxParser
- The SAXParser to use for parsing.setListener(org.semanticdesktop.aperture.util.SimpleSAXListener)
public SimpleSAXParser() throws ParserConfigurationException, SAXException
ParserConfigurationException
- If the SimpleSAXParser was unable to create a SAXParser.
SAXException
setListener(org.semanticdesktop.aperture.util.SimpleSAXListener)
,
SAXParser
,
SAXParserFactory
Method Detail |
---|
public void setListener(SimpleSAXListener listener)
listener
- The (new) listener for events from this parser.public SimpleSAXListener getListener()
public void setTrimWhiteSpace(boolean trimWhitespace)
public boolean getTrimWhitespace()
public void parse(InputStream in) throws SAXException, IOException
in
- An InputStream containing XML data.
SAXException
IOException
public void parse(InputStream in, String systemId) throws SAXException, IOException
in
- An InputStream containing XML data.systemId
- The systemId used to resolve relative URIs.
SAXException
IOException
public void parse(File file) throws SAXException, IOException
file
- The file containing the XML to parse.
SAXException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |