You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by Vijay Dialani <vd...@us.ibm.com> on 2005/06/29 01:48:09 UTC

DTD Parsing with xerces

Hi All,
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 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?
Regards,
Vijay

Re: DTD Parsing with xerces

Posted by Andy Clark <an...@apache.org>.
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 * andyc@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org