XMLx

fallsnowpeasInternet και Εφαρμογές Web

12 Νοε 2013 (πριν από 3 χρόνια και 9 μήνες)

86 εμφανίσεις

XML

e
X
tensible
M
arkup
L
anguage

Dated May 2
nd

2013

Presented by


Carlos Costa

Yanxia

Gao


Outlines


Brief History


Markup Language


XML Definition


XML Element


XML Attributes


XML Syntax


XML Structure


XML DTD


XML Schema


XML Tree Model


XML Display


XML Application


XML Tools & Software


Brief History


SGML (Standardized General Markup Language)


Descended from IBM’s Generalized Markup
Languages, which developed by 3 persons in 1960.


Originally designed to enable the sharing of machine
-
readable large
-
project documents in government, law,
and industries


HTML (
HyperText

Markup Language)


1989, Tim
Berners

Lee invented the web w/HTML as
its publishing language


XML (
eXensible

Markup Language)


Was complied by a working group of 11 members


Version 1.0 was introduced by W3C in 1998


Bridge the data exchange on the web


What is Markup Languages


Markup


Text added to data content to convey info about
data


Markup document


Data


Info about data (markup)


Markup language


Formalized system to provide markup


Specifies code for formatting, both the layout and
style, within a text file.


The code used to specify the formatting are
called tags

What is Markup language

A markup language must specify:


What markup is allowed


What markup is required


How markup is distinguished from text


What the markup means



*XML only specify the first three, the fourth is specified
by DTD


Markup Language


SGML


International standard to define structure
and content in text documents


Interchangeable: device
-
independent,
system
-
independent


Not predefined tag


Using DTD to validate the structure of
the document


Large, powerful, and very complex


Heavily used in industrial and commercial
for over a decade


HTML and XML


Both Based on SGML


HTML


A small SGML application used on web (a
DTD and a set of processing conventions)


XML


A simplified version of SGML


Maintains the most useful parts of SGML


Designed so that SGML can be delivered
over the Web





SGML

XML

HTML

HTML vs. XML


HTML


Fixed set of tags


have a
fixed

meaning
and
browsers

know
what it is.


used for display


Presentation oriented


No data validation
capabilities


Single presentation



XML


Extensible set of tags


different for
different

applications, and
users

know what they mean


used to describe
documents and data


Content orientated


Standard Data
infrastructure


Allows multiple output
forms




Example

<html>


<head><title>
exampl
e
</title></head>

<body>


<h1>
John Smith
</h1>


<h2>
js@gmail.com
</h
2>

</body>

</html>

<?xml version=“1.0”/>

<address
>


<name>
John
Smith
</name>


<email>
js@gmail.com
</email>

</address>


What is XML


Extensible Markup Language


Defines a set of rules to describe data


Use of tags, values and attributes


Use W3C as a framework


a text
-
based language with a universal data
format


Is used to store and exchange data between
applications


Emphasize simplicity, generality, and usability over
the internet


Widely used, data identified by a tag can be
available for other tasks.


XML Element


A segment between an opening and a
corresponding closing tag


Primary components of XML documents


Delimited by angle brackets


Identify the nature of the content they
surround


General format: <element>…</element>



XML Element





<
person
>


<
name
>

John Smith

</
name
>


<
tel
>

662
-
2595666

</
tel
>



<
fax
>

051
-
3019222

</
fax
>


<
email
>

js@yahoo.com

</
email
>


</
person
>

element

XML Element


Can be extended to carry more info


Parents and children relationship


Different content types: element
content, mixed content, simple
content, empty content and
attributes


Follow the naming rules





XML Attribute


Provide additional info about Elements.


Values of the Attributes are set inside the
Elements like:<element attribute=“value”>


Located in the start tag of elements


Provide info that is not a part of data


Must be enclosed in quotes


Element vs. Attribute


Data about data should be stored as attributes


Data itself should be stored as elements




XML Syntax


Tags are enclosed in angle brackets.


Tags come in pairs with start
-
tags and end
-
tags.


All XML elements must have a closing tag


XML tags are case sensitive


All XML elements must be properly nested


<name><email>…</name></email> is not allowed.


<name><email>…</email></name> is allowed.


All XML documents must have a root tag that begins the
document.


Attribute values must always be quoted


With XML, white space is preserved


