XML Key Components DTD Prepared By:  Rajan Shah
XML- eXtensible Mark-up Language  Xml provides data storage and transportation facility.  In xml there are no predefined tags. All the tags are user-defined.  It is a language which describes other languages
Advantages of XML  It is readable by both- humans and machines  It is self documenting  Independent of OS  Used to display meta contents  Useful in exchanging data between applications  Neutral language
KEY components  Elements  Attributes  Other essentials  Namespaces
Elements  Elements must have a closing tag  Tags are case sensitive  Elements must be correctly nested  Must have root element  < b >< i > Hello </ b ></ i > -- Is not correct  < br >-- used alone is not allowed. It must be closed
Attributes  Attribute values must be quoted to be considered legal in xml  <attrib-name value=“xyz”>Hello </ attrib-name > -- is valid.
Other Essentials  White spaces are not trimmed to a single space  Carriage return(CR) and linefeed(LF) combination at the end of text lines, is translated to Lf by xml
Namespaces  It is possible to associate a namespace with element to distinguish them from other similar named elements in other projects, when sharing two or more documents  Usually takes the form of a url, beginning with a domain name, an optional namespace label in the form of a directory and finally a version no.(optional)  Example: xmlns: “http://www.domain.com/ns/1.1”
DTD- Document Type Data  Dtd is used to define the basic building blocks of any XML document.  It is used to specify the sequence of elements and what data to be parsed and what not.  It is used to specify the set of rules for structuring data in XML File.
Example of DTD  memo.dtd (External DTD File) <!ELEMENT memo (to, from, message)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT message (#PCDATA)>
Continue  readmemo.xml <?xml version=“1.1”?> <!DOCTYPE memo SYSTEM memo.dtd> <memo> <to>XYZ</to> <from>ABC</from> <message>Hello</message> </memo>
Understanding DTD File  Document of type “memo” is created, having 3 elements– to, from, message, each having data type PCDATA- parsed character data, which refers to everything except mark-up  DTD describes XML in terms of elements, tags, attributes, entities, PCDATA and CDATA.
Advantages of DTD  Advantages: 1. Used to define the structural components of XML document 2. Simple and Compact 3. Can be Embedded directly inn XML document
Disadvantages  Disadvantages: 1. Cant define the type of DATA contained in XML document 2. DTD’s are not aware of the concept of Namespace 3. DTD’s are not W3C recommendation.
Xml dtd- Document Type Definition- Web Technology

Xml dtd- Document Type Definition- Web Technology

  • 1.
  • 2.
    XML- eXtensible Mark-upLanguage  Xml provides data storage and transportation facility.  In xml there are no predefined tags. All the tags are user-defined.  It is a language which describes other languages
  • 3.
    Advantages of XML It is readable by both- humans and machines  It is self documenting  Independent of OS  Used to display meta contents  Useful in exchanging data between applications  Neutral language
  • 4.
    KEY components  Elements Attributes  Other essentials  Namespaces
  • 5.
    Elements  Elements musthave a closing tag  Tags are case sensitive  Elements must be correctly nested  Must have root element  < b >< i > Hello </ b ></ i > -- Is not correct  < br >-- used alone is not allowed. It must be closed
  • 6.
    Attributes  Attribute valuesmust be quoted to be considered legal in xml  <attrib-name value=“xyz”>Hello </ attrib-name > -- is valid.
  • 7.
    Other Essentials  Whitespaces are not trimmed to a single space  Carriage return(CR) and linefeed(LF) combination at the end of text lines, is translated to Lf by xml
  • 8.
    Namespaces  It ispossible to associate a namespace with element to distinguish them from other similar named elements in other projects, when sharing two or more documents  Usually takes the form of a url, beginning with a domain name, an optional namespace label in the form of a directory and finally a version no.(optional)  Example: xmlns: “http://www.domain.com/ns/1.1”
  • 9.
    DTD- Document TypeData  Dtd is used to define the basic building blocks of any XML document.  It is used to specify the sequence of elements and what data to be parsed and what not.  It is used to specify the set of rules for structuring data in XML File.
  • 10.
    Example of DTD memo.dtd (External DTD File) <!ELEMENT memo (to, from, message)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT message (#PCDATA)>
  • 11.
    Continue  readmemo.xml <?xml version=“1.1”?> <!DOCTYPEmemo SYSTEM memo.dtd> <memo> <to>XYZ</to> <from>ABC</from> <message>Hello</message> </memo>
  • 12.
    Understanding DTD File Document of type “memo” is created, having 3 elements– to, from, message, each having data type PCDATA- parsed character data, which refers to everything except mark-up  DTD describes XML in terms of elements, tags, attributes, entities, PCDATA and CDATA.
  • 13.
    Advantages of DTD Advantages: 1. Used to define the structural components of XML document 2. Simple and Compact 3. Can be Embedded directly inn XML document
  • 14.
    Disadvantages  Disadvantages: 1. Cantdefine the type of DATA contained in XML document 2. DTD’s are not aware of the concept of Namespace 3. DTD’s are not W3C recommendation.