public class XmlReader extends LoggableOp
Typically, when you parse an XML document, you do not want the parse to barf on badly-formed XML with an exception. XmlReader therefore prints error and warning messages to an output stream, which is by default System.out, but can be set to another stream to allow an application to capture this output (to display it in a GUI, for example). A "verbose" flag can be used to make the XML reader print out lots and lots of other information as well. Once the parse is complete, the caller should use the getErrorCount() method to see if there were any errors.
This parser is capable of resolving external entities using either public IDs or system IDs. System IDs are usually given as a complete URL to the given file. Public IDs are given as partial pathnames to which the parser prepends a locally known location for libraries of XML files. In Diva, the partial pathname (eg "graph.dtd") is looked up in the default resource bundle in the diva.resource package. DTDs that can be recognized as "public" must therefore be entered into diva/resource/Defaults.properties file. If both IDs are given, this parser tries to use the public ID first.
Modifier and Type | Class and Description |
---|---|
class |
XmlReader.Handler
Handler is an inner class that implements the Aelfred XmlHandler
interface.
|
_verbose
Constructor and Description |
---|
XmlReader() |
Modifier and Type | Method and Description |
---|---|
int |
getLineNumber()
Get the current line number.
|
void |
parse(XmlDocument document)
Parse the given document from the URL it contains.
|
void |
parse(XmlDocument document,
InputStream in)
Parse the given document from the given input stream, but
using the given URL to resolve external references.
|
void |
parse(XmlDocument document,
Reader in)
Parse the given document from the given reader, but
using the given URL to resolve external references.
|
String |
printEntityType(String name)
Print the type of an entity.
|
getErrorCount, getErrorStream, getWarningCount, indent, isVerbose, logError, logError, logError, logInfo, logInfo, logWarning, logWarning, logWarning, reset, setErrorStream, setVerbose, unindent
public int getLineNumber()
getLineNumber
in class LoggableOp
public void parse(XmlDocument document) throws Exception
Exception
- If the parser fails internally. This indicates
a severe error, such as an I/O error, not an XML error.public void parse(XmlDocument document, InputStream in) throws Exception
Exception
- If the parser fails internally. This indicates
a severe error, such as an I/O error, not an XML error.parse(XmlDocument)
public void parse(XmlDocument document, Reader in) throws Exception
Exception
- If the parser fails internally. This indicates
a severe error, such as an I/O error, not an XML error.parse(XmlDocument)
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.