This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Genarating XML help please............ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Genarating XML help please............" Watch "Genarating XML help please............" New topic

Genarating XML help please............

santosh vashist

Joined: May 14, 2001
Posts: 25
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.
Ajith Kallambella

Joined: Mar 17, 2000
Posts: 5782
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).
I agree. Here's the link:
subject: Genarating XML help please............
jQuery in Action, 3rd edition