1,105,395 Community Members

Converting from .XML to .DTD

Member Avatar
dami06
Junior Poster in Training
90 posts since Oct 2006
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Can someone please help me out here.. I am trying to convert a .xml
file to .dtd file.. I got this .xml file from google.
<?xml version="1.0"?>
<book>
<person>
<first>Kiran</first>
<last>Pai</last>
<age>22</age>
</person>
<person>
<first>Bill</first>
<last>Gates</last>
<age>46</age>
</person>
<person>
<first>Steve</first>
<last>Jobs</last>
<age>40</age>
</person>
</book>

Please could you help me out using this example to convert this .XML to .DTD file. I don't know how to do it and I wanna know please...You can use any example that you want..Thank you in advance..

Member Avatar
thekashyap
Practically a Posting Shark
809 posts since Feb 2007
Reputation Points: 193 [?]
Q&As Helped to Solve: 77 [?]
Skill Endorsements: 0 [?]
 
0
 

Well, are you trying to write a java program that converts Xmls to DTDs ?!
Reason why I ask is it's not a good idea.
Do you know what is a DTD used for and what is it's syntax?

Member Avatar
dami06
Junior Poster in Training
90 posts since Oct 2006
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

No im not trying to write a java program.. I was given an assignment which is below:
Change the programs that you wrote for the Coursework 2 so that recipes
are stored as .XML les rather than as simple text or as serialized objects.
You should not need to change any other part of your existing program: just
change the section in the recipe program that writes recipes out to use XML,
and include an XML parser in the menu program for reading them back.
Students who did not manage to get the programs for Coursework 2 to
work should write a program that creates recipes from arrays of Strings
and use these.
(2) Write a .DTD le that species what the contents of the .XML les
should look like, and a .XSL le which turns the .XML le into appropriate
.HTML.

I have already converted the java program to .xml and the next part is to .dtd but Im stuck and i dont know how to do it..thats why i used the example from google so that you wouldn't think i want you to do the assignment for me.. I hope you can help me now..

Member Avatar
thekashyap
Practically a Posting Shark
809 posts since Feb 2007
Reputation Points: 193 [?]
Q&As Helped to Solve: 77 [?]
Skill Endorsements: 0 [?]
 
0
 

You didn't answer my question.. ( Do you know what is a DTD used for and what is it's syntax?) so i'll assume answer is no..
Well, DTD is the Document Type Definition, that describes the format of an XML file. If you know Java/C++ a crude example would be see DTD as a class and XML as class object/instance.
So what you should do:
0. List down teh data you wanna put in your XML file.
1. At least get an overview of what is a DTD. Look at external links section for details.
2. Learn how to write a DTD.
3. Then write the DTD.
4. Then write an XML file that conforms to this DTD.

For teh HTML part of your problem see this link.

Finally always remember to search wikipedia.

Member Avatar
dami06
Junior Poster in Training
90 posts since Oct 2006
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

ok..thank you for that

Member Avatar
ausgezeichnete
Newbie Poster
2 posts since Apr 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
-1
 

hello there...for ur documnet it will be like this...
<!DOCTYPE book[
<!ELEMENT book (person)+>
<!ELEMENT person (first,last,age)>
<!ELEMENT first (#PCDATA)>
<!ELEMENT last (#PCDATA)>
<!ELEMENT age (#PCDATA)>

]>

<book>
<person>
<first>Kiran</first>
<last>Pai</last>
<age>22</age>
</person>

<person>
<first>Bill</first>
<last>Gates</last>
<age>46</age>
</person>

<person>
<first>Steve</first>
<last>Jobs</last>
<age>40</age>
</person>

</book>

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article