File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes XML DTD vs Schema Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML DTD vs Schema" Watch "XML DTD vs Schema" New topic
Author

XML DTD vs Schema

Brian Nguyen
Greenhorn

Joined: Mar 19, 2002
Posts: 22
Helle everyone,
I am new to XML technologies. I just have simple question, what is the difference between DTD and Schema?
Also, could you show me good tutorials from Internet about DTD and Schema as well as how to create them.
Thanks for your help,
Brian
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12821
    
    5
DTD stands for Document Type Definition - it contains information on how the elements inside the XML document are related to each other. The format of a DTD is not XML unfortunately.
A Schema is a way of describing an XML document in greater detail so that not only the relationship of the elements but also their allowed content can be described. Schema documents are valid XML documents which makes it easier for them to be manipulated.
The best place to look for authoritative documentation on XML, DTDs and Schema is the W3C
http://www.w3.org/
Bill
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
Also, here is an old post for the same topic.
Debbie Argulkar
Ranch Hand

Joined: Jul 26, 2002
Posts: 43
Hi,
In the mock exam XML design questions, there is a question :
Problem :
North American Real Estate Associates, a realtor agency would like to convert their inventory listings into XML format. Until now, they used a commercial application to retrive the information from the database and render it to their clients in the HTML format.
Apart from being able to supply the inventory information to various different clients (web, handheld, wireless devices etc.), the new XML-based system should also allow numerous real-estate agents across the country to send their local inventory listings to a central application. The new listings and/or update of existing listings will arrive by email as an XML document. A processing application is required to be designed that will analyze the incoming XML documents once everyday and will bring up to date the master database.

Would you say that in such a scenario, using DTD offers more flexibility than using a schema because of less constraints? I think that the same level of constraints that can be achieved by a DTD can be achieved by a Schema simply by omiting those. But is there any other advantage to using DTD that I am not aware of?
Thanks,
Deb
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
Originally posted by Debbie Argulkar:
Would you say that in such a scenario, using DTD offers more flexibility than using a schema because of less constraints? I think that the same level of constraints that can be achieved by a DTD can be achieved by a Schema simply by omiting those. Deb

I agree.
But is there any other advantage to using DTD that I am not aware of?
The only one I am aware of is that DTD supports entities and Schema doesn't. But entites do not seem to be crucial part of this application, and their support is a very minor advantage compared to all other things Schema is much better in.
Sumit Amar
Ranch Hand

Joined: Jun 08, 2002
Posts: 180
The purpose of DTD and Schema is almost same, but the streamline difference is that, using Schemas for making valid documents makes XML language independent. because DTDs are written in Extended Backus-Naur Form, which is not XML ! If we are looking for designing our validity statements in pure XML we should go for XML Based Schemas. However, writing DTDs can be a little easy.


SCJP, SCWCD, OCA, OCP-DBA 9i, <a href="http://brainbench.com/transcript.jsp?pid=2232802" target="_blank" rel="nofollow">BCIP</a>, MCP, MCAD, MCSD.NET, MCDBA, MCTS (SQL 05), MCITP (DBD, DBA)
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
To clear some misconceptions:
1. using Schemas will not make documents valid. Compliance to Schema will.
2. using Schemas will not make XML language independent. XML *is* a language, how can a language be "language independent"? If by XML you mean "specification of its structure", be it DTD or Schema or something else, than preference of one language (XML) over another (EBNF) to express it will not make such a specification language independent either.
Accidentally, "XML Certfication" forum is discussing this subject today I posted a quote from David Mertz's "Comparing W3C XML Schemas and Document Type Definitions (DTDs)" there.
Deepak Gupta
Greenhorn

Joined: Aug 25, 2002
Posts: 7
I would like to add a few points here
1.Schemas offer great support for the data types which DTD does not.
2.In Schemas you can define ur own data type and use them as a new data type.
3.You can define the pattern too.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XML DTD vs Schema