XML

Views:
 
Category: Education
     
 

Presentation Description

No description available.

Comments

Presentation Transcript

XML : 

XML Week 10 & 11

XML : 

XML ©Jibitesh Mishra, mishrajibitesh@gmail.com XML stands for EXtensible Markup Language XML is a markup language much like HTML XML was designed to carry data, not to display data XML tags are not predefined. You must define your own tags XML is designed to be self-descriptive

Difference between HTML & XML : 

Difference between HTML & XML XML was designed to transport and store data, with focus on what data is. HTML was designed to display data, with focus on how data looks HTML can use predefined tags e.g <p>, <h1>, etc. XML allows the author to define his own tags and his own document structure ©Jibitesh Mishra, mishrajibitesh@gmail.com

XML Tree : 

XML Tree XML document must contain a root element. This element is parent of all other elements All elements must have sub elements (child elements). Children on the same level are called siblings (brothers or sisters). ©Jibitesh Mishra, mishrajibitesh@gmail.com

Example of XML Tree : 

Example of XML Tree ©Jibitesh Mishra, mishrajibitesh@gmail.com

Example of XML Tree : 

Example of XML Tree ©Jibitesh Mishra, mishrajibitesh@gmail.com <bookstore>  <book category="COOKING">    <title lang="en">Everyday Italian</title>    <author>Giada De Laurentiis</author>    <year>2005</year>    <price>30.00</price>  </book>

Example of XML Tree : 

Example of XML Tree ©Jibitesh Mishra, mishrajibitesh@gmail.com <book category="CHILDREN">    <title lang="en">Harry Potter</title>    <author>J K. Rowling</author>    <year>2005</year>    <price>29.99</price>  </book>

Example of XML Tree : 

Example of XML Tree ©Jibitesh Mishra, mishrajibitesh@gmail.com <book category="WEB">    <title lang="en">Learning XML</title>    <author>Erik T. Ray</author>    <year>2003</year>    <price>39.95</price>  </book></bookstore>

Building blocks for XML : 

Building blocks for XML Elements: are the main building blocks of both XML and HTML documents Attributes: provide extra information about elements Entities: special meaning in XML, like the less than sign (<) that defines the start of an XML tag. PCDATA: Parsed character data, will be examined by parser for entities & markup CDATA: Character data ©Jibitesh Mishra, mishrajibitesh@gmail.com

DTD : 

DTD Internal DTD: If the DTD is declared inside the XML file, it should be wrapped in a DOCTYPE definition with the following syntax: <!DOCTYPE root-element [element-declarations] > External DTD: If the DTD is declared in an external file, it should be wrapped in a DOCTYPE definition with the following syntax: <!DOCTYPE root-element SYSTEM "filename"> ©Jibitesh Mishra, mishrajibitesh@gmail.com

DTD Elements : 

DTD Elements <!ELEMENT note (to,from,heading,body)><!ELEMENT to (#PCDATA)><!ELEMENT from (#PCDATA)><!ELEMENT heading (#PCDATA)><!ELEMENT body (#PCDATA)> When children are declared in a sequence separated by commas, the children must appear in the same sequence in the document ©Jibitesh Mishra, mishrajibitesh@gmail.com

DTD Elements : 

DTD Elements ©Jibitesh Mishra, mishrajibitesh@gmail.com

Declaring content : 

Declaring content Declaring either/or Content <!ELEMENT note (to,from,header,(message|body))> i.e. either message or body Declaring Mixed Content <!ELEMENT note (#PCDATA|to|from|header|message)*> note element can contain zero or more occurrences of parsed character data, "to", "from", "header", or "message" elements ©Jibitesh Mishra, mishrajibitesh@gmail.com

DTD Attributes : 

DTD Attributes <!ATTLIST element-name attribute-name attribute-type default-value> In a DTD, attributes are declared with an ATTLIST declaration. Example: <!ATTLIST payment type CDATA "check"> Then the XML example can be as follows: <payment type="check" /> ©Jibitesh Mishra, mishrajibitesh@gmail.com

DTD Attributes cont.. : 

DTD Attributes cont.. ©Jibitesh Mishra, mishrajibitesh@gmail.com