Hi, I had to do the quiz for XML and I am not quite sure whether I've got all the question right. Please tell me whether I've got each question right or wrong. Thank you very much.

  1. What kind of component in an XML file is written like this:

    <?xml version="1.0"?>

Select one:
a. an empty element
b. none of the other cases - this is illegal XML
c. an attribute
d. a processing instruction
e. none of the other cases, but this is legal XML

Answer: d

  1. This is XML.

    <?xml version="1.0"?>
    <block>
    <order strength="firm">
    <item>widget-LH-metric</item>
    <number>25</number> </order>
    <order strength="firm"><item>tap</item><number/></order>
    </block>

name the root element: block
what is the name of the attribute: strength
what is the name of the empty element: number

3.This is an XML document. Choose all of the statements that are true:

   <?xml version="1.0"?>
<block>blah<blip>
   <fred>blah</blip>
<fred></BLOCK>
    <fred/>

Select one or more:
a. syntactically correct XML but not well-formed
b. not syntactically correct
c. this is legal well-formed XML

Answer: b

  1. A DTD :
    Select one or more:
    a. is written in a language defined in a seperate specification from XML outside the XML syntax
    b. is itself a well-formed XML document
    c. must always be contained in the XML document to be valid
    d. uses <!ELEMENT components

Answer: a, d

  1. A DTD component in a document

    <!ELEMENT order (#PCDATA) >

must name an element in a different namespace from the rest of the document

Select one:
True
False

Answer: True

  1. Given this fragment of a DTD specification for a document, state whether each of the following fragments of XML is valid or invalid according to this DTD.

    <!ELEMENT zoo (animalStock)*>
    <!ELEMENT animalStock (animal , count)>
    <!ELEMENT animal (lion | kangaroo | ant | zebra | aname)>
    <!ELEMENT kangaroo (#PCDATA)>
    <!ELEMENT lion (#PCDATA)>
    <!ELEMENT ant (#PCDATA)>
    <!ELEMENT zebra (#PCDATA)>
    <!ELEMENT count (#PCDATA)>

    <zoo> <animalStock> <animal type="lion">white</animal> <count>3</count> </animalStock> </zoo>

Answer: invalid

<zoo> <animalStock> <animal><ant/></animal> <count>1000000</count> </animalStock> <animalStock> <animal><kangaroo>red</kangaroo> </animal> <count>6</count> </animalStock> </zoo>    

Answer: valid

<animalStock>
<animal><lion/></animal>
<count>1</count>
</animalStock>   

Answer: invalid

<animalStock> <animal type="lion"/> <count>1</count> </animalStock>  

Answer: invalid

<zoo> <animal> <lion> </animal> </zoo>   

Answer: invalid

<animalStock> <animal><zebra>mountain</zebra></animal> <count> 35</count> </animalStock>    

Answer: invalid

  1. XML Schema: choose all of the following that are the names of simple types in XSD
    Select one or more:

    a. boolean
    b. thin
    c. short
    d. year
    e. solid
    f. alphanumeric
    g. java
    h. integer
    i. string
    j. date
    k. identifier

Answer: all of them ?

Thanks!

Recommended Answers

All 3 Replies

That was so painstaking to read with the formatting.

The answers could also be found yourself by using google.

------------

What kind of component in an XML file is written like this:

<?xml version="1.0"?>

Select one:
a. an empty element
b. none of the other cases - this is illegal XML
c. an attribute
d. a processing instruction
e. none of the other cases, but this is legal XML

Your answer: D.
Answer: Incorrect, E.

The XML declaration is commonly mistaken for a processing instruction as it looks like one, however it is not.

------------

This is XML.

<?xml version="1.0"?>
<block>
    <order strength="firm">
        <item>widget-LH-metric</item>
        <number>25</number> 
    </order>
    <order strength="firm">
        <item>tap</item>
        <number></number>
    </order>
</block>

Name the root element: Block
What is the name of the attribute: Strength
What is the name of the empty element: Number

Answers: Correct.

------------

3.This is an XML document. Choose all of the statements that are true:

 <?xml version="1.0"?>
 <block>
     blah<blip>
     <fred>blah</blip>
     <fred>
 </BLOCK>
 <fred></fred>

Select one or more:
a. syntactically correct XML but not well-formed
b. not syntactically correct
c. this is legal well-formed XML

Your Answer: B.
Answer: Correct.

------------

A DTD :
Select one or more:
a. is written in a language defined in a seperate specification from XML outside the XML syntax
b. is itself a well-formed XML document
c. must always be contained in the XML document to be valid
d. uses <!ELEMENT components

Your Answer: A and D.
Answer: Correct, little unsure on A though.

------------

A DTD component in a document

<!ELEMENT order (#PCDATA)>

must name an element in a different namespace from the rest of the document

Select one:
True
False

Your answer: True.
Answer: No clue on this one, I haven't played with writing DTD's.

------------

Given this fragment of a DTD specification for a document, state whether each of the following fragments of XML is valid or invalid according to this DTD.

<!ELEMENT zoo (animalStock)*>
<!ELEMENT animalStock (animal , count)>
<!ELEMENT animal (lion | kangaroo | ant | zebra | aname)>
<!ELEMENT kangaroo (#PCDATA)>
<!ELEMENT lion (#PCDATA)>
<!ELEMENT ant (#PCDATA)>
<!ELEMENT zebra (#PCDATA)>
<!ELEMENT count (#PCDATA)>

 <zoo> 
     <animalStock> 
         <animal type="lion">white</animal> 
         <count>3</count>
     </animalStock> 
 </zoo>

Your Answer: Invalid.
Answer: Correct.

 <zoo> 
     <animalStock>
         <animal>
             <ant></ant>
         </animal> 
         <count>1000000</count> 
     </animalStock>
     <animalStock> 
         <animal>
             <kangaroo>red</kangaroo>
         </animal>
         <count>6</count>
     </animalStock> 
 </zoo> 

Your Answer: Valid.
Answer: Correct.

 <animalStock>
     <animal>
         <lion></lion>
     </animal>
     <count>1</count>
 </animalStock> 

Your Answer: Invalid.
Answer: Correct.

 <animalStock>
     <animal type="lion"></animal>
     <count>1</count>
 </animalStock> 

Your Answer: Invalid.
Answer: Correct.

 <zoo>
     <animal>
         <lion>
     </animal>
 </zoo> 

Your Answer: Invalid.
Answer: Correct.

 <animalStock>
     <animal>
         <zebra>mountain</zebra>
     </animal>
     <count>35</count> 
 </animalStock> 

Your Answer: Invalid.
Answer: Incorrect, Valid.

<animalstock> contains <animal> and <count> as it should.
Zebra is allowed within <animal> and is correctly formed.

------------

XML Schema: choose all of the following that are the names of simple types in XSD
Select one or more:

a. boolean
b. thin
c. short
d. year
e. solid
f. alphanumeric
g. java
h. integer
i. string
j. date
k. identifier

Your Answer: All of them.
Answer: A, C, H, I, K, J.

Source for answer

------##------

Answered to the best of my knowledge so I may be wrong, but google rarely is.

So, is DTD itself a well-formed XML document? (for choice of B in question above?)

I would say no.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.