I have a project in which I am supposed to write a parser in Java for a set
of files that don't contain <!DOCTYPE ...> lines. A DTD file was defined for
these files, and the files contain entity references whose definitions are
in the DTD file. I looked at the JAXP documentation, and it looks like I
have several options: There appear to be a variety of ways I can provide a
system id to a factory object, to a parser object, or as an argument to the
parse function. Or I can specify an entityResolver function for the parser,
or I can tell the parser not to expand entity references. I have tried
several of these, and I haven't gotten any of them to work yet. In each
case, it appears that the DTD file is not read and the parse crashes with an
error saying that an entity was referenced that was not declared. Can anyone
provide me with a sort of recipe for constructing a parser in which the DTD
file is specified without the use of a <!DOCTYPE ... > line in the file to
be parsed, and the DTD file is read and is available to resolving entity
references that are encountered during the parse? Thanks.

Mike O'Leary

Reply via email to