The XML DTD Parser API

Version:
$Revision: 1.1.1.1 $ $Date: 2003/03/03 07:09:26 $
Author:
Alexander Totok
This package consists of two parsers:

The parser is fully compliant with the current XML specification, unless otherwise is stated, for instance it is able to parse Unicode text, provided the {@link java.io.Reader java.io.Reader} used to instantiate the parser is correctly set up.

The structure of the package:

The parser was written using JavaCC (Java Compiler Compiler) - automated tool to generate Java programming language parsers.

Package consists of the following classes and files:

The followinge example parses XML DTD file dtd-document.dtd and constructs corresponding {@link org.exolab.castor.xml.dtd.DTDdocument XML DTD document} object dtd.


  FileInputStream inputStream;

  InputStreamReader reader;

  InputCharStream charStream;

  DTDInitialParser initialParser;

  String intermedResult;

  StringReader strReader;

  DTDParser parser;

  DTDdocument dtd;



  // instantiate input byte stream, associated with the input file

  inputStream = new FileInputStream( "dtd-document.dtd" );



  // instantiate character reader from the input file byte stream

  reader = new InputStreamReader( inputStream, "US-ASCII" );



  // instantiate char stream for initial parser from the input reader

  charStream = new InputCharStream( reader );



  // instantiate initial parser

  initialParser = new DTDInitialParser( charStream );



  // get result of initial parsing - DTD text document with parameter

  // entity references expanded

  intermedResult = initialParser.Input();



  // construct StringReader from the intermediate parsing result

  strReader= new StringReader( intermedResult );



  // instantiate char stream for the main parser

  charStream = new InputCharStream( strReader );



  // instantiate main parser

  parser = new DTDParser( charStream );



  // parse intermediate parsing result with the main parser

  // and get corresponding DTD document oblect

  dtd = parser.Input();