• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DTD

 
Ravikiran Muvva
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
This sample question is from the DTD sample Question you have provided in Javaranch site.
Could you please let me know why optionDis not the correct answer for this?
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)>
Answer : b
Thanks & Regards
Ravikiran
 
Falk Lucius
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravikiran,
the answer is that option "D" contains invalid syntax.
You may add an asterisk immediately after a child name, or after the closing bracket of an enumeration of child elements if these are all optional, like:
<!ELEMENT test (this|that)*>
But what did the author of
<!ELEMENT test (this,that)*>
really intend? Did he mean that the test element contains any number of paired this and that elements? If so, he should introduce another structure level, like:
<!ELEMENT supertest (test*)>
<!ELEMENT test (this,that)>
Hope that helps.
 
Micheal Jacob
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
How can you specify like
<!ELEMENT test (#ANY)>
is this right ??
Micheal
 
Tong Chen
Ranch Hand
Posts: 1011
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please note that in the anwser D
<!ELEMENT this(#PCDATA)>
<!ELEMENT that(#PCDATA)>
there must be a space between "this", "that" and "(#PCDATA)" like
<!ELEMENT this (#PCDATA)>
<!ELEMENT that (#PCDATA)>
So the anwser D is not right.
Otherwise,
<!ELEMENT test (this,that)*>
<!ELEMENT this (#PCDATA)>
<!ELEMENT that (#PCDATA)>
is a ABSOLUTELY VALID DTD.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic