• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

DTD

 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it a good idea to include a DTD in the document that it defines?
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure if I got the meaning.
Your question is whether it is normal to put a line like
<!DOCTYPE sth PUBLIC "-//some org" "some_dtd.dtd"> ?
If yes, then this line serves validating parser which have to validate the XML document against the DTD that defines the valid syntax of the XML document. It is a means for the parser to find the DTD.
Let me know if your question was not that one
HIH

------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
 
Allan Moster
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that's my question.
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And does the answer satisfy you or do you need more in-depth explanations ?
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
 
Allan Moster
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess I need more explanation. I'm confused if I should create a separate file for the DTD to prevent it from being coupled to a specific document.
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it now...
you were asking if it was a good idea to put the contents of the DTD in an XML file...
Ok then. A good practice is to have a separate file for the DTD which you can then reference in your XML document and serves validation purposes.
Putting the content of the DTD within the XML file is not very elegant and moreover there is no way to reuse that DTD code for another XML document.
Imagine you want to write a DTD specifying the syntax of an XML document which stores different kinds of book libraries. You want to store, say, the title, the author and the ISBN of the books but you want to have a separate XML file for each topic (Sci-fi, Romans,Comics,...). Then you should definitely have a separate DTD that you reference inside each XML file, otherwise the maintenance of your DTD would be a nightmare when the number of XML files grows... I've never seen DTD written directly inside an XML file...
Anyone any insights about this ?

------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
 
Allan Moster
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Valentin. That's insightful!
 
Every time you till, you lose 30% of your organic matter. But this tiny ad is durable:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic