Hi All, I want to genarate an XML file after reading an DTD file. I want to know how can i read an DTD file in my java programme, can any body help me please. thanks, santosh
Joined: Mar 17, 2000
Generating a document instance based on a DTD ( or Schema specification ) is not quite easy. Since what people normally do is the quite opposite ie., apply an existing schema/DTD to an XML document, you will be disappointed to know there is no standard tool support to "cook" XML documents based on a DTD. Think about it. You will have to consider all possible combinations of document elements and attributes supported by DTD. The relation between a DTD( or a Schema ) and a valid XML document is really one to many. When the DTD is made flexible enough to accomodate different possiblities ( mixed content, optional elements, set of elements appearing in any order etc. ), you could generate many if not infinite number of documents that are all valid. Before you jump in, you should consider these issues. How will you handle such an "accommodative" DTD ? Since no tool support is available, you will have to parse the DTD yourself and build your generator class. What happens when the DTD changes over a period of time? How often can that happen? Will you rewrite your generator class to implement the changes and deploy it all over the client base? If you must do this, consider XML databinding frameworks like JAXB. Good luck,
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).