• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

DTD questions

 
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)>
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic