The XML DTD Parser API
<!ENTITY % name "John White" >signaling an error if an external parameter entity declaration, like:
<!ENTITY % ISOLat2 SYSTEM "http://www.xml.com/iso/isolat2-xml.entities" >is met. Future versions will be able to parse and handle external parameter entity declarations.
<![ INCLUDE [ ... ]]> <![ IGNORE [ ... ]]>
<?xml version="1.0" encoding="UTF-16"?>
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:
JAVA_UNICODE_ESCAPE = false; UNICODE_INPUT = false; USER_CHAR_STREAM = false;Note that this class is not fully JavaCC generated.
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();