File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Product and Other Certifications and the fly likes DTD questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "DTD questions" Watch "DTD questions" New topic
Author

DTD questions

Elizabeth King
Ranch Hand

Joined: Jul 11, 2002
Posts: 191
Hi
Are the following DTD definitions for an
element <book> correct? I think both are correct.
A) <!ELEMENT title #PCDATA>
<!ELEMENT author #PCDATA>
<!ELEMENT book (#PCDATA, title, author)>
B> <!ELEMENT title #PCDATA>
<!ELEMENT author #PCDATA>
<!ELEMENT book (#PCDATA, title, #PCDATA, author, #PCDATA)>
Thanks.
Rakesh Gudur
Ranch Hand

Joined: Apr 29, 2002
Posts: 79
Hai Mary,
Both of them are incorrect. The DTD should be something like
<!ELEMENT author (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT book (#PCDATA | author | title)*>
When I put the other ones in XML Spy, it gives an error. The above one is correct. Hope this helps.
Rakesh.
Luciano Queiroz
Ranch Hand

Joined: Feb 04, 2002
Posts: 172
In addition, I would like to remind you of a little detail.
In a DTD, when you declare a mixed element, the #PCDATA child must be the first sub-element inside the parenthesis.
Ex.:
<!ELEMENT house (#PCDATA, door, window)>


<b>Luciano Queiroz</b><br/>
 Brazil<br/>
 <i>SCJP 1.2, SCWCD, IBM 141, IBM 483, SCJP 1.4, IBM 484, IBM 287, SCBCD, SCEA, SCJP 5.0, SCJP 6.0, SCWCD 5</i>
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1175
The only two ways PCDATA can be used are -
by itself -
<!ELEMENT house (#PCDATA)>
or in a mixed content model -
<!ELEMENT house (#PCDATA | door | window)*>
Cheers,
Dan


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Jerry Sheehan
Greenhorn

Joined: Mar 19, 2002
Posts: 12
Why are you still writing DTD's anyway? XSD schemas are much more powerful and if you already have existing DTD's, you can use XMLSpy to convert it to a W3C compliant XSD.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DTD questions