33
E0262 – MIS – Multimedia Storage Techniques XML (Extensible Markup Language XML is a markup language for creating documents containing structured information. XML stands for eXtensible Markup Language. Structured information contains content and what role the content plays. Eg. content-audio, video etc Role- heading, address etc.

E0262 – MIS – Multimedia Storage Techniques XML (Extensible Markup Language XML is a markup language for creating documents containing structured information

Embed Size (px)

Citation preview

E0262 – MIS – Multimedia Storage Techniques

XML (Extensible Markup Language

XML is a markup language for creating documents containing structured information.

XML stands for eXtensible Markup Language.

Structured information contains content and what role the content plays.

Eg. content-audio, video etc

Role- heading, address etc.

E0262 – MIS – Multimedia Storage Techniques

HTML To create web pages. Is platform independent Edited using text editor or notepad Markup language – Contains Tags Angle brackets.< > eg.<i> Good Morning </i> In case end tag is not required. <img src= “doll.jpg”> src=attribute followed by doll.jpg Tags are not case sensitive <HEAD> Hello</head> It has head and body

E0262 – MIS – Multimedia Storage Techniques

HTML format. Head has information about document And body the actual content. <html> <head> <title> Web page</title> </head> <body text=”white” bgcolor=”black”> ------ ------ </body> </html>

E0262 – MIS – Multimedia Storage Techniques

XML & HTML In HTML tags are prefined, language is fixed. XML specifies neither the tag set or semantics. It is a open language, defines tag semantics. XML defines 3 specifications.

1. Basic XML specification(XML 1.0)

2. XML pointer language (Xpointer)

XML linking language (Xlink)

3. XSL-Extensible style language

E0262 – MIS – Multimedia Storage Techniques

Applications of XML

* Cell Phones - XML data is sent to some cell phones. The data is then formatted by the specification of the cell phone software designer to display text or images, and even to play sounds!

* File Converters - Many applications have been written to convert existing documents into the XML standard. An example is a PDF to XML converter.

* VoiceXML - Converts XML documents into an audio format so that you can listen to an XML document.

E0262 – MIS – Multimedia Storage Techniques

Internet Explorer 6.0 supports viewing XML files.

You can download IE 6.0 from Microsoft's Website. Internet

Explorer 6.0 has special color coding the make XML documents

easier to read.

Firefox XML Viewer: Firefox has some of the same features as

Internet Explorer. You can download Mozilla's Firefox from

Mozilla.com.

Free XML Editors:

There are many free XML editors available for download on the

internet. Here are a few we have found useful:

* XML Cooktop

* XML Mind Standard Edition

* Pete's XML Editor

Free XML Viewer

E0262 – MIS – Multimedia Storage Techniques

XML Syntax:

XML Code:<?xml version="1.0" encoding="ISO-8859-15"?><class_list>

<student><name>Robert</name><grade>A+</grade>

</student><student>

<name>Lenard</name><grade>A-</grade>

</student></class_list>

E0262 – MIS – Multimedia Storage Techniques

XML code.

XML code has five components:1.Prolog2.Elements3.Attributes4.Entity reference5.Comments.----------------------------------------------------------------Prolog-first structural elements. It has XML

declaration and Data Type Declaration (DTD)<?xml version="1.0" encoding="ISO-8859-15"?> Data type 1.0 & encoding rules.

E0262 – MIS – Multimedia Storage Techniques

XML Elements

Elements are common form of Markup.They contain the opening and closing tags, child elements,

and data.<student>

<name>Robert</name><grade>A+</grade>

</student><city/>----> <city> </city> empty XML is case sensitive.Elements naming convention:Must begin with an underscore or letterCan contain letters, digits, underscore,hyphen etc

E0262 – MIS – Multimedia Storage Techniques

XML Attribute An attribute appears within the opening tag of an element. Must not contain any white spaces.<student active="true">

<name>Robert</name><grade>A+</grade>

</student>

E0262 – MIS – Multimedia Storage Techniques

XML Entity references

They are used to reference data that is not directly in the structureBuilt in entity like &, <, >, “,'The stringTin&Tin(“Don't read x<y”)

Tin&amp;Tin(&quot;Don&apos;t read x&lt;y&quot;)

E0262 – MIS – Multimedia Storage Techniques

XML Comment Syntax<?xml version="1.0" encoding="ISO-8859-15"?><!-- Students grades are updated bi-monthly --><class_list>

<student><name>Robert</name><grade>A+</grade>

</student><student>

<name>Lenard</name><grade>A-</grade>

</student></class_list>

E0262 – MIS – Multimedia Storage Techniques

XML Commenting out XML

To temporarily remove some XML code from your XML document.

<?xml version="1.0" encoding="ISO-8859-15"?>

<class_list>

<student>

<name>Robert</name>

<grade>A+</grade>

</student>

<!--

<student>

<name>Lenard</name>

<grade>A-</grade>

</student>

-->

</class_list>

E0262 – MIS – Multimedia Storage Techniques

Processing Instructions

Used to provide information to the application

<?name pidata?>Name is special command , pi names beginning with xml are reservedEg. In case of image file, application will be informed to open image With bmp or jpeg opener.Or will be informed that image type is jpeg.etc

E0262 – MIS – Multimedia Storage Techniques

When an element appears within another element, it is said that the inner element is "nested". The term nested can be related directly to the word "nest". If an element is nested within another element, then it is surrounded, protected, or encapsulated by the outer element

Example A<phonebook>

<number><name></number></name>

</phonebook>

XML Nesting

E0262 – MIS – Multimedia Storage Techniques

Example B

<phonebook><number><name>

</name></number>

</phonebook>All elements are closed in the order that they were opened. Those elements which were opened first are closed last.Example B is what example A must look like to be a well-formed XML document.

E0262 – MIS – Multimedia Storage Techniques

CDATA section

A CDATA section instructs the XML parser to ignore most Markup characters.

Example:<![CDATA[temp=*p;*p=*q;*q=temp;if(temp<0) temp=-temp;]]>All character data in between is passed to the applicationWithout interpretation.

E0262 – MIS – Multimedia Storage Techniques

Broken XML Code:<email>

<to>Mr. Garcia<body>Hello there! How are we today?</to>

</body></email>Well-Formed XML Code:<email>

<to>Mr. Garcia</to><body>Hello there! How are we today?</body>

</email>The error in the first example was:The document suffers from improper

nesting. The body element was opened inside the to element, yet body

was not closed before the to element was closed!

E0262 – MIS – Multimedia Storage Techniques

Entity References

If you place a character like "<" inside an XML element, it will generate an error because the parser interprets it as the start of a new element.<message>if salary < 1000 then</message><message>if salary &lt; 1000 then</message>

There are 5 predefined entity references in XML:&lt; < less than&gt; > greater than&amp; & ampersand &apos; ' apostrophe&quot; " quotation mark

E0262 – MIS – Multimedia Storage Techniques

DTD (Document type declaration)

Important for displaying in a browser

XML allows us to create own tag namesFour kinds of declarations:Element typeAttribute typeEntity typeNotation type

Element type: helps to identify the name of the elements and content of the elements.Example: <xsd:element name=”Name” type=”xsd:string” maxOccurs=”unbounded/>They can be defined with reference to cardinality. (How many times they appear in document.Xsd-keyword used to define elementName is element, unbounded-number of times element is occur.

E0262 – MIS – Multimedia Storage Techniques

Attribute list declaration

Attributes should have name and type. They can haveRestriction with reference to cardinality.<xsd:attribute name=”city” type=”xsd:string” fixed=”bangalore”/>Fixed is default cannot be changed.

E0262 – MIS – Multimedia Storage Techniques

Entity declaration

Allows us to associate a name with some other fragment or content..2 types are there:Internal entityExternal entity

Internal entity: &lt, &gt,&amp, &apos, &quot.

External entity: associated a name with the contents of another file

<!entity IISclogoSYSTM “/institute/logo.gif>IISc logo will be replace by image.

E0262 – MIS – Multimedia Storage Techniques

XML(Table)

E0262 – MIS – Multimedia Storage Techniques

XPath - Finding Information

XPath is the solution to finding information in an XML document. XPath uses expressions to find elements, attributes, and other information in your XML. If you have an XML document that contained a bunch of your favorite books, each with author children elements, you can use a one line XPath expression to find all the authors of your favorite books!The most common place people might see XPath expressions are in XSLT (Extensible Stylesheet Language Transformation).

E0262 – MIS – Multimedia Storage Techniques

Simple Links

Resembles HTML<link xml:link=”simple”href=”http//www.iisc.ernet.in>Home page</link>

E0262 – MIS – Multimedia Storage Techniques

Extended Links (relation between 2 or more

resources)

<elink xml:link=”extended”<locator xml:link “locator” href=”text.html”>Home page</locator><locator xml:link “locator” href=”face.jpg”>Home page</locator>---<\elink>

E0262 – MIS – Multimedia Storage Techniques

Structure of an XML Document

E0262 – MIS – Multimedia Storage Techniques

Structure of an XML Document

E0262 – MIS – Multimedia Storage Techniques

Structure of an XML Document

E0262 – MIS – Multimedia Storage Techniques

Structure of an XML Document

E0262 – MIS – Multimedia Storage Techniques

Structure of an XML Document

E0262 – MIS – Multimedia Storage Techniques

Structure of an XML Document

E0262 – MIS – Multimedia Storage Techniques

Structure of an XML Document