Sie sind auf Seite 1von 33

XML(ExtensibleMarkupLanguage

XMLisamarkuplanguageforcreatingdocuments
containingstructuredinformation.

XMLstandsforeXtensibleMarkupLanguage.

Structuredinformationcontainscontentandwhatrole
thecontentplays.

Eg.contentaudio,videoetc

Roleheading,addressetc.

HTML

Tocreatewebpages.

Isplatformindependent

Editedusingtexteditorornotepad

MarkuplanguageContainsTags

Anglebrackets.<>

eg.<i>GoodMorning</i>

Incaseendtagisnotrequired.

<imgsrc=doll.jpg>

src=attributefollowedbydoll.jpg

Tagsarenotcasesensitive

<HEAD>Hello</head>

Ithasheadandbody

HTMLformat.

Headhasinformationaboutdocument

Andbodytheactualcontent.

<html>

<head>

<title>Webpage</title>

</head>

<bodytext=whitebgcolor=black>

</body>

</html>

XML&HTML

InHTMLtagsareprefined,languageisfixed.

XMLspecifiesneitherthetagsetorsemantics.

Itisaopenlanguage,definestagsemantics.

XMLdefines3specifications.

1.BasicXMLspecification(XML1.0)
2.XMLpointerlanguage(Xpointer)
XMLlinkinglanguage(Xlink)
3.XSLExtensiblestylelanguage

ApplicationsofXML
* 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.

FreeXMLViewer
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

XMLSyntax:
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>

XMLcode.
XML code has five components:
1.Prolog
2.Elements
3.Attributes
4.Entity reference
5.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.

XMLElements
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 letter
Can contain letters, digits, underscore,hyphen etc

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>

XMLEntityreferences
They are used to reference data that is not directly in the
structure
Built in entity like &, <, >, ,'
The string
Tin&Tin(Don't read x<y)
Tin&amp;Tin(&quot;Don&apos;t read x&lt;y&quot;)

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

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>

ProcessingInstructions
Used to provide information to the application
<?name pidata?>
Name is special command , pi names beginning with xml are reserved
Eg. 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

XMLNesting
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>

ExampleB
<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.

CDATAsection
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 application
Without interpretation.

BrokenXMLCode:
<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!

EntityReferences
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

DTD(Documenttypedeclaration)Importantfor
displayinginabrowser
XML allows us to create own tag names
Four kinds of declarations:
Element type
Attribute type
Entity type
Notation 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 element
Name is element, unbounded-number of times element is occur.

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

Entitydeclaration
Allows us to associate a name with some other fragment or content..
2 types are there:
Internal entity
External entity
Internal entity: &lt, &gt,&amp, &apos, &quot.
External entity: associated a name with the contents of another file
<!entity IISclogo
SYSTM /institute/logo.gif>
IISc logo will be replace by image.

XML(Table)

XPathFindingInformation
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).

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

ExtendedLinks(relationbetween2ormoreresources)

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

StructureofanXMLDocument

StructureofanXMLDocument

StructureofanXMLDocument

StructureofanXMLDocument

StructureofanXMLDocument

StructureofanXMLDocument

StructureofanXMLDocument

Das könnte Ihnen auch gefallen