Spaces are not allowed in element and attribute names


With XML, a new line is always stored as LF


Comments in XML: <!

This is a comment
--

>


XML Structure


Two ways to define the structure of an
XML document


DTDs


Schemas


Each set of rules specifies an XML
vocabulary


What is DTD


Document Type Definitions


Defines legal building blocks of an XML
Document like what elements and attributes
can appear and what are their relationships


Describes the tree structure of a document
and something about its data. Like how many
times a node may appear, and how child
nodes are ordered


Two data types


PCDATA is parsed character data.


CDATA is character data, not usually parsed.


Can be within XML or as an external
reference



Problem w/ DTD


Difficult to work with


No support for data types


Not extensible




XML Schemas


Written in XML


An alternative to DTD, more powerful and complex


Standardized after DTDs and provide more info about the
document


Allows for user
-
defined data types (complex/simple types)


Enhanced
datatypes



Unlike PCDATA in DTS’s


A wide range of data types including string, decimal,
integer,
boolean
, date and time


Can create your own
datatypes

(
complexType
)


Support namespaces for extensibility


Serves same purpose as database schema



Address Example

DTD

Schema

<!ELEMENT address (name, email,
phone, birthday)>

<!ELEMENT name (first, last)>

<!ELEMENT first (#PCDATA)>

<!ELEMENT last (#PCDATA)>

<!ELEMENT email (#PCDATA)>

<!ELEMENT phone (#PCDATA)>

<!ELEMENT birthday (year, month,
day)>

<!ELEMENT year (#PCDATA)>

<!ELEMENT month (#PCDATA)>

<!ELEMENT day (#PCDATA)>


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

<
xs:schema

xmlns:xs
="http://www.w3.org/2001/X
MLSchema">

<
xs:element

name="address">


<
xs:complexType
>



<
xs:sequence
>




<
xs:element

name="name" type="
xs:string
"/>




<
xs:element

name="email" type="
xs:string
"/>




<
xs:element

name="phone" type="
xs:string
"/>




<
xs:element

name="birthday" type="
xs:date
"/>



</
xs:sequence
>


</
xs:complexType
>

</
xs:element
>

</
xs:schema

Validity


A well
-
formed document has a tree
structure and obeys all the XML rules.


A particular application may add more
rules in either a DTD or in a schema.


XML Tree


Has a single root node.


A parent node may have any number of
children.


Child nodes are ordered, and may have
siblings.


XML Tree Example

XML Display



Display info to XML with


CSS (Cascading Style Sheets)


XSL (
eXtensible

Style sheet Language)


XML Application


Separate Data


XML Separates Data from HTML


Store data in separate XML files


Using HTML for layout and display


Benefits:


Changes in the underlying data will not
require any changes to HTML


XML Application


Exchange Data


Text format


Software/hardware
-
independent


Exchange data between incompatible
systems over internet


Can be read by many different types of
applications


Benefits:


Reduce the complexity of interpreting data


Easier to expand and upgrade a system


XML Application
-

Store Data


Plain text file


Store data in files or databases


Application can be written to store and
retrieve info


Other clients and applications can access
your XML files as data sources


Benefits:


Accessible to more applications


XML Application
-
Create New
Internet Language


For markup internet applications for
handheld devices like mobile phones


WAP(Wireless Application Protocol)



WML (Wireless Markup Language)


For
describing

available web services


WSDL (Web Services Description Language)


For news fees


RSS (Really Simple Syndication)


For describing multimedia for the web


SMIL (Synchronized Multimedia Integration
Language)


XML Application
-

Apps for Android
Systems


XML File created
to store data:



<
?xml version="1.0" encoding="utf
-
8"?>

<MIS409DB>


<
professorName
>
Sumali

Conlon </
professorName
>


<
professorEmail
>
scolon@bus.olemiss.edu


<
/
professorEmail
>


<
professorDepartment
> MIS </
professorDepartment
>

</MIS409DB>

XML Application
-

Apps for Android
Systems

XML Application
-

Apps for Android
Systems

XML Application
-

Apps for Android
Systems

Tools & Software


XMLSpy

http://www.xmlspy.com/download.html


XML Notepad
http://msdn.microsoft.com/xml/notepad
/download.asp


XML Pro
http://www.vervet.com/demo.html



Great links:

www.w3schools.com