Its initial objective is to facilitate the automated exchange of contents between heterogeneous information systems (interoperability), especially on Internet. The initial objective is explains at the begin of the specification of February 10th 1998, this sentence is

Its goal is to enable generic SGML to be served, received, and processed on the Web in the way that is now possible with HTML.

Its objective was to define a generic language, but easier: XML has been designed for ease of implementation XML is a under set of SGML (Standard Generalized Markup Language), defined by the standard ISO8879 in 1986, used in the environment of the Documentary Electronic Management ( GED). XML resumes the major part of the features of SGML; it is about a simplification of SGML to make it useful on Web!


Example of XML synthax

<article xmlns="http://docbook.org/ns/docbook">

  <title>Extensible Markup Language</title>
  <para>
    <acronym>XML</acronym> (Extensible Markup Language, 
    « langage de balisage extensible »)...
  </para>
</article>


History

  • Jan 2001:IETF Proposed Standard: XML Media Types
  • Nov '99 : XSL Transformations (XSLT) Version 1.0, XML Path Language (XPath) Version 1.0
  • Jun '99 : W3C Recommendation: Associating stylesheets with XML documents (press release)
  • Jan '99: W3C Recommendation: Namespaces in XML (press release, coverage) (also: articles by WG members Clark, Bray and one by Bourret)
  • Feb 1998 : W3C Recommendation: Extensible Markup Language (XML) 1.0 (2nd edition 6 October 2000)


Conclusion

SGML insisted especially on the validation (See DTD and XML Schema), on the correspondence to a binding model. XML planned a more flexible usage of the structured information; he specifies a means to make live several vocabularies of markup in the same document (See Namespace). It has been amazing to see how quickly the XML standard has been developed and how quickly a large number of software vendors have adopted the standard. We strongly believe that XML will be as important to the future of the Web as HTML has been to the foundation of the Web and that XML will be the most common tool for all data manipulation and data transmission. It is important to understand that XML is not a replacement for HTML. In future Web development it is most likely that XML will be used to describe the data, while HTML will be used to format and display the same data.


Source: Wikipedia, W3Schools, W3C


DTD

A Document Type Definition (DTD) is a document allowing describing a model of document SGML or XML. A DTD indicates the names of elements which can appear and their contents, i.e. sub-elements and attributes. Except the attributes, the contents are specified by indicating the name, the order and the number of occurrences authorized by sub-elements. DTD establishes the definition of the valid hierarchies of elements and text. On the other hand, the DTD does not allow putting constraints on the value of the text. A DTD can be declared inline inside an XML document, or as an external reference.

Internal DTD Example

Syntax : <!DOCTYPE root-element element-declarations>
XML file: <?xml version="1.0"?> <!DOCTYPE note [

 <!ELEMENT note (to,from,heading,body)>
 <!ELEMENT to      (#PCDATA)>
 <!ELEMENT from    (#PCDATA)>
 <!ELEMENT heading (#PCDATA)>
 <!ELEMENT body    (#PCDATA)>

]> <note>

 <to>Tove</to>
 <from>Jani</from>
 <heading>Reminder</heading>
 <body>Don't forget me this weekend</body>

</note>

External DTD Example

Syntax: <!DOCTYPE root-element SYSTEM "filename">

XML file:
<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "note.dtd">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

Note.dtd:
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>


Conclusion

With a DTD, each of your XML files can carry a description of its own format. With a DTD, independent groups of people can agree to use a standard DTD for interchanging data. Your application can use a standard DTD to verify that the data you receive from the outside world is valid. You can also use a DTD to verify your own data. We saw that with the DTD, it was possible to define a legal building blocks of an XML document, but it is also the role of the XML Schema. So let us study closer the schema XML.


Source : wikipedia & w3schools


XML Schema

XML Schema is a language of description of structure of document XML. A XML Schema is itself a XML file. The knowledge of the structure of a document XML allows verifying the validity of this document. XML Schema Description or XSD file) is itself a document XML. XML Schema is a little the equivalent of a DTD. XML Schema brings however several differences with the DTD: it allows for example to define domains of validity for the value of a field, whereas it is not possible in a DTD; on the other hand, XML Schema does not allow defining entities.


What is an XML Schema?

The purpose of an XML Schema is to define the legal building blocks of an XML document, just like a DTD. An XML Schema:

  • defines elements that can appear in a document
  • defines attributes that can appear in a document
  • defines which elements are child elements
  • defines the order of child elements
  • defines the number of child elements
  • defines whether an element is empty or can include text
  • defines data types for elements and attributes
  • defines default and fixed values for elements and attributes


XML Schemas vs DTDs

We think that very soon XML Schemas will be used in most Web applications as a replacement for DTDs. Here are some reasons:

  • XML Schemas are extensible to future additions
  • XML Schemas are richer and more powerful than DTDs
  • XML Schemas are written in XML
  • XML Schemas support data types
  • XML Schemas support namespaces


XSD

An XML Schema instance is an XML Schema Definition (XSD) and typically has the filename extension ".xsd". The language itself is sometimes informally referenced as XSD. It has been suggested that WXS (for W3C XML Schema) is a more appropriate initialism though this acronym has not been in a widespread use and W3C working group rejected it. XSD is also an initialism for XML Schema Datatypes, the datatype portion of XML Schema.


Example of XSD file

<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

 <xs:element name="personne">
    <xs:complexType>
       <xs:sequence>
          <xs:element name="nom" type="xs:string"/>
          <xs:element name="prenom" type="xs:string"/>
          <xs:element name="date_naissance" type="xs:date"/>
       </xs:sequence>
    </xs:complexType>
 </xs:element>

</xs:schema>


Example of XML file

<?xml version="1.0" encoding="UTF-8"?> <personne xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="personne.xsd">

 <nom>de Latour</nom>
 <prenom>Jean</prenom>
 <date_naissance>1967-08-13</date_naissance>

</personne>


XDR

(XML-Data Reduced) An XML schema language from Microsoft prior to the W3C XML schema. XDR was released in 1999 as a working schema as part of Microsoft's BizTalk initiative. XDR supports data typing and XML namespaces. See XML schema and XML.


Source : wikipedia & w3schools


Namespaces

XML namespaces provide a simple method for qualifying element and attribute names used in Extensible Markup Language documents by associating them with namespaces identified by URI references.


XML namespaces

The XML namespace attribute is placed in the start tag of an element and has the following syntax: xmlns:namespace-prefix="namespaceURI"
When a namespace is defined in the start tag of an element, all child elements with the same prefix are associated with the same namespace. Note that the address used to identify the namespace is not used by the parser to look up information. The only purpose is to give the namespace a unique name. However, very often companies use the namespace as a pointer to a real Web page containing information about the namespace.


Example

When you start using XSL, you will soon see namespaces in real use. XSL style sheets are used to transform XML documents into other formats, like HTML. If you take a close look at the XSL document below, you will see that most of the tags are HTML tags. The tags that are not HTML tags have the prefix xsl, identified by the namespace "http://www.w3.org/1999/XSL/Transform":

<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body>

 <h2>My CD Collection</h2>
 <table border="1">
   <tr>
     <th align="left">Title</th>
     <th align="left">Artist</th>
   </tr>
   <xsl:for-each select="catalog/cd">
   <tr>
     <td><xsl:value-of select="title"/></td>
     <td><xsl:value-of select="artist"/></td>
   </tr>
   </xsl:for-each>
 </table>

</body> </html> </xsl:template> </xsl:stylesheet>