views:

375

answers:

3

I've been looking around the System.Xml namespace, but don't see anything that would support this. Does anyone know if it's built into .Net, or would I have to obtain a third party library to do it?

NOTE: I wish it were as simple as generating an xsd, but that won't do for my specific situation.

A: 

I'm not sure about DTD but you can generate XSD files from an xml file using the Xsd.exe tool. It usually lives in the following directory:

C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\xsd.exe

Richard Nienaber
Thanks, but I was asking for DTD. I wish I could get by in my current task with an xsd, but the client specifically asked for DTDs.
Kilhoffer
A: 

Well, xsd.exe should be able to get you an xsd. For the dtd side, xmlpad3 claims to be able to do this (and is free). I haven't tried, so I can't vouch for it.

Marc Gravell
+2  A: 

It would be very easy to do, but very hard to make it useful.

DTD is a grammar. It is trivial to generate a grammar that generates just the given XML file and no other. This is of course useless in practice. What you probably need is to create a grammar that generates files "like this one", and this is a hard AI problem.

Edit: This problem is known as "Grammar Induction" or "Grammar Inference".

Rafał Dowgird