Logo F2FInterview

XML Interview Questions

Q   |   QA

A Document Type Definition (DTD) defines the legal building blocks of an XML document. It defines rules for a specific type of document, including:

  •     Names of elements, and how and where they can be used
  •     The order of elements
  •     Proper nesting and containment of elements
  •     Element attributes

To apply a DTD to an XML document, you can:

  •     Include the DTD's element definitions within the XML document itself.
  •     Provide the DTD as a separate file, whose name you reference in the XML document.

An XML Schema describes the structure of an XML instance document by defining what each element must or may contain.XML Schema is expressed in the form of a separate XML file.

  • XML Schema provides much more control on element and attribute datatypes.
  • Some datatypes are predefined and new ones can be created.

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <xsd:element name="test">




Schema document is an XML document i.e., the structure of an XML document is specified by another XML document. DTDs follow SGML syntax.
Schema supports variety of dataTypes similar to programming language. In DTD everything is treated as text.
In Schema,  It is possible to inherit and create relationship among elements. This is not possible in DTD without invalidating existing documents.
In Schema, It is possible to group elements and attributes so that they can be treated as single logical unit. Grouping of elements and attributes is not possible in DTD.
In Schemas, it is possible to specify an upper limit for the number of occurrences of an element It is not possible to specify an upper limit of an element in DTDs

A complex element is an XML element that contains other elements and/or attributes.
There are four kinds of complex elements:

  •     empty elements
  •     elements that contain only other elements
  •     elements that contain only text
  •     elements that contain both other elements and text

A simple element is an XML element that can contain only text.

  •     A simple element cannot have attributes
  •     A simple element cannot contain other elements
  •     A simple element cannot be empty
  •     However, the text can be of many different types, and may have various restrictions applied to it

In order to link this F2FInterview's page as Reference on your website or Blog, click on below text area and pres (CTRL-C) to copy the code in clipboard or right click then copy the following lines after that paste into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code: