Lists Home |
Date Index |
- From: John Cowan <firstname.lastname@example.org>
- To: James Gray <email@example.com>, "firstname.lastname@example.org" <email@example.com>
- Date: Thu, 28 Sep 2000 15:21:59 -0400
James Gray wrote:
> I'm trying to create a DTD that will incorporate an
> attribute list that will allow the following case:
> 1. Define optional values for an element
> 2. Require one of the options be present
> 3. Not allow any option other than those listed
You mention attribute lists, but then talk about the value of an element.
DTDs don't allow you to control the value (content) of an element as such.
> I'd like to have a "shirt"
> element that is only allowed to the values:
> S, M, LG, XL
In order to make this work, we have to reformulate it as a "shirt"
element with an attribute "size" or the like. In that case, the
following ATTLIST declaration will work:
size (S|M|LG|XL) #REQUIRED>
This will require the size attribute to be present in all shirt elements,
and will allow its value to be "S", "M", "LG", or "XL".
> If the <shirt> element is filled with "XS" or "XXL",
> I would be able to reject it based on my DTD?
Yes, provided you use a validating parser.
There is / one art || John Cowan <firstname.lastname@example.org>
no more / no less || http://www.reutershealth.com
to do / all things || http://www.ccil.org/~cowan
with art- / lessness \\ -- Piet Hein