Вы находитесь на странице: 1из 41

EXtensible Markup Language (XML)

Guided By: Mr. Nitin Rathore

Submitted By: Mukesh Madnani (IT 27) Nishit Agrawal (CS56) Ronak Neema (CS 68) Sanket Nayak (CS 73)

What is XML ?
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 self-

Comparison b/w xml & html


XML  Extensible set of tags  Content orientated  Standard Data infrastructure  Allows multiple output forms HTML Fixed set of tags  Presentation oriented  No data validation capabilities  Single presentation

NOTE : XML was designed to transport and store data, with focus on what data is Whereas HTML was designed to display data, with focus on how data looks

Html code just displaying data


<html> <body> <p><b>This text is bold</b></p> <p><strong>This text is strong</strong></p> <p><big>This text is big</big></p> <p><em>This text is emphasized</em></p> <p><i>This text is italic</i></p> <p><small>This text is small</small></p> <p>This is<sub> subscript</sub> and <sup>superscript</sup></p> </body> </html>

RESULT :
This text is bold This text is strong This text is big This text is emphasized This text is italic This text is small This is subscript and superscript

Why xml ?
XML was created to structure, store, and transport information. With XML You Invent Your Own Tags XML is Not a Replacement for HTML XML Separates Data from HTML XML Simplifies Data Sharing XML Simplifies Data Transport XML Simplifies Platform Changes XML Makes Your Data More Available XML is Used to Create New Internet Languages

An Example XML Document


<?xml version="1.0" encoding="ISO-8859-1"?> encoding="ISO-8859<note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>

What is an XML Element?


An XML element is everything from (including) the element's start tag to (including) the element's end tag. An element can contain: other elements text attributes or a mix of all of the above...

XML Attributes
Attributes provide additional information about elements. Example : <person age=21"> <firstname>Ana</firstname> <lastname>Smith</lastname> </person>

Tree like structure of xml


<bookstore> <book category="COOKING"> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book category="CHILDREN"> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> </bookstore>

Well Formed XML Documents


A "Well Formed" XML document has correct XML syntax. XML documents must have a root element XML elements must have a closing tag XML tags are case sensitive XML elements must be properly nested XML attribute values must be quoted
<?xml version="1.0" encoding="ISO-8859-1"?> encoding="ISO-8859<note> <to>Tove</to> <To>nike <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>

Valid XML Documents


A "Valid" XML document is a "Well Formed" XML document, which also conforms to the rules of a Document Type Definition (DTD) Document Type Definition (DTD) A Document Type Definition (DTD) defines the legal building blocks of an XML document. It defines the document structure with a list of legal elements and attributes.

A DTD can be declared as :  Internal DTD declaration.  External DTD declaration.

Internal DTD Declaration


SYNTEX : <!DOCTYPE root-element [element-declarations]> root[elementExample of XML document with an internal DTD:

<?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 Declaration


SYNTEX : <!DOCTYPE root-element SYSTEM "filename"> rootExample :

<?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>
And this is the file "note.dtd" which contains the DTD:

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

Why Use a DTD?


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.

Ways to Use XML in Meta Data Services


Extensible Markup Language (XML) support for new possibilities of publishing and sharing meta data. You can also exchange meta data with other tools that use meta data. For ex: If you have two applications that understand the same XML format, you can exchange meta data between the two applications directly.

Using XML,Benifits can be achieved in Microsoft SQL Server 2000 Meta Data Services, they are like::: 1) You can export and import meta data between two repository databases. The diagram shows that you can exchange meta data between Repository A and Repository B through XML documents. 2) In the diagram, you can provide data from Repository A to Application A through an XML document. 3) You can import meta data from a tool or run-time runobject to a repository database. In the diagram, you can import meta data from Application A to Repository A through an XML document.

Diagram shows the relationship and flow of XML from one repository to another, and subsequently to other applications.

XMLHttpRequest Object
The The XMLHttpRequest object is used to exchange data with a server behind the scenes. The XMLHttpRequest object is a developer's dream, dream, because you can: Update a web page without reloading the page Request data from a server after the page has loaded Receive data from a server after the page has loaded Send data to a server in the background

