[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: ATTLIST question
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: <!ATTLIST shirt 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 <jcowan@r...> no more / no less || http://www.reutershealth.com to do / all things || http://www.ccil.org/~cowan with art- / lessness \\ -- Piet Hein
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|