Re: DTD Parsing with xerces

Andy Clark <[email protected]>
Newsgroups gmane.text.xml.general,gmane.spam.detected
Message-ID <[email protected]>
Vijay Dialani wrote:
> I was trying to use XERCES for parsing a DTD document. There seems to
> be more than one way to accomplish the above. For my purpose, I was
> able to extend the org.apache.xerces.parsers.DOMParser class and
> override the DTD associated methods, but these do not provide the

The problem with that approach is that you are not able
to parse a standalone DTD file -- only a DTD that is part
of an XML document.

> advanced features as those provided by
> org.apache.xerces.parsers.DTDParser. Does any know a way of how one
> could use org.apache.xerces.parsers.DTDParser class? Any Sample code?

You could use the DTDParser class directly but it might
require you to write more code than you want. Another
approach is to use my NekoDTD[1] tool. It basically makes
the DTDParser into an XML parser, reporting all of the
DTD information in XML format. So you can use standard
XML APIs like DOM and SAX to access the DTD grammar.

This also lets you apply XSLT stylesheets and anything
else that you can do with XML. In fact, the tool comes
with some stylesheets (and some handy .bat files) to do
a poor-man's conversion of DTDs into XML Schema and
RelaxNG.

Depending on what you want to do, NekoDTD may help.

[1] http://www.apache.org/~andyc/neko/doc/dtd/index.html

-- 
Andy Clark * [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.