Which DTD declaration is used to define attributes for an element?
A
<!ELEMENT ...> B
<!ATTRIBUTE ...> C
<!ATTLIST ...> D
<!ENTITY ...>
Analysis & Theory
`<!ATTLIST>` is used to define attributes associated with an element.
What does the following DTD declaration mean?
`<!ATTLIST book category CDATA #REQUIRED>`
A
The `book` element has an optional attribute `category` of type text B
The `book` element must have an attribute `category` with predefined values C
The `book` element must have an attribute `category` with any text value D
The `book` element cannot have the `category` attribute
Analysis & Theory
`CDATA` means the attribute accepts any text, and `#REQUIRED` means it must be present in the XML.
Which of the following keywords in DTD means that an attribute is optional?
A
#REQUIRED B
#IMPLIED C
#FIXED D
#DEFAULT
Analysis & Theory
`#IMPLIED` means the attribute is optional — it may or may not be included in the element.
What does `#FIXED` do in a DTD attribute declaration?
A
Specifies a list of values the attribute can take B
Forces the attribute to always have a fixed value if present C
Makes the attribute optional D
Makes the attribute required
Analysis & Theory
`#FIXED` sets a constant value for the attribute if it is present in the XML element.
How would you define an attribute with a default value in DTD?
A
`<!ATTLIST book category CDATA 'fiction'>` B
`<!ATTLIST book category CDATA #DEFAULT 'fiction'>` C
`<!ATTLIST book category CDATA #IMPLIED>` D
`<!ATTLIST book category CDATA 'default=fiction'>`
Analysis & Theory
Default values are given directly in single quotes: `<!ATTLIST book category CDATA 'fiction'>`.
Which type allows an attribute to take a value from a list of options?
A
ID B
CDATA C
ENUMERATION D
IDREF
Analysis & Theory
`ENUMERATION` allows defining a list of valid values, like `(paperback | hardcover | ebook)`.
What does this declaration mean?
`<!ATTLIST item id ID #REQUIRED>`
A
Each `item` must have a unique `id` attribute B
Each `item` must have a non-unique id C
The `id` attribute is optional D
The `id` value must match another element
Analysis & Theory
An attribute of type `ID` must be unique within the XML document and is required here.