E Tensible Arkup Anguage: I. Nabeela Jasmine
E Tensible Arkup Anguage: I. Nabeela Jasmine
I. NABEELA JASMINE
Page 1
XML is useful for representing any structured or unstructured data. Structured data refers to data that is identifiable because it is organized in a structure. Unstructured data refers to data that has no identifiable structure. For example: Videos, email Any such document following XML rules are said to be as XML document.
Page 2
XML stands for Extensible Markup Language. It is similar to HTML but designed to describe data. XML tags are not predefined. We define our own tags. It uses a Document Type Definition (DTD) or an XML schema to describe the data.
Page 3
DTD defines a legal building block of an XML document. It defines the document with list of its elements and attributes. DTD can be declared in 2 ways: Inside an XML document(internal DTD) As an external reference(externalDTD)
Page 4
If DTD is declared inside XML file, it should be wrapped in a DOCTYPE definition with the following syntax:
<!DOCTYPE root_element[element_declaration]>
Page 5
EXAMPLE
<?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>
Page 6
!ELEMENT to defines the to element to be of type "#PCDATA(parsed character data) it is keyword to specify mixed content, an element may contain character data as well as child element in an orbitary order. Example: <!ELEMENT b(#PCDATA)>
<!ELEMENT p(#PCDATA|a|b)*> in this code element b must contain character data only,element p can contain a mixture of any combination of character data <a>,<b> elements. !ELEMENT from defines the from element to be of type "#PCDATA !ELEMENT heading defines the heading element to be of type "#PCDATA !ELEMENT body defines the body element to be of type "#PCDATA"
Page 7
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">
Page 8
EXAMPLE
<?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> Page 9
XML SCHEMA
XML Schema is an XML-based alternative to DTD. An XML schema describes the structure of an XML document.
Page 10
Cont
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
Page 12
AN XML SCHEMA
The following example is an XML Schema file called "note.xsd" that defines the elements of the XML document above ("note.xml"): <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com" elementFormDefault="qualified">
Page 13
XML
Data is stored in separate XML files. It is user defined language. It is used to describe data and focus on what data is All elements must be properly nested within each other XML is dynamic Is case-sensitive
It is predefined language. It is used to display data and focus on how data looks Not much necessary
It is static Not case-sensitive
Page 14
When HTML is used to display data, the data is stored inside your HTML with XML, data can be stored in separate XML files.
Page 16
Page 17
XML ELEMENTS
XML elements must have a closing tag. The following example is legal in HTML. <p> This is a paragraph <p> This is a another paragraph In XML all elements must have a closing tag. <p> This is a paragraph</p> <p> This is a another paragraph</p> Page 19
With XML, the tag <Letter> is different from <letter> opening and closing tags must therefore be written in same case.
THANK YOU!
Page 22