What is difference between xsd and dtd?

Answers were Sorted based on User's Feedback



What is difference between xsd and dtd?..

Answer / g.h

DTD stands for "Document Type Definition". In the context of
XML, it serves as an exact specification of what may appear
in an instance document. A DTD consists of a number of
declarations that appear directly in a document or are
referenced as external resources.

XSD is the file type of W3C XML Schemas, standing for "XML
Schema Definition". Contrary to DTDs, XML Schemas are built
up as XML documents themselves, using XML to describe
itself. A schema is external to an XML document. It can be
referenced in the document for automatically retrieving the
schema for validation.

Both DTD and W3C XML Schema are XML schema languages, but
W3C XML Schema is a lot more flexible and has namespace
support, which is still lacking in the current version of
the DTD standard. Another advantage of XSD is the use of
data types.

Is This Answer Correct ?    12 Yes 1 No

What is difference between xsd and dtd?..

Answer / umarali1981

DTD:

1. Abbreviation: DTD stands for Document Type Definition
2. Markup validation: Can specify only the root element in
the instance document. No ambiguous content support.
3. Namespace support : DTD does not support namespace
instead it has its own set of keywords for defining a schema

example:
!DOCTYPE for root tag
!ELEMENT for an element
!ATTLIST for an attribute
!ENTITY for defining variables.
4. Code reuse: Poorly supported. Can use parameter entities.
5. Datatype Support :No real datatype support. DTD has only
#PCDATA as the data type for the elements.(it is used for
string datatype)
6. Datatype Validation: In DTD, no such restrictions
7. Uses: DTD is more suitable for small XML Data
ex:bookname,companyname etc.
8. Strongly / Weakly typed: DTD is weaky typed.DTD lacks
strong typing capabilities, and has no way of validating the
content to data types.
9. Provisions of Inline Definitions:DTD allows inline
definitions.This is good when working with small files, as
it allows us to contain both the content and the schema
within the same document, but when it comes to larger
documents, this can be a disadvantage, as we pull content
every time we retrieve the schema. This can lead to serious
overhead that can degrade performance.

XSD:

1. Abbreviation: XSD stands for Xml Schema Definition
2. Markup validation: Any global element can be root. No
ambiguous content support.
3. Namespace support :XSD uses its own set of namespaces and
elements for defining the schema.
4. Code reuse:Can reuse definitions using named types.
5. Datatype Support :Provides flexible set of datatypes.

1. primitive / fundamental data types:
string,decimal,float,boolean
2. Custom Data types
i. complex type : a data type that contains child elements
or attributes and
also the mixed contents
ii. simple type : a data type that contains only values.

Provides multi-field key cross references. No co-occurrence
constraints.
6. Datatype Validation: XSD allows us to specify restriction
on data .

Example: tag. we can write only digits here.
7. Uses: XSD is used in large XML Data ex: ADO.NET DataSets,
Web Services.
8. Strongly / Weakly typed: XML Schema is strongly typed.An
XML Schema can define the data type of certain elements, and
even constrain it to within specific lengths or values. This
ability ensures that the data stored in the XML document is
accurate.
9. Provisions of Inline Definitions: XML Schema does not
allow inline definitions

Reference:
http://onlydifferencefaqs.blogspot.in/2012/08/difference-between-dtd-and-xsd.html

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More XML XSLT RSS Interview Questions

What is the difference between xml and xslt?

0 Answers  


Why do we use xslt?

0 Answers  


Define xpath? And what is xslt?

0 Answers  


What is xml and xsl?

0 Answers  


What are the different types of parts used in xsl?

0 Answers  






How do I make a pdf into a picture?

0 Answers  


Does anyone use xslt anymore?

0 Answers  


Define cdata?

0 Answers  


Is xml a web service?

0 Answers  


Can you walk us through the steps necessary to parse XML documents?

3 Answers  


Whether graphics can be used in XML? If so, How?

0 Answers  


How do I convert an xml file to excel?

0 Answers  


Categories