rocket mass heater kickstarter
The moose likes Product and Other Certifications and the fly likes XML DTD fundamental doubts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "XML DTD fundamental doubts" Watch "XML DTD fundamental doubts" New topic

XML DTD fundamental doubts

Kingsly Theodar

Joined: Feb 21, 2004
Posts: 19
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)*>

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)* >]>
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?

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

Thanks in advance,
Randy Oneil

Joined: May 26, 2005
Posts: 1
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

Joined: May 23, 2005
Posts: 5
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

Joined: Aug 25, 2003
Posts: 118

Here are the various combinations I can think of:

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

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

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

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

Will this work?
It is sorta covered in the JavaRanch Style Guide.
subject: XML DTD fundamental doubts