• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML DTD fundamental doubts

 
Kingsly Theodar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

The questions given below are taken from the sample exam given for XML DTD at our site.

Since some answers lack explanation, I am posting this here.

Can someone please explain?

Q1. 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)>

I hope for the above question the answers are b and d. But the site shows only b. Am I correct?


Q3. 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)>]>

I hope for the above question the answer is a alone, whereas the site shows a and c. Can you please explain why?

Q6.
Is the following declaration valid?
<!ENTITY lt "*(&5;#">

Thanks in advance,
T.Kingsly
 
Randy Oneil
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just create a XML file with a DTD section to run your scenarios in Internet Explorer, it will show the errors if there is any.
 
yuan fang
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q1 I agree with you ,and Q3 ,I think only a is right ,in choose c :there is something wrong with this text,"[ <!ELEMENT test.dtd (#PCDATA|elm1|elm2)* >]> " we cann`t make choose between #PCDATA and elements,if delete "#PCDATA|" it`s legal.
 
Nitish Bahadur
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
#Q3

Here are the various combinations I can think of:

<!DOCTYPE test [
<!ELEMENT test.dtd (#PCDATA|elm1|elm2)* >
<!ELEMENT elm1 (#PCDATA)>
<!ELEMENT elm2 (#PCDATA)>
]>

Case 1: Just #PCDATA
<test>
<!-- use only #PCDATA -->
Here is some parsed character data.
</test>

Case 2: Just elm1
<test>
<elm1>Here is some more text</elm1>
</test>

Case 3: Just elm2
<test>
<elm2>Here is more text</elm2>
</test>

Will this work?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic