• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

DTD - spaces in (enumerated) attribute type list

Hi, I would like to have the following attribute list:

<!ATTLIST elementName attrName (two words|more than one word) #REQUIRED>

but it seems spaces are not valid in the enumerated list.  I also tried:

<!ENTITY % twoWords "two words">
<!ENTITY % moreThanOneWord "more than one word">
<!ATTLIST elementName attrName(%twoWords;|%moreThanOneWord;) #REQUIRED>

but was also unable to validate the DTD.  How can I solve this?  Thanks.
0
pw05
Asked:
pw05
  • 2
1 Solution
 
rdcproCommented:
DTD's are quite limited in what they can do.  Attributes can only have a few datatypes.  The enumerated type only allows name tokens (NMTOKEN).  You can use a NOTATION type for an attribute, then specify (using a <!NOTATION> declaration) an external reference, but I don't think you'll be able to validate that way.  Notation is mainly used to help an external application understand a custom datatype.  For example, you might declare a notation to assist your external application in handling an unparsed external entity, such as an image file in JPEG or GIF file format.

You're really better of defining this sort of thing in a Schema, such as a W3C XML Schema.

Regards,
Mike Sharp
0
 
rdcproCommented:
I didn't explicitly say, but you've probably already realized, a NMTOKEN is a single word, with no whitespace.  They are essentially like character data (CDATA) except they cannot contain whitespace characters such as space, tab, newline etc.  

Regards,
Mike Sharp
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now