[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: ATTLIST question

  • From: John Cowan <jcowan@r...>
  • To: James Gray <jmgii@y...>, "xml-dev@x..." <xml-dev@x...>
  • Date: Thu, 28 Sep 2000 15:21:59 -0400

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!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.