I have a simple DTD file with elements and attributes specifications. Can i create a suitable XML file (with DOM) parsing this DTD with Java and no external APIs?
Thanks in advance
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I understand your question differently from Eugene Morozov. Tell me if I’m right: you want a program which takes as input a DTD and automatically generates XML file(s) whch are valid according to this DTD. Is it a correct description?
If so, it is certainly possible, such programs exist for other ‘structure languages’ (see abnfgen for BNF grammars; in the XML world, it seems that XMLSpy, for instance, can open a W3C Schema file – XSD file – and generates a sample valid XML) but I don’t know one for DTD/XML, you’ll have to write it yourself.
Just be aware that there is an infinity of valid XML files according to a given DTD. Your program will just generate a small subset (but it may be sufficient for your purpose: what is it, anyway?)