Reputation: 101
I know that the question is probably trivial, but I really need to know this stuff.
Here's an example of what I precisely mean:
XML Code:
<product id="01" quantity="4 peaces"> Chocolate Cake </product>
Also, what would be in this case the attribute-type declaration in the DTD-file? Perhaps 'CDATA'?
Upvotes: 1
Views: 111
Reputation: 111511
Your example shows an element with two attributes: id
and quantity
. XML does not limit the number of attributes an element can have, so, yes, an element can have both an id
(attribute) and other attributes at the same time.
<!ELEMENT product (#PCDATA)>
<!ATTLIST product
id ID #REQUIRED
quantity CDATA #REQUIRED>
Or, if you must accommodate id
values that begin with a digit, which as Daniel Haley rightly points out are not allowed by ID
, you could use CDATA
for id
.
Upvotes: 2
Reputation: 344
In my opinion yes, it can have both. The id is just an attribute like quantity and every xml-element can have n
attributes. So it should work.
But I can not help you with your second question. I have never used DTD-files. Maybe this converter can help you: http://bsp.mits.ch/xsd2dtd/
Upvotes: 1