0
1.8kviews
explain xml application

Applications are :

  1. Tree model
  2. Data model
  3. DTD(Document Type Definition)
  4. XSD(XML Schema Definition)
1 Answer
0
37views
  • eXtensible Markup Language (XML) is developed by the World Wide Web Consortium (W3C), which is used as a format to store and transfer data over the Web.
  • XML is a markup language based on simple, platform-independent rules for processing and displaying textual information in a structured way.
  • XML was designed to carry data, not to display data.

XML Tree Model

  • An XML application or document is always descriptive.
  • The tree model is often referred to as XML Tree and plays an important role to describe any XML application easily.
  • The XML tree mode contains root or parent elements, child elements, and so on.
  • By using this tree model, anyone can get to know all succeeding branches and sub-branches starting from the root.
  • The parsing starts at the root, then moves down the first branch to an element, takes the first branch from there, and so on to the leaf nodes.

Example:

<?xml version="1.0" encoding="UTF-8"?>
<bookstore>  
<book>  
    <author>J K. Rowling</author> 
    <title>Harry Potter</title>  
    <year>2005</year>    
  </book>  
  <book>   
    <author>Binita Mayekar</author>  
    <title>Internet Programming</title> 
    <year>2018</year>    
  </book>  
</bookstore>

Below XML Tree Model represents the above simple XML document or application code:

XML Tree Model Structure

XML Data Model

  • The data model for XML is very simple or very abstract, depending on one's point of view.
  • XML provides no more than a baseline on which more complex models can be built. All those more restricted applications will share some common invariants, however, and it is those that are given below.
  • Think of an XML document as a linearization of a tree structure.
  • At every node in the tree there are several character strings. The tree structure and the character strings together form the information content of an XML document. Almost everything will follow naturally from that.
  • Some of the characters in the document are only there to support the linearization, others are part of the information content.

XML Document Type Declaration (DTD)

  • The XML Document Type Declaration, commonly known as DTD, is a way to describe XML language precisely.
  • DTDs check vocabulary and validity of the structure of XML documents against grammatical rules of appropriate XML language.
  • Its main purpose is to define the structure of an XML document. It defines the legal building blocks of an XML document. For this, it contains a list of legal elements and attributes.
  • With a DTD, independent groups of people can agree on a standard DTD for interchanging data.
  • An application can use a DTD to verify that XML data is valid.
  • A valid XML document must include the reference to DTD which validates it. When a DTD is absent then validating parser can’t verify the data format but can try an attempt to interpret the data.
  • An XML DTD can be either specified inside the document, or it can be kept in a separate document and then liked separately.
  • Syntax for XML DTD is <!DOCTYPE root-element [element-declarations]>

The DTD for the above simple XML code is as follows:

<?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE bookstore [
 <!ELEMENT bookstore (book)+>
 <!ELEMENT book (author,title,year)>
 <!ELEMENT author (#PCDATA)>
 <!ELEMENT title (#PCDATA)>
 <!ELEMENT year (#PCDATA)>
 ]>

<bookstore>  
<book>  
    <author>J K. Rowling</author> 
    <title>Harry Potter</title>  
    <year>2005</year>    
  </book>  
  <book>   
    <author>Binita Mayekar</author>  
    <title>Internet Programming</title> 
    <year>2018</year>    
  </book>  
</bookstore>

XML Schema Definition (XSD)

  • The XML Schema Definition (XSD) is a way to describe the structure of an XML application.
  • It is comparatively simpler than XML DTD and gives users more control over the structure of XML applications.
  • It supports namespace, data types, extensible to additions, and is written in XML which makes XSD more powerful than XML DTD which doesn't support these features.
  • It defines the rules for all the attributes and elements in an XML application.
  • It can also be used to generate XML applications.
  • It also checks the vocabulary of the applications.
  • It doesn’t require processing by a parser.
  • XSD checks for the correctness of the structure of the XML file.

The XSD for the above simple XML code is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  <xs:element name="bookstore">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" ref="book"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="book">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="author"/>
        <xs:element ref="title"/>
        <xs:element ref="year"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="author" type="xs:string"/>
  <xs:element name="title" type="xs:string"/>
  <xs:element name="year" type="xs:integer"/>
</xs:schema>
Please log in to add an answer.