Reputation: 11444
I would like to write an XML file for the following data (represented in tables):
Account table:
account-number balance
100 1000
719 9000
715 -3000
600 100
Costumers table:
account-number street city id
100 ... ... ...
719 ... ... ...
715 ... ... ...
715 ... .... ...
600 ... ... ...
Since this is my first time writing in XML, im abit confused about the DTD file. This is what I wrote:
<!ELEMENT bank (costumer)*>
<!ELEMENT costumer (account, street, city, id)>
<!ELEMENT account (account-number, balance)>
<!ELEMENT account-number (#PCDATA)>
<!ELEMENT balance (#PCDATA)>
<!ATTLIST balance currency CDATA #FIXED "usd">
<!ELEMENT street (#PCDATA)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT id (#PCDATA)>
Does this form truly serves my intentions, or I do I have any mistakes? Do you have anything to add/change in my code, so it best fits to describe those tables?
Upvotes: 1
Views: 1797
Reputation: 52858
It looks like you have everything covered, but only you can determine whether it fits your needs or not.
Just a couple of minor suggestions.
Use an attribute for id
instead of an element. That way you can be sure that it's unique and you can reference it if you need to: <!ATTLIST costumer id ID #REQUIRED>
. You could do the same for account number too.
Wrap street
and city
in an address
element. That will make it easier to expand in the future without cluttering the model of costumer
.
Upvotes: 2