Syntax for creating an XMLHttpRequest object: xmlhttp=new XMLHttpRequest();

XML to HTML

In the following example, we loop through an XML file ("cd_catalog.xml"), and ("cd_catalog.xml"), display the contents of each CD element as an HTML table row:

<html> <body> <script type="text/javascript"> if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET","cd_catalog.xml",false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML; document.write("<table border='1'>"); var x=xmlDoc.getElementsByTagName("CD"); for (i=0;i<x.length;i++) { document.write("<tr><td>"); document.write(x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue); document.write("</td><td>"); document.write(x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue); document.write("</td></tr>"); } document.write("</table>"); </script> </body> </html>

Output :

What is CSS?
CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to solve a problem External Style Sheets can save a lot of work External Style Sheets are stored in CSS files CSS defines HOW HTML elements are to be displayed.

HTML was intended to define the content of a document, like: <h1>This is a heading</h1> <p>This is a paragraph.</p> When tags like <font>, and color attributes were added to the HTML 3.2 specification, it started a nightmare for web developers. Development of large web sites, where fonts and color information were added to every single page, became a long and expensive process. To solve this problem, the World Wide Web Consortium (W3C) created CSS. In HTML 4.0, all formatting could be removed from the HTML document, and stored in a separate CSS file. All browsers support CSS today.

CSS Syntax: A CSS rule has two main parts: a selector, and one or more declarations:

