public class SaxParser extends Base
Modifier and Type | Class and Description |
---|---|
protected class |
SaxParser.ValidationHandler
An inner class Error Handler that is registered in
parser that performs validation.
|
Base.LoggingWriter, Base.StackFrame
Constructor and Description |
---|
SaxParser()
Construct a SaxParser.
|
SaxParser(boolean fAllowComments)
Construct a SaxParser.
|
Modifier and Type | Method and Description |
---|---|
protected static Parser |
getParser()
Get an instance of non-validating SAX parser.
|
protected XmlElement |
instantiateRoot(String sRoot)
Instantiate an XmlElement implementation for a root element.
|
static void |
main(String[] asParam)
Unit test: create a simple parser, parse and output the result.
|
XmlElement |
parseXml(InputSource input)
Parse the specified InputSource into a tree of XmlElement objects
ignoring any XML nodes other than elements, text or comments
(in a case of SaxParser that allows comments).
|
protected XmlElement |
parseXml(InputSource input,
XmlElement xmlRoot)
Actual implementation...
|
XmlElement |
parseXml(InputStream input)
Parse the specified InputStream into a tree of XmlElement objects
ignoring any XML nodes other than elements, text or comments
(in a case of SaxParser that allows comments).
|
XmlElement |
parseXml(Reader input)
Parse the specified Reader into a tree of XmlElement objects
ignoring any XML nodes other than elements, text or comments
(in a case of SaxParser that allows comments).
|
XmlElement |
parseXml(String sXml)
Parse the specified String into a tree of XmlElement objects
ignoring any XML nodes other than elements, text or comments
(in a case of SaxParser that allows comments).
|
XmlElement |
parseXml(String sXml,
XmlElement elRoot)
Parse the specified String into a tree of XmlElement objects
(same as above) having the specified [empty] XmlElement a root.
|
protected Source[] |
resolveSchemaSources(List<String> listUri)
For a given set of XSD URIs, return the
Source s to be
used by the XML parser to validate an XML document. |
void |
validateXsd(String sXml,
XmlDocument xml)
XSD aware parsing routine; if XML contains an XSD reference
to a schemeLocation/noNamespaceSchemaLocation then parse XML
using provided XSD for validation.
|
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
public SaxParser()
public SaxParser(boolean fAllowComments)
fAllowComments
- if true, the resulting tree may contain
the XMLValue nodes that contain comments;
otherwize all comments are ignoredpublic static void main(String[] asParam)
asParam
- an array of parameterspublic XmlElement parseXml(String sXml) throws SAXException
sXml
- the XML as stringSAXException
- if SAX error occurspublic XmlElement parseXml(String sXml, XmlElement elRoot) throws SAXException
sXml
- the XML as stringelRoot
- the XML rootSAXException
- if SAX error occurspublic XmlElement parseXml(InputStream input) throws SAXException
input
- the InputStreamSAXException
- if SAX error occurspublic XmlElement parseXml(Reader input) throws SAXException
input
- the input ReaderSAXException
- if SAX error occurspublic XmlElement parseXml(InputSource input) throws SAXException
input
- the InputSourceSAXException
- if SAX error occursprotected XmlElement parseXml(InputSource input, XmlElement xmlRoot) throws SAXException
input
- the InputSourcexmlRoot
- the XML rootSAXException
- if SAX error occurspublic void validateXsd(String sXml, XmlDocument xml) throws SAXException, IOException, ParserConfigurationException
sXml
- the XML to parse (as a string)xml
- the XML document object used to obtain schema locationsSAXException
- if XML contains an XSD reference and does not
pass validationIOException
- if XML contains a schema that cannot be loadedParserConfigurationException
- if a parser cannot be createdprotected Source[] resolveSchemaSources(List<String> listUri) throws IOException
Source
s to be
used by the XML parser to validate an XML document.listUri
- list of XSD URIs to convertSource
s to be used by the XML parserIOException
- if the resource cannot be located or loadedprotected XmlElement instantiateRoot(String sRoot)
sRoot
- root name