back to XML certification FAQ

DTD
 

Questions 1-9 provided by Sanjay Mishra, 10-12 by Dan Chisham

   
1. Which of the following dtd code is valid?
  a)<!ELEMENT test (#CDATA)>
b)<!ELEMENT test (#PCDATA)>
c)<!ELEMENT test (#ANY)>
d)<!ELEMENT test (this,that)*>
    <!ELEMENT this(#PCDATA)>
    <!ELEMENT that(#PCDATA)>
 

Wrong

Answer : b

2. Which of the following code is valid?
 
a) <!DOCTYPE SYSTEM SYSTEM "test.dtd">
<SYSTEM></SYSTEM>
b) <!DOCTYPE PUBLIC SYSTEM "test.dtd">
<PUBLIC></PUBLIC>
c) <!DOCTYPE PUBLIC PUBLIC "test.dtd">
<PUBLIC></PUBLIC>
d) <!DOCTYPE SYSTEM PUBLIC "test.dtd">
<PUBLIC></PUBLIC>
 

Wrong

Answer : a b

3. Which of the following code is valid?


 
a)<!DOCTYPE test [ <!ELEMENT test (#PCDATA)>]>
b)<!DOCTYPE test [ <!ELEMENT test.dtd (elm1|elm2|#PCDATA) >]>
c)<!DOCTYPE test [ <!ELEMENT test.dtd (#PCDATA|elm1|elm2)* >]>
    <!ELEMENT elm1 (#PCDATA)>
    <!ELEMENT elm2 (#PCDATA)>
d)<!DOCTYPE test [ <!ELEMENT test test (#PCDATA)>]>
e)<!DOCTYPE test [ <!ELEMENT test "test" (#PCDATA)>]>
 

Wrong

Answer : a c

4. Which of the following code is valid?
  a) <?xml version="1.0" encoding="ISO-8859-1" ?>
b) <?xml version='1.0' encoding="en_US" ?>
c) <?xml version='1.0" encoding='ISO8859-1' ?>
d) <?xml version="1.0" encoding="ISO 8859-1" ?>
 

Wrong

Answers : a

5. Which of the following code is valid?
  a) <?xml version="1.0" standalone="yes"?>
b) <?xml standalone="yes" Standalone="no" ?>
c) <?xml version = "1.0" standalone="yes" ?>
d) <?xml version="1.0" attribute="value" ?>
 

Wrong

Answer : a c

6. Which of the following code is valid
 
a) <!ENTITY test "(#PCDATA)" >
<!ELEMENT elm1 &test;>
b) <!ENTITY lt "*(&5;#">
c) <!ENTITY test elm "elm1">
d) <!ENTITY test SYSTEM "elm">
e) <!ENTITY %test "(#PCDATA)">
<!ELEMENT elm1 %test;>
 

Wrong

Answer : d e

7. Is the following code valid?
 

<test att="a1"></test>
<test att="a1"> </test>
where att is ID type attribute.

a)true
b)false
 

Wrong

Answer: b

8. What are the predefined attributes
  a) xml:lang
b) xml:space
c) both
d) none.
 

Wrong

Answer: c

9. Parameter entities can appear in
  a) xml file
b) dtd file
c) xsl file
d) Both a and b
 

Wrong

Answers: b

10. Given the following declarations in the same DTD, what will be the declaration actually used?
  <!ATTLIST machine
cpu CDATA #REQUIRED
memory CDATA #IMPLIED
oem CDATA #FIXED "Dell"
>

<!ATTLIST machine
cpu CDATA #FIXED "1.2 MHz"
memory CDATA #IMPLIED
oem CDATA #FIXED "Dell"
os CDATA "Linux"
>


a)
<!ATTLIST machine
cpu CDATA #REQUIRED
memory CDATA #IMPLIED
oem CDATA #FIXED "Dell"
>

b)
<!ATTLIST machine
cpu CDATA #FIXED "1.2 MHz"
memory CDATA #IMPLIED
oem CDATA #FIXED "Dell"
os CDATA "Linux"
>

c)
<!ATTLIST machine
cpu CDATA #REQUIRED
memory CDATA #IMPLIED
oem CDATA #FIXED "Dell"
os CDATA "Linux"
>

d) None of the above. This is an error.
 

Wrong

Answers: c
ATTLIST declaractions are merged by using the first declared attribute and adding any additional attributes declared in later ATTLIST declarations. This is to allow
overriding of ATTLIST declarations in the external subset by declarations in the
internal subset.
XML Specification states the following (Section 3.3 Attribute-List
Declarations):
"When more than one AttlistDecl is provided for a given element type, the contents of all those provided are merged. When more than one definition is provided for the same attribute of a given element type, the first declaration is binding and later declarations are ignored."

11. Given the following declarations in the same DTD, what will be the declaration actually used?
  <!ENTITY machine name "Dell" >
<!ENTITY machine name "Gateway" >


a) <!ENTITY machine name "Dell" >
b) <!ENTITY machine name "Gateway" >
c) <!ENTITY machine name "DellGateway" >
d) None of the above. This is an error.
 

Wrong

Answer: a
The first ENTITY declaration is always used. This rule exists so that non-validating parsers can safely ignore subsequent ENTITY declarations.

XML Specification states the following (Section 4.2 Entity Declarations):
"If the same entity is declared more than once, the first declaration encountered is binding; at user option, an XML processor may issue a warning if entities are declared multiple times."

12. Given the following declarations in the same DTD, what will be the declaration actually used?
  <!ELEMENT machine ( monitor, harddrive+ ) >
<!ELEMENT machine ( cdrom* ) >
<!ELEMENT machine ( cdrom*, nic* ) >


a) <!ELEMENT machine ( monitor, harddrive+ ) >
b) <!ELEMENT machine ( cdrom*, nic* ) >
c) <!ELEMENT machine ( monitor, harddrive+, cdrom*, nic* ) >
d) None of the above. This is an error.
 

Wrong

Answers: d
This actually is an error. The XML specification expressly forbids multiple declarations for the same element.

XML Specification states the following (Section 3.2 Element Type Declarations):
"Validity Constraint Unique Element Type Declaration. No element type may
be declared more than once.

 

 Your scores: 

back to XML certification FAQ