This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes How to create a form from XML-DTD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How to create a form from XML-DTD" Watch "How to create a form from XML-DTD" New topic
Author

How to create a form from XML-DTD

dan nwankwo
Greenhorn

Joined: May 23, 2001
Posts: 8
i am writing a software and i want to generate my user interface form based on the elements in a DTD because i want the interface form to be generic. how do i go about this. what tools can i use to extract the number and type of elements in a dtd and how best can i use this information to construct my user interface. Are there any good books or web sites that give examples on how to achieve this.
My MSc degree is riding on this so i would really appreciate any suggestions. Thankyou.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12809
    
    5
I don't think a DTD gives you the kind of information you need to generate a form - for example, for a repeating element, how many input fields should you generate.
How about a "model" XML document corresponding to a fully populated form? You could fill it with the largest possible entries so you could determine the size of the various input fields.
There is a thing called XForms that the w3c is playing around with that you might look into.
This is a very interesting area so let us know how your project goes.
Bill
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
As mr. Brogden already said, you need to employ XML, not DTD. XML is a language which is capable to express information, DTD is a language to express grammar, not semantics! DTD is written using EBNF - very formal language designed to express grammar of computer languages. If your assignment were to create some new language, then, perhaps, you could use DTD, although I am not sure even in this case. In XML world DTDs are used to check if XML documents are formally correct, nothing more.
For inspiration, you may want to check "Java pro", April 2001, Vol 5, N.4 "XML and Java on the Menu" by Dan Wahlin. It describes an example how dynamic menus can be created. Data are kept in XML, then they are converted to HTML using DOM parser (Xerces). To run transformation, JSP technology is used.
Even more interesting example is described in "XML journal", Volume 2, Issue 3. "Converting your client/server applications to the Internet" by Victor Rasputnis and Anatole Tartakovski. User interface is described very detailed in XML format:
<NAME>gender</NAME> <TABORDER>10</TABORDER> <X>33px</X><Y>1px</Y><WIDTH>144px</WIDTH><HEIGHT>19px</HEIGHT>...
Then the authors use generic XSLT stylesheet to generate... another XSLT stylesheets, which will convert XML to HTML. Another XSLT stylesheet is used to generate Java code - maybe that is an idea you are looking for.

[This message has been edited by Mapraputa Is (edited June 30, 2001).]


Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
dan nwankwo
Greenhorn

Joined: May 23, 2001
Posts: 8
Thankyou for the suggestions so far, i find them enlightening. Please keep them coming, i need all i can get!
Daniel
 
 
subject: How to create a form from XML-DTD