in reply to Parsing an XML-like definition of an XML-like language to create a parser of the actual data in that language.

To the best of my recollection, Altova's free XMLSpy had a utility that would allow you to take either a DTD or an XML Schema (tools exist to go from DTD to Schema) and generate a small sample XML file that corresponds to that DTD/Schema. Whether such would be sufficient to generate a parser for that particular XML file, I cannot say.

However, you might have a larger problem. When I open your DTD in my installed version of XMLSpy, I get the following error:

This file is not well-formed: % expected.

IMHO, you probably need to address this issue (hopefully just an error of copy & paste) before addressing larger issues of parsing DTDs, Schemas, or XML.

Since XML Schemas are themselves written in XML (and well-tested parsers already exist for XML), I would try (1) Fixing the error described above; (2) Converting DTD to XSD; (3) using an existing XML Parser on the result.

I have included a few links (unchecked to see if they are still "up"), that may be of use:

James Clark's trang

a Java-based translator

a Perl program that can translate DTDs to XSD, link 1

a Perl program that can translate DTDs to XSD, link 2

dtd2xs

HTH,

planetscape
  • Comment on Re: Parsing an XML-like definition of an XML-like language to create a parser of the actual data in that language.
  • Download Code

Replies are listed 'Best First'.
Re^2: Parsing an XML-like definition of an XML-like language to create a parser of the actual data in that language.
by Moron (Curate) on Nov 20, 2006 at 11:27 UTC
    Planetscape, thanks for taking so much trouble to map out a strategy, I will certainly start with making sure I have a DTD parser and a version of the DTD that work together bug-free and see where that gets me along the road you describe. The vendor also just warned me of a particular bug with the data so itīs going to be sort of fun even getting past step 1 of your plan, but Iīll give it a go.

    -M

    Free your mind