Class Parser

public class Parser
{
  // Constructors
  public Parser();

  // Methods
  public final XMLOutputStream createOutputStream(OutputStream out);
  public final void loadDTD(String urlStr, Atom nameSpace)
        throws ParseException;
  public final void parse(URL url, ElementFactory factory, DTD dtd,
        Element root, boolean caseInsensitive, boolean loadExt)
        throws ParseException;
  final public void parse(InputStream in, ElementFactory factory,
        DTD dtd, Element root, boolean caseInsensitive,
        boolean loadExt) throws ParseException;
  final public void report(ParseException e, OutputStream out);
}

This class implements an eXtensible Markup Language (XML) parser according to the latest World Wide Web Consortium (W3C) working draft of the XML specification. This parser class is used internally by the XML document load method, so you shouldn't need to use it directly.

Constructors

Parser

public Parser();

Creates a new parser object.

Methods

createOutputStream 

public final XMLOutputStream createOutputStream(OutputStream out);

Creates an output stream that best matches the XML data format found during parsing. For example, this will match big endian or little endian XML data formats.

Return Value

Returns an XMLOutputStream object that uses the newline separator defined by the system property "line.separator".

ParameterDescription
outThe output stream.

loadDTD 

public final void loadDTD(String urlStr, Atom nameSpace)
        throws ParseException;

check for document type declaration DocTypeDecl ::= ''

parse 

public final void parse(URL url, ElementFactory factory, DTD dtd,
        Element root, boolean caseInsensitive, boolean loadExt)
        throws ParseException;

Parses the XML document pointed to by the given URL and creates the corresponding XML document hierarchy.

ParameterDescription
urlthe url points to the XML document to parse.
factoryused to create XML Elements during parsing.
dtdthe object that the parser stores DTD information in.
rootthe root node to start with and add children to during parsing.
loadextwhether to load external DTD's and/or entities

Exceptions

ParseException if syntax or other error encountered.

parse 

final public void parse(InputStream in, ElementFactory factory,
        DTD dtd, Element root, boolean caseInsensitive,
        boolean loadExt) throws ParseException;

Parses the XML from given input stream.

ParameterDescription
inthe input stream containing XML data to parse.
factoryused to create XML Elements during parsing.
dtdthe object that the parser stores DTD information in.
rootthe root node to start with and add children to during parsing.

Exceptions

ParseException if syntax or other error encountered.

report 

final public void report(ParseException e, OutputStream out);

Reports errors to the specified output stream including parsing context and stack trace where the error occurred.

Return Value

No return value.

ParameterDescription
eThe exception to report.
outThe output stream to write the report to.