CSS Example
p {color:red;text-align:center;} {color:red;text<html> <head> <style type="text/css"> p{color:red;textp{color:red;text-align:center;} </style></head> <body> <p>Hello World!</p> <p>This paragraph is styled with CSS.</p></body></html> Output: Hello World!This paragraph is styled with CSS.

Displaying XML with CSS


Below is a fraction of the XML file. The second line links the XML file to the CSS file: <?xml version="1.0" encoding="ISO-8859-1"?> encoding="ISO-8859<?xml<?xml-stylesheet type="text/css" href="cd_catalog.css"?> <CATALOG> <CD> <TITLE>Empire Burlesque</TITLE> <ARTIST>Bob Dylan</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>Columbia</COMPANY> <PRICE>10.90</PRICE> <YEAR>1985</YEAR> </CD> <CD> <TITLE>Hide your heart</TITLE> <ARTIST>Bonnie Tyler</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>CBS Records</COMPANY> <PRICE>9.90</PRICE> <YEAR>1988</YEAR> </CD> . . . </CATALOG>Formatting XML with CSS is not the most common method.

Css file
CATALOG { backgroundbackground-color: #ffffff; width: 100%; } CD { display: block; marginmargin-bottom: 30pt; marginmargin-left: 0; } TITLE { color: #FF0000; fontfont-size: 20pt; } ARTIST { color: #0000FF; fontfont-size: 20pt; } COUNTRY,PRICE,YEAR,COMPANY { display: block;color: #000000; marginmargin-left: 20pt; }

Output

What is XSLT
XSL stands for EXtensible Stylesheet Language, and is a style sheet language for XML documents. XSLT stands for XSL Transformations CSS = Style Sheets for HTML While XSL = Style Sheets for XML

XSL describes how the XML document should be displayed! XSL consists of three parts: XSLT - a language for transforming XML documents XPath - a language for navigating in XML documents XSL-FO - a language for formatting XML XSLdocuments

How Does it Work? In the transformation process, XSLT uses XPath to define parts of the source document that should match one or more predefined templates. When a match is found, XSLT will transform the matching part of the source document into the result document.

Displaying XML with XSLT


XML CODE <?xml version="1.0" encoding="ISO-8859-1"?> encoding="ISO-8859<!-<!-- Edited by XMLSpy --> --> <breakfast_menu> <food> <name>Belgian Waffles</name> <price>$5.95</price> <description>two of our famous Belgian Waffles with plenty of real maple syrup</description> <calories>650</calories> </food> <food> <name>Strawberry Belgian Waffles</name> <price>$7.95</price> <description>light Belgian waffles covered with strawberries and whipped cream</description> <calories>900</calories> </food> </breakfast_menu>

XSLT code
<?xml version="1.0" encoding="ISO-8859-1"?> encoding="ISO-8859<!-<!-- Edited by XMLSpy --> --> <html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"> <body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE"> style="font-family:Arial;font-size:12pt;background<xsl:for<xsl:for-each select="breakfast_menu/food"> <div style="background-color:teal;color:white;padding:4px"> style="background<span style="font-weight:bold"><xsl:value-of select="name"/></span> style="font-weight:bold"><xsl:value- <xsl:value-of select="price"/> <xsl:value</div> <div style="margin-left:20px;margin-bottom:1em;font-size:10pt"> style="margin-left:20px;margin-bottom:1em;font<xsl:value<xsl:value-of select="description"/> <span style="font-style:italic"> style="font<xsl:value<xsl:value-of select="calories"/> (calories per serving) </span> </div> </xsl:for</xsl:for-each> </body> </html>

Relationship between HTML, SGML and XML


SMGL, HTML and XML are all markup languages. languages. technology, In computer technology, a markup language is a set of words and symbols that highlight text to define it for a web document. For example, when creating an Internet page, you want to be able the separate paragraphs and put letters in a bold-face type. This is boldtype. accomplished through a markup language. . The relationship between SGML, HTML and XML is a family bond that helps make websites work and web design dynamic

SGML
In this family of markup languages, Standard Generalized Markup Language (SGML) is the parent. SGML provides a way to define markup languages and form. sets the standard for their form. In other words, SGML states what some languages can or cannot do, what elements must be included, such as tags, and the basic structure of the language. As a parent passes on genetic traits to a child, SGML passes structure and format rules to markup languages

HTML
HyperText Markup Language (HTML) is a child, or application, of SGML. It is HTML that usually designs the page for an Internet browser. Using HTML, you can embed images, create page sections, establish fonts and direct the flow of the page. HTML is the markup language that creates the form and appearance of the web page. Additionally, using HTML, you can add page. languages, other functions to a website via scripting languages, JavaScript. such as JavaScript. HTML is the predominant language design. used for website design.

XML
Extensible Markup Language (XML) is a cousin to HTML and a nephew to SGML. Although XML is a markup language and therefore part of the family, it has different functions than HTML. XML is a subset of SGML, this give it rights that an application, such as HTML, doe not have. XML can define applications of its own. Resource Description Format (RDF) is an application of XML. HTML is limited to design and does not have subsets or applications. XML is a pared down, or light, version of SGML, bandwidth. designed to work with limited bandwidth. XML inherited genetic traits from SGML, but is created to make its own family. Subsets of XML include XSL and XSLT. XSLT.

Web Personalization
Web pages are personalized based on the characteristics (interests, social category, context, ...) of an individual. Personalization implies that the changes are based on implicit data, such as items purchased or pages viewed. The term customization is used instead when the site only uses explicit data such as ratings or preferences.

Personalization Categories
Profile / Group based Behaviour based (also known as Wisdom of the Crowds) Collaboration based

Methods of Personalization
Implicit Explicit Hybrid

Semantic Web
The Semantic Web is a "web of data" that enables machines to understand the semantics, or meaning, of semantics, information on the World Wide Web It extends the network of hyperlinked human-readable web humanpages by inserting machine-readable metadata about machinepages and how they are related to each other, enabling automated agents to access the Web more intelligently and perform tasks on behalf of users. The main purpose of the Semantic Web is driving the evolution of the current Web by allowing users to use it to its full potential, thus allowing them to find, share, and combine information more easily.

Ontology
ontology is a formal representation of knowledge as a set of concepts within a domain, and the relationships domain, between those concepts. It is used to reason about the entities within that domain, and may be used to describe the domain. Ontologies are the structural frameworks for organizing intelligence, information and are used in artificial intelligence, the Semantic Web, systems engineering, software Web, engineering, engineering, engineering, biomedical informatics, library informatics, science, science, enterprise bookmarking, and information bookmarking, architecture as a form of knowledge representation about the world or some part of it.

Вам также может понравиться