Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DTD Question #23

 
Vasudha Deepak
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
This question is from the mock exam by Shashank.
Since the element root1 is mandatory,it should always be present.Could anyone please clarify why,the option C is not a part of the answers?
The correct answers for this question is D.
Thanks,
Vasudha

23> Which of the following XML documents will NOT get successfully validated against the DTD below.
<!ELEMENT root (root1,root2?,root3*)*>
<!ELEMENT root1 (#PCDATA)>
<!ELEMENT root2 (#PCDATA)>
<!ELEMENT root3 (#PCDATA)>
A>
<root>
<root1/>
<root2/>
</root>
B>
<root>
<root1> root1 data </root1>
<root1> root1 data </root1>
</root>
C> <root/>
D>
<root>
<root1/>
<root3/>
<root3/>
<root2/>
</root>
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pay attention to the second * in the DTD.
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
The DTD given is here -
23> Which of the following XML documents will NOT get successfully validated against the DTD below.
<!ELEMENT root (root1,root2?,root3*)*>
<!ELEMENT root1 (#PCDATA)>
<!ELEMENT root2 (#PCDATA)>
<!ELEMENT root3 (#PCDATA)>
now the option 3 has <root/>
This is valid as per the DTD as explained below -
1) You should look at the contents of the root element as a zero or many occurances (*) of the following group of elements
(root1, root2? root3*);
2) Now root2 and root3 need not be part of the group and i hope this is pretty straight forward as we have a ? and * in there for the respective elements; root1 is a must for the group and this is the minimum content the group can be made of;
If we club the minimum contents of the group with the condition (1) mentioned above (we are trying to justify the scenario of option 3 of the question), we may have (root1)* as the minimal configuration i.e., again zero or many occurances of root1;
Option 3 can be looked as zero occurances of root1 and hence is still valid as per the DTD;
I hope this clarifies your doubt;
 
Vasudha Deepak
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for clearing the doubt.
Vasudha
 
Niraj Sheth
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody explain why D is correct answer here? I think option D should also be validated against this DTD just fine ( because of second * )
Thanks,
Niraj
 
Vidya Nayak
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Niraj,
In option 'D' - the elements are not in order. root2 must be followed by root3...
regards,
Vidya
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic