• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Difference between Schema and DTD?

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
Can you pl tell me what is the difference bet'n Schema and DTD?
which one is mostly in use?
Thank you.
 
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's funny. I was just about to post the same question. Ajith, I was going to use a DTD for the project in the cattle drive, but seeing how an XML schema let's me control date and and type more carefully, would you recommend using an XML schema or a DTD? The more I look at it the more the XML schema looks better.
Thanks,
Bill
 
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most parsers don't have built in support for validation against schemas as of yet, which is why DTD's are used more widely. Schemas will probably be the validation of choice in the future though, as it gets more widely accepted.
Brian
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, a Schema uses XML to describe XML.
DTD's use a hideous language called BNF (Backus Naur Form). I once tried to write a DTD with Notepad, but the BNF brought me to my knees. I switched to XMLSpy, which is a very cool visual product, and it will produce both BNF and XMLSchema DTD's.
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is possible to express a lot more with Schema than with DTD. For instance, you can't control the element content at all with DTD and attribute content can only be controlled via primitive regular types. XML Schema has got a lot of datatypes (som very exotic!), that applies both to element and attribute content.
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lets not forget, DTD is still quite popular and Schema has a long way to go before it becomes as popular.
Agreed, XML Schema is more flexible, more descriptive and more intuitive than DTD. But there is a overhead involved in using the Schema. Since an xsd( Schema definition ) document itself is an XML document, the parser will have to first process the schema to make sure it is well-formed. This may not be a significant overhead, but it still is an extra processing step. With all the fancy things Schema supports, one can come up with a really complex Schema definition and degree of complexity adds to the overhead. As XML standards evolve, the ability to write more complex documents will also increase.
Ofcourse DTDs are also parsed in someway. However since they are simple and "flat-structured", it isn't a big deal.
Bottom line ( IMHO ) - if DTD can do your job, there is no need to consider XML Schema. If DTD falls short of representing your XML documents because of its limitations, then consider using XML Schema.
Cheers!
------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
IBM Certified Developer - XML and Related Technologies, V1.
 
Steffen Foldager
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think the overhead in large xsd's should be considered. After all, the typical situation would be that you have lots of xml documents and only a handfull of xsd's. The parsed xsd's can be kept in memory (as can xsl stylesheets) and reused.
The overhead is considerably bigger in humans writing, reading, and understanding the xsd's than in machines using them.
I think the choice between DTD and XML Schema is more of a choice between established technology and bleeding edge. There are plenty of DTD's out there, but not a lot of XSD's.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!