I am just learning to write XML and associated DTD’s, and I’m wondering if I can combine certain things in one line of an !ATTLIST.
eg:
I have an element weight, and I want to have (kg|lb) as options, but set "kg" as the default. None of these are essential, so the status is #IMPLIED, but I also want to have a default weight of “1”.
Can I legally put all this in one line:
<!ELEMENT weight (#PCDATA)>
<!ATTLIST weight unit CDATA "1" (kg|lb) "kg" #IMPLIED>
Or can I do it this way:
<!ELEMENT weight (#PCDATA)>
<!ATTLIST weight unit CDATA>
<!ATTLIST weight unit "1" #IMPLIED>
<!ATTLIST weight unit (kg|lb)>
<!ATTLIST weight unit "kg" #IMPLIED>
I suspect there are problems with both, and I am a little confused as to how I combine these features (or if I even can) – so I would really appreciate a little guidance on doing this properly.
Ok, I have got it working by doing the following, although it might not be the ‘accepted practice’ way:
I had to break the value out into its own attribute (which makes sense now I think about it), and remove the #IMPLIED, since I read somewhere that by setting a default value, its implied anyway.
Hopefully this will help someone else (assuming its the right way to do it)
Cheers