SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Downloaden Sie, um offline zu lesen
XML Introduction
Ing. Marco BRESCIANI

XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
What Is XML?
Page 2

XML is a W3C Recommendation (http://www.w3.org/XML/); the acronym
means eXtensible Markup Language:
 It’s a mark-up, just like HTML.

It was designed to describe data (metadata language):
 It does not define or perform operations on data;
 It needs a grammar to describe data:
 XML Schema is a standard grammar;
 DTD is a standard grammar, old-fashioned.
It does not define tags:
 HTML is <html></html>;
 XML is NOT <xml></xml>.
It is self-descriptive: an XML file with its grammar is self-contained.

XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
Why XML?
Page 3

XML describes data:
 Keeps data separated from their graphical layout;
 Allows automatic data management and exchange;
 Can define new languages in order to produce specific data formats;
 A single XML file and the data it contains can be managed in different
ways.

XML is precise and safe:
 HTML allows this: <HtML> content </HTml> or <HTML>
content (?);
 XML force this: <tag> content </tag> or <tag />.
 Refers to a grammar that can be used to do more checks.

XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
How XML?
Page 4

XML has been defined to be managed through software in
order to produce different outputs, to evaluate data and to
transform them in many ways… simply using text files!
A simple XML file:
<article>
<paragraph title="Paragraph Title">
<text>This is the text</text>
</paragraph>
</article>

XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
Some XML Details
Page 5

There are some constrains that each XML file must observe:
 All XML files must start with a prologue:
<?xml version='1.0' encoding='utf-8'?>
where version can be “1.0” or “1.1” and encoding is the name of a
valid ISO charset: “utf-8”, “iso-8859-15”, “utf-16”, “iso-2022-jp”, …;
 All elements are case-sensitive. Standard suggests the used of
lowercase: <TAG> or <Tag> or <tag> represent three different
elements;
 Element tags must be ordered in the open/close sequence;
 Attributes must be contained between ’ or “ delimiters;
 A document must contain a single root element that contains all the
others:
<?xml version='1.0' encoding='utf-8'?>
<root> Document content (other element tags) </root>
XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
XML Definition
Page 6

As stated, XML does not define tags so we cannot say (as for
HTML), <em> tag identifies an emphasis on text or <table>
tag identifies the beginning of a tabular data structure and
so on.
How can we define XML? XML can be defined by defining an
XML application.
What is an XML application? An XML application is a
language, based on XML structure/grammar, that defines
the structure of a data set.
What is XML? XML is a standard way to define data
structures (and much more… we’ll see…).
XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
Smart XML Example
Page 7

As states, XML does not define how
to use data, only their logical
representation. This is a set of data:
<?xml version="1.0" encoding="UTF-8"?>
<X3D profile="Immersive"
xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance"
xsd:noNamespaceSchemaLocation="http://www.web3d.org/specifi
cations/x3d-3.0.xsd">
<head>
<meta content="Scacchiera.x3d" name="filename"/>
<meta content="Scacchiera Tridimensionale di Star Trek"
name="description"/>
<meta content="Marco Bresciani" name="author"/>
<meta content="Marco Bresciani" name="translator"/>
<meta content="1998" name="created"/>
<meta content="2004-09-01" name="translated"/>
<meta content="2005-02-23" name="revised"/>
<meta content="200502.23.1905" name="version"/>
<meta content="http://marcobresciani.altervista.org"
name="reference"/>
…

How can this data be represented?
Look on the right!
XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
Another XML Example
Page 8

Remember: XML does not define
how to use data!
<project_statistics>
<master_url>http://setiathome.ssl.berkeley.edu/</master_url
>
<daily_statistics>
<day>1138233600.000000</day>
<user_total_credit>25489.045579</user_total_credit>
<user_expavg_credit>89.772845</user_expavg_credit>
<host_total_credit>5259.731942</host_total_credit>
<host_expavg_credit>89.661763</host_expavg_credit>
</daily_statistics>
<daily_statistics>
<day>1138579200.000000</day>
<user_total_credit>25615.527457</user_total_credit>
<user_expavg_credit>70.733574</user_expavg_credit>
<host_total_credit>5386.213820</host_total_credit>
<host_expavg_credit>70.659423</host_expavg_credit>
</daily_statistics>
…

Data above could be represented
as on the left or in any other ways.
XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
XML: « My Computer » Example (1 of 5)
Page 9

Now, we begin working with some basic XML with a(n almost) complete
example. After this, we will describe XML grammar(s) in detail.
This sample XML file (briefly) represents the structure and components of
a generic PC (not completely true… we’ll see that): the parts that
compose the PC, the details about those parts and so on.
The XML file, even if be simple, allows the beginners to have a smart
view of the XML standard itself, by introducing its features and
possibilities with a simple structure based on a known thing.
Let’s see the XML file: please note that elements (tags) are uppercase to
enhance readability…

XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
XML: « My Computer » Example (2 of 5)
Page 10

<?xml version="1.0"?>
<PART>
<!DOCTYPE PARTS SYSTEM "parts.dtd">
<ITEM>Sound Card</ITEM>
<?xml-stylesheet type="text/css"
<MANUFACTURER>Creative
href="xmlpartsstyle.css"?>
Labs</MANUFACTURER>
<PARTS><TITLE>Computer Parts</TITLE>
<MODEL>Sound Blaster
<PART>
Live</MODEL>
<ITEM>Motherboard</ITEM>
<COST>80.00</COST>
<MANUFACTURER>ASUS</MANUFACTURER>
</PART>
<MODEL>P3B-F</MODEL>
<PART>
<COST>123.00</COST>
<ITEM>19 inch Monitor</ITEM>
</PART>
<MANUFACTURER>LG
<PART>
Electronics</MANUFACTURER>
<ITEM>Video Card</ITEM>
<MODEL>995E</MODEL>
<MANUFACTURER>ATI</MANUFACTURER>
<COST>290.00</COST>
<MODEL>All-in-Wonder Pro</MODEL>
</PART>
<COST>160.00</COST>
</PARTS>
</PART>

XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
XML: « My Computer » Example (3 of 5)
Page 11

In the previous page we saw:
 A computer is a list of <PARTS> with a name defined by a <TITLE>;
 The list of <PARTS> is composed by a number or <PART> element;
 Each <PART> has its own details:
 An <ITEM> that describes the kind of part we are writing about;
 A <MANUFACTURER> that states the builder of the <PART>;
 A <MODEL> that renders the description of the <PART>, also given by
<ITEM>;
 A <COST> that specifies the money you spent to buy that component.

We saw a <!DOCTYPE PARTS SYSTEM “parts.dtd”>
tag too: this is used to relate the XML to its grammar. Let’s
see it…
XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
XML: « My Computer » Example (4 of 5)
Page 12

Using the DTD standard (simpler, for beginners) we can define the
grammar of our “My Computer” description:
<!ELEMENT PARTS (TITLE?, PART*)>
<!ELEMENT TITLE (#PCDATA)>
<!ELEMENT PART (ITEM, MANUFACTURER, MODEL, COST)+>
<!ATTLIST PART type (computer|auto|airplane) #IMPLIED>
<!ELEMENT ITEM (#PCDATA)>
<!ELEMENT MANUFACTURER (#PCDATA)>
<!ELEMENT MODEL (#PCDATA)>
<!ELEMENT COST (#PCDATA)>

The DocType element described before defines the language we are
going to use in our XML file. The grammar file defines the details of such
language Let’s check the DTD grammar, step-by-step…

XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
XML: « My Computer » Example (4a of h)
Page 13

We said an XML file must contains a single element which
will contain all the other elements:
<!ELEMENT PARTS (TITLE?, PART*)>
This description states that the root element is called PARTS
and that it will contain a sequence (, symbol) of zero-or-one
(? symbol) TITLE elements and zero-or-more (* symbol)
PART elements.
So, a file that will contain:
<PARTS><TITLE></TITLE><TITLE></TITLE>…
Wont’ be correct due to the wrong number of TITLE
elements.

XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
XML: « My Computer » Example (4b of h)
Page 14

The second description in the DTD file will represent the “content-type” of
the TITLE element:
<!ELEMENT TITLE (#PCDATA)>
This means that the TITLE element can contain any sequence of data
described as a #PCDATA by the XML standard itself.
This is a generic sequence of valid characters, number, symbols and so
on. Valid #PCDATA data are:
Afe5o 8ghert
4534
-.f,.5,g
… and so on. The user that’ll define this element would probably use
meaningful data as: <TITLE>This is My Computer</TITLE>.

XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
XML: « My Computer » Example (4c of h)
Page 15

The third element describes the structure of the PART
element:
<!ELEMENT PART (ITEM, MANUFACTURER, MODEL,
COST)+>
as a sequence (, symbol) of four other elements: ITEM,
MANUFACTURER, MODEL and cost.
Each sequence (that is: each PART element) must be present
one-or-more time (+ symbol).

XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
XML: « My Computer » Example (4d to h)
Page 16

All the other elements are quite simple and state the fact that
the PART sub-elements are defined as simple text
(#PCDATA):
<!ELEMENT ITEM (#PCDATA)>
<!ELEMENT MANUFACTURER (#PCDATA)>
<!ELEMENT MODEL (#PCDATA)>
<!ELEMENT COST (#PCDATA)>
So, even those elements are defined as generic and not
constrained to a specific format.

XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
XML: « My Computer » Example (5 of 5)
Page 17

What we learned?
 XML can defined structured data;
 Every one can define its own XML application;
 Each XML application represents a new language related to data it can
represent and manage;
 An XML-based language defines it capabilities through a grammar that
states how data can be structured and related.

What are we going to learn?
 Why a grammar?
 Which kind of grammar?
 Many other aspects of XML…

XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
The Needs of the Grammar
Page 18

As stated, a grammar defines the “words” (elements or tags) we can use
in our XML-based language. Is it needed?
 XML is defined to be managed by software:
 How can a software knows if a tag (element) is allowed in my
language? BASIC programming language allows the PRINT
instruction while Java does not;
 How can a software knows if elements are written in the correct
order? PRINT “HELLO” is a valid instruction while “HELLO”
PRINT is not;
 How can a software knows how to relate data? An address belongs
to an house or to the owner of the house?
 XML can also be interpreted and produced in different ways. Grammar
helps software in describing data content;
 Grammars are also used by automatic parsers, validators and editors
in order to help the user in hand-writing XML document.
XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
Which Grammar?
Page 19

XML can use and be defined by a couple of standard
grammar: DTD and XML Schema.
Few notes about DTD:
 It’s older;
 It uses a specific syntax different from XML;
 Cannot define or constrain data types;

Few notes about XML Schema:
 It’s a newer standard;
 It’s a XML application: defined using XML, uses XML to define XML
languages!
 Allows constraints on data types and contents;

XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
XML Schema: a Brief Introduction (1 of 2)
Page 20

The W3C XML Schema Definition Language is an XML language (W3C
Recommendation) for describing and constraining the content of XML
documents. The purpose of an XML Schema is to define the legal
building blocks of an XML document, just like a DTD. An XML Schema:
 defines elements that can appear in a document;
 defines attributes that can appear in a document;
 defines which elements are child elements;
 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.

XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
XML Schema: a Brief Introduction (2 of 2)
Page 21

XML Schema has more features than DTD:
 Supports data type;
 Uses XML syntax;
 Secures data communications
 A date like this: “03-11-2004” could be interpreted as 3. November
or as 11. March. An XML element like: <date
type="date">2004-03-11</date> ensures a mutual
understanding because the XML data type date requires the format
YYYY-MM-DD.
 Is extensible
 A Schema can be used inside another schema or
modified/extended/merged by other schemas.

XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
XML Schema Vs. DTD: Example (1 of 4)
Page 22

This is a simple example of a XML file:
<?xml version="1.0"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
Where elements and file (data) structure are very simple.
XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
XML Schema Vs. DTD: Example (2 of 4)
Page 23

The DTD file that describes the previous XML sample could
be:
<!ELEMENT note (to, from, heading, body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
And we saw elements descriptions and meaning before…

XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
XML Schema Vs. DTD: Example (3 of 4)
Page 24

The XML Schema that describe the XML sample data file could be:
<?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">
<xs:element name="note">
<xs:complexType><xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
XML Schema Vs. DTD: Example (4 of 4)
Page 25

Let’s focus on elements: the attributes contained in the
<xs:schema> tag are a detail information we don’t need
(now).
 With respect to elements, the DTD <!ELEMENT> object becomes
<xs:element>: the name of the element is an attribute of the tag
itself;
 A <xs:complexType> means that an element contains other
elements;
 The <xs:sequence> elements describe a mandatory list of elements
inside another element, just like the <,> operator did in DTD;
 The xs:string attribute defines a type (!) and says that the related
elements can contain strings: <to>content string<to>.

XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
References to XML Schema or DTD
Page 26

So, how can a XML file refer to a given XML Schema or DTD that
describe it? Let’s see the XML Schema:
<?xml version="1.0"?>
<note xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com
note.xsd">
… </note>
And then the DTD:
<?xml version="1.0"?>
<!DOCTYPE note SYSTEM
"http://www.w3schools.com/dtd/note.dtd">
<note> … </note>

XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
XML Schema Data Types
Page 27

This grammar language defines many data types:
 xs:string – generic sequence of characters;
 xs:boolean – true/false values that can be represented with 1/0 too;
 xs:decimal – sequence of numbers only, with a possible minus sign
(-) preponed and a decimal separator (.);
 xs:positiveInteger – integer non-negative values;
 xs:byte – a single byte, from –128 to 127;
 xs:unsignedByte – an integer number, from 0 to 255;
 xs:complexType – can contain other elements;
 xs:sequence – describe a sequence of elements;
 xs:choice – describe alternate elements;
…

XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
XML: Some (Very Few) References
Page 28

The XML Standard: http://www.w3.org/XML/;
XML Schema: http://www.w3.org/XML/Schema;
 A tutorial: http://www.w3schools.com/schema/default.asp;

DTD Tutorial: http://www.w3schools.com/dtd/default.asp;
Java Technology & XML: http://java.sun.com/xml/;
XML and C:
 The XML C parser and toolkit of Gnome: http://xmlsoft.org/;
 Apache Xerces API: http://xml.apache.org/index.html;

Web Syndication (with XML):
http://en.wikipedia.org/wiki/Web_syndication;

XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
XML: Where From Here?
Page 29

XML standard(s) has many other features and capabilities:
 It allows querying a database through XML Query standard;
 It allows automatic translations from XML to any other language
((X)HTML in primis), data structure, … through the use of XSL
Transformation language family;
 Can describe “well-known” data and information such as:
 geometric drawings and diagrams through SVG (Scalable Vector
Graphics);
 mathematical expressions, through MathML;
 three-dimensional environments, with X3D;
 chess games and players information, with LCARS-ML, ChessGML,
ChessML, …;
 It allows information spreading and syndication with RSS, Atom, …
 To be continued… Let’s take a look at the “big picture”!
XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
XML Family: The Big Picture
Page 30

XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel
Page 31

www.alcatel.com
XML Introduction / 6 November, 2013

All rights reserved © 2005, Alcatel

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Fergus Fahey - DRI/ARA(I) Training: Introduction to EAD - Introduction to XML
Fergus Fahey - DRI/ARA(I) Training: Introduction to EAD - Introduction to XMLFergus Fahey - DRI/ARA(I) Training: Introduction to EAD - Introduction to XML
Fergus Fahey - DRI/ARA(I) Training: Introduction to EAD - Introduction to XML
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
XML
XMLXML
XML
 
Basic xml syntax
Basic xml syntaxBasic xml syntax
Basic xml syntax
 
Extensible Markup Language (XML)
Extensible Markup Language (XML)Extensible Markup Language (XML)
Extensible Markup Language (XML)
 
Xml
XmlXml
Xml
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
XML, DTD & XSD Overview
XML, DTD & XSD OverviewXML, DTD & XSD Overview
XML, DTD & XSD Overview
 
Xml Java
Xml JavaXml Java
Xml Java
 
Xml ppt
Xml pptXml ppt
Xml ppt
 
Xml tutorial
Xml tutorialXml tutorial
Xml tutorial
 
SQL Server - Querying and Managing XML Data
SQL Server - Querying and Managing XML DataSQL Server - Querying and Managing XML Data
SQL Server - Querying and Managing XML Data
 
Intro xml
Intro xmlIntro xml
Intro xml
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
XML-Extensible Markup Language
XML-Extensible Markup Language XML-Extensible Markup Language
XML-Extensible Markup Language
 
01 Xml Begin
01 Xml Begin01 Xml Begin
01 Xml Begin
 
Xml Presentation-3
Xml Presentation-3Xml Presentation-3
Xml Presentation-3
 
XML
XMLXML
XML
 
Xml
XmlXml
Xml
 
Xml
XmlXml
Xml
 

Andere mochten auch

Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XMLAbhra Basak
 
Entity beans in java
Entity beans in javaEntity beans in java
Entity beans in javaAcp Jamod
 
REST to RESTful Web Service
REST to RESTful Web ServiceREST to RESTful Web Service
REST to RESTful Web Service家弘 周
 
Introduction to XML and Databases
Introduction to XML and DatabasesIntroduction to XML and Databases
Introduction to XML and Databasestorp42
 
Network topology
Network topologyNetwork topology
Network topologylekshmik
 
Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)Peter R. Egli
 
Xml Publisher And Reporting To Excel
Xml Publisher And Reporting To ExcelXml Publisher And Reporting To Excel
Xml Publisher And Reporting To ExcelDuncan Davies
 
Web Service Presentation
Web Service PresentationWeb Service Presentation
Web Service Presentationguest0df6b0
 
Best Practices in Web Service Design
Best Practices in Web Service DesignBest Practices in Web Service Design
Best Practices in Web Service DesignLorna Mitchell
 
Webservices Overview : XML RPC, SOAP and REST
Webservices Overview : XML RPC, SOAP and RESTWebservices Overview : XML RPC, SOAP and REST
Webservices Overview : XML RPC, SOAP and RESTPradeep Kumar
 

Andere mochten auch (17)

Xml & Java
Xml & JavaXml & Java
Xml & Java
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Xml dtd
Xml dtdXml dtd
Xml dtd
 
Entity beans in java
Entity beans in javaEntity beans in java
Entity beans in java
 
Introduction to EJB
Introduction to EJBIntroduction to EJB
Introduction to EJB
 
REST to RESTful Web Service
REST to RESTful Web ServiceREST to RESTful Web Service
REST to RESTful Web Service
 
Web service introduction
Web service introductionWeb service introduction
Web service introduction
 
Introduction to XML and Databases
Introduction to XML and DatabasesIntroduction to XML and Databases
Introduction to XML and Databases
 
EJB .
EJB .EJB .
EJB .
 
Network topology
Network topologyNetwork topology
Network topology
 
Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)
 
Xml Publisher And Reporting To Excel
Xml Publisher And Reporting To ExcelXml Publisher And Reporting To Excel
Xml Publisher And Reporting To Excel
 
Web Service Presentation
Web Service PresentationWeb Service Presentation
Web Service Presentation
 
Enterprise JavaBeans(EJB)
Enterprise JavaBeans(EJB)Enterprise JavaBeans(EJB)
Enterprise JavaBeans(EJB)
 
Best Practices in Web Service Design
Best Practices in Web Service DesignBest Practices in Web Service Design
Best Practices in Web Service Design
 
Introduction to Web Service
Introduction to Web Service Introduction to Web Service
Introduction to Web Service
 
Webservices Overview : XML RPC, SOAP and REST
Webservices Overview : XML RPC, SOAP and RESTWebservices Overview : XML RPC, SOAP and REST
Webservices Overview : XML RPC, SOAP and REST
 

Ähnlich wie XML Introduction Exploring the 'My Computer' Example (20)

Unit 5 xml (1)
Unit 5   xml (1)Unit 5   xml (1)
Unit 5 xml (1)
 
XML-Unit 1.ppt
XML-Unit 1.pptXML-Unit 1.ppt
XML-Unit 1.ppt
 
Xml 1
Xml 1Xml 1
Xml 1
 
Introduction to xml schema
Introduction to xml schemaIntroduction to xml schema
Introduction to xml schema
 
Xml
XmlXml
Xml
 
XML notes.pptx
XML notes.pptxXML notes.pptx
XML notes.pptx
 
M.FLORENCE DAYANA WEB DESIGN -Unit 5 XML
M.FLORENCE DAYANA WEB DESIGN -Unit 5   XMLM.FLORENCE DAYANA WEB DESIGN -Unit 5   XML
M.FLORENCE DAYANA WEB DESIGN -Unit 5 XML
 
Xml intro1
Xml intro1Xml intro1
Xml intro1
 
ch10
ch10ch10
ch10
 
Xml Session No 1
Xml Session No 1Xml Session No 1
Xml Session No 1
 
LECT_TWO.pptx
LECT_TWO.pptxLECT_TWO.pptx
LECT_TWO.pptx
 
XML Security Using XSLT
XML Security Using XSLTXML Security Using XSLT
XML Security Using XSLT
 
Xml For Dummies Chapter 8 Understanding And Using Dt Ds it-slideshares.blog...
Xml For Dummies   Chapter 8 Understanding And Using Dt Ds it-slideshares.blog...Xml For Dummies   Chapter 8 Understanding And Using Dt Ds it-slideshares.blog...
Xml For Dummies Chapter 8 Understanding And Using Dt Ds it-slideshares.blog...
 
WEB TECHNOLOGIES XML
WEB TECHNOLOGIES XMLWEB TECHNOLOGIES XML
WEB TECHNOLOGIES XML
 
Web Services Part 1
Web Services Part 1Web Services Part 1
Web Services Part 1
 
paper about xml
paper about xmlpaper about xml
paper about xml
 
uptu web technology unit 2 Xml2
uptu web technology unit 2 Xml2uptu web technology unit 2 Xml2
uptu web technology unit 2 Xml2
 
Web programming xml
Web programming  xmlWeb programming  xml
Web programming xml
 
Xml
XmlXml
Xml
 
Introduction to xml
Introduction to xmlIntroduction to xml
Introduction to xml
 

Mehr von Marco Bresciani

Personal kanban: diamo i numeri!
Personal kanban: diamo i numeri!Personal kanban: diamo i numeri!
Personal kanban: diamo i numeri!Marco Bresciani
 
Db per guerre stellari rpg (weg 2a ed.)
Db per guerre stellari rpg (weg 2a ed.)Db per guerre stellari rpg (weg 2a ed.)
Db per guerre stellari rpg (weg 2a ed.)Marco Bresciani
 
Tiger: Java 5 Evolutions
Tiger: Java 5 EvolutionsTiger: Java 5 Evolutions
Tiger: Java 5 EvolutionsMarco Bresciani
 
Progetto e Sviluppo di un Sistema per il Gioco degli Scacchi Tridimensionali
Progetto e Sviluppo di un Sistema per il Gioco degli Scacchi TridimensionaliProgetto e Sviluppo di un Sistema per il Gioco degli Scacchi Tridimensionali
Progetto e Sviluppo di un Sistema per il Gioco degli Scacchi TridimensionaliMarco Bresciani
 
Intelligenza artificiale tra fantascienza e realtà
Intelligenza artificiale  tra fantascienza e realtàIntelligenza artificiale  tra fantascienza e realtà
Intelligenza artificiale tra fantascienza e realtàMarco Bresciani
 
La Misura di un... Robot
La Misura di un... RobotLa Misura di un... Robot
La Misura di un... RobotMarco Bresciani
 

Mehr von Marco Bresciani (7)

Personal kanban: diamo i numeri!
Personal kanban: diamo i numeri!Personal kanban: diamo i numeri!
Personal kanban: diamo i numeri!
 
Ruby gravaty gem
Ruby gravaty gemRuby gravaty gem
Ruby gravaty gem
 
Db per guerre stellari rpg (weg 2a ed.)
Db per guerre stellari rpg (weg 2a ed.)Db per guerre stellari rpg (weg 2a ed.)
Db per guerre stellari rpg (weg 2a ed.)
 
Tiger: Java 5 Evolutions
Tiger: Java 5 EvolutionsTiger: Java 5 Evolutions
Tiger: Java 5 Evolutions
 
Progetto e Sviluppo di un Sistema per il Gioco degli Scacchi Tridimensionali
Progetto e Sviluppo di un Sistema per il Gioco degli Scacchi TridimensionaliProgetto e Sviluppo di un Sistema per il Gioco degli Scacchi Tridimensionali
Progetto e Sviluppo di un Sistema per il Gioco degli Scacchi Tridimensionali
 
Intelligenza artificiale tra fantascienza e realtà
Intelligenza artificiale  tra fantascienza e realtàIntelligenza artificiale  tra fantascienza e realtà
Intelligenza artificiale tra fantascienza e realtà
 
La Misura di un... Robot
La Misura di un... RobotLa Misura di un... Robot
La Misura di un... Robot
 

Kürzlich hochgeladen

Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 

Kürzlich hochgeladen (20)

Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 

XML Introduction Exploring the 'My Computer' Example

  • 1. XML Introduction Ing. Marco BRESCIANI XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 2. What Is XML? Page 2 XML is a W3C Recommendation (http://www.w3.org/XML/); the acronym means eXtensible Markup Language:  It’s a mark-up, just like HTML. It was designed to describe data (metadata language):  It does not define or perform operations on data;  It needs a grammar to describe data:  XML Schema is a standard grammar;  DTD is a standard grammar, old-fashioned. It does not define tags:  HTML is <html></html>;  XML is NOT <xml></xml>. It is self-descriptive: an XML file with its grammar is self-contained. XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 3. Why XML? Page 3 XML describes data:  Keeps data separated from their graphical layout;  Allows automatic data management and exchange;  Can define new languages in order to produce specific data formats;  A single XML file and the data it contains can be managed in different ways. XML is precise and safe:  HTML allows this: <HtML> content </HTml> or <HTML> content (?);  XML force this: <tag> content </tag> or <tag />.  Refers to a grammar that can be used to do more checks. XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 4. How XML? Page 4 XML has been defined to be managed through software in order to produce different outputs, to evaluate data and to transform them in many ways… simply using text files! A simple XML file: <article> <paragraph title="Paragraph Title"> <text>This is the text</text> </paragraph> </article> XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 5. Some XML Details Page 5 There are some constrains that each XML file must observe:  All XML files must start with a prologue: <?xml version='1.0' encoding='utf-8'?> where version can be “1.0” or “1.1” and encoding is the name of a valid ISO charset: “utf-8”, “iso-8859-15”, “utf-16”, “iso-2022-jp”, …;  All elements are case-sensitive. Standard suggests the used of lowercase: <TAG> or <Tag> or <tag> represent three different elements;  Element tags must be ordered in the open/close sequence;  Attributes must be contained between ’ or “ delimiters;  A document must contain a single root element that contains all the others: <?xml version='1.0' encoding='utf-8'?> <root> Document content (other element tags) </root> XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 6. XML Definition Page 6 As stated, XML does not define tags so we cannot say (as for HTML), <em> tag identifies an emphasis on text or <table> tag identifies the beginning of a tabular data structure and so on. How can we define XML? XML can be defined by defining an XML application. What is an XML application? An XML application is a language, based on XML structure/grammar, that defines the structure of a data set. What is XML? XML is a standard way to define data structures (and much more… we’ll see…). XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 7. Smart XML Example Page 7 As states, XML does not define how to use data, only their logical representation. This is a set of data: <?xml version="1.0" encoding="UTF-8"?> <X3D profile="Immersive" xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="http://www.web3d.org/specifi cations/x3d-3.0.xsd"> <head> <meta content="Scacchiera.x3d" name="filename"/> <meta content="Scacchiera Tridimensionale di Star Trek" name="description"/> <meta content="Marco Bresciani" name="author"/> <meta content="Marco Bresciani" name="translator"/> <meta content="1998" name="created"/> <meta content="2004-09-01" name="translated"/> <meta content="2005-02-23" name="revised"/> <meta content="200502.23.1905" name="version"/> <meta content="http://marcobresciani.altervista.org" name="reference"/> … How can this data be represented? Look on the right! XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 8. Another XML Example Page 8 Remember: XML does not define how to use data! <project_statistics> <master_url>http://setiathome.ssl.berkeley.edu/</master_url > <daily_statistics> <day>1138233600.000000</day> <user_total_credit>25489.045579</user_total_credit> <user_expavg_credit>89.772845</user_expavg_credit> <host_total_credit>5259.731942</host_total_credit> <host_expavg_credit>89.661763</host_expavg_credit> </daily_statistics> <daily_statistics> <day>1138579200.000000</day> <user_total_credit>25615.527457</user_total_credit> <user_expavg_credit>70.733574</user_expavg_credit> <host_total_credit>5386.213820</host_total_credit> <host_expavg_credit>70.659423</host_expavg_credit> </daily_statistics> … Data above could be represented as on the left or in any other ways. XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 9. XML: « My Computer » Example (1 of 5) Page 9 Now, we begin working with some basic XML with a(n almost) complete example. After this, we will describe XML grammar(s) in detail. This sample XML file (briefly) represents the structure and components of a generic PC (not completely true… we’ll see that): the parts that compose the PC, the details about those parts and so on. The XML file, even if be simple, allows the beginners to have a smart view of the XML standard itself, by introducing its features and possibilities with a simple structure based on a known thing. Let’s see the XML file: please note that elements (tags) are uppercase to enhance readability… XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 10. XML: « My Computer » Example (2 of 5) Page 10 <?xml version="1.0"?> <PART> <!DOCTYPE PARTS SYSTEM "parts.dtd"> <ITEM>Sound Card</ITEM> <?xml-stylesheet type="text/css" <MANUFACTURER>Creative href="xmlpartsstyle.css"?> Labs</MANUFACTURER> <PARTS><TITLE>Computer Parts</TITLE> <MODEL>Sound Blaster <PART> Live</MODEL> <ITEM>Motherboard</ITEM> <COST>80.00</COST> <MANUFACTURER>ASUS</MANUFACTURER> </PART> <MODEL>P3B-F</MODEL> <PART> <COST>123.00</COST> <ITEM>19 inch Monitor</ITEM> </PART> <MANUFACTURER>LG <PART> Electronics</MANUFACTURER> <ITEM>Video Card</ITEM> <MODEL>995E</MODEL> <MANUFACTURER>ATI</MANUFACTURER> <COST>290.00</COST> <MODEL>All-in-Wonder Pro</MODEL> </PART> <COST>160.00</COST> </PARTS> </PART> XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 11. XML: « My Computer » Example (3 of 5) Page 11 In the previous page we saw:  A computer is a list of <PARTS> with a name defined by a <TITLE>;  The list of <PARTS> is composed by a number or <PART> element;  Each <PART> has its own details:  An <ITEM> that describes the kind of part we are writing about;  A <MANUFACTURER> that states the builder of the <PART>;  A <MODEL> that renders the description of the <PART>, also given by <ITEM>;  A <COST> that specifies the money you spent to buy that component. We saw a <!DOCTYPE PARTS SYSTEM “parts.dtd”> tag too: this is used to relate the XML to its grammar. Let’s see it… XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 12. XML: « My Computer » Example (4 of 5) Page 12 Using the DTD standard (simpler, for beginners) we can define the grammar of our “My Computer” description: <!ELEMENT PARTS (TITLE?, PART*)> <!ELEMENT TITLE (#PCDATA)> <!ELEMENT PART (ITEM, MANUFACTURER, MODEL, COST)+> <!ATTLIST PART type (computer|auto|airplane) #IMPLIED> <!ELEMENT ITEM (#PCDATA)> <!ELEMENT MANUFACTURER (#PCDATA)> <!ELEMENT MODEL (#PCDATA)> <!ELEMENT COST (#PCDATA)> The DocType element described before defines the language we are going to use in our XML file. The grammar file defines the details of such language Let’s check the DTD grammar, step-by-step… XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 13. XML: « My Computer » Example (4a of h) Page 13 We said an XML file must contains a single element which will contain all the other elements: <!ELEMENT PARTS (TITLE?, PART*)> This description states that the root element is called PARTS and that it will contain a sequence (, symbol) of zero-or-one (? symbol) TITLE elements and zero-or-more (* symbol) PART elements. So, a file that will contain: <PARTS><TITLE></TITLE><TITLE></TITLE>… Wont’ be correct due to the wrong number of TITLE elements. XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 14. XML: « My Computer » Example (4b of h) Page 14 The second description in the DTD file will represent the “content-type” of the TITLE element: <!ELEMENT TITLE (#PCDATA)> This means that the TITLE element can contain any sequence of data described as a #PCDATA by the XML standard itself. This is a generic sequence of valid characters, number, symbols and so on. Valid #PCDATA data are: Afe5o 8ghert 4534 -.f,.5,g … and so on. The user that’ll define this element would probably use meaningful data as: <TITLE>This is My Computer</TITLE>. XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 15. XML: « My Computer » Example (4c of h) Page 15 The third element describes the structure of the PART element: <!ELEMENT PART (ITEM, MANUFACTURER, MODEL, COST)+> as a sequence (, symbol) of four other elements: ITEM, MANUFACTURER, MODEL and cost. Each sequence (that is: each PART element) must be present one-or-more time (+ symbol). XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 16. XML: « My Computer » Example (4d to h) Page 16 All the other elements are quite simple and state the fact that the PART sub-elements are defined as simple text (#PCDATA): <!ELEMENT ITEM (#PCDATA)> <!ELEMENT MANUFACTURER (#PCDATA)> <!ELEMENT MODEL (#PCDATA)> <!ELEMENT COST (#PCDATA)> So, even those elements are defined as generic and not constrained to a specific format. XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 17. XML: « My Computer » Example (5 of 5) Page 17 What we learned?  XML can defined structured data;  Every one can define its own XML application;  Each XML application represents a new language related to data it can represent and manage;  An XML-based language defines it capabilities through a grammar that states how data can be structured and related. What are we going to learn?  Why a grammar?  Which kind of grammar?  Many other aspects of XML… XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 18. The Needs of the Grammar Page 18 As stated, a grammar defines the “words” (elements or tags) we can use in our XML-based language. Is it needed?  XML is defined to be managed by software:  How can a software knows if a tag (element) is allowed in my language? BASIC programming language allows the PRINT instruction while Java does not;  How can a software knows if elements are written in the correct order? PRINT “HELLO” is a valid instruction while “HELLO” PRINT is not;  How can a software knows how to relate data? An address belongs to an house or to the owner of the house?  XML can also be interpreted and produced in different ways. Grammar helps software in describing data content;  Grammars are also used by automatic parsers, validators and editors in order to help the user in hand-writing XML document. XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 19. Which Grammar? Page 19 XML can use and be defined by a couple of standard grammar: DTD and XML Schema. Few notes about DTD:  It’s older;  It uses a specific syntax different from XML;  Cannot define or constrain data types; Few notes about XML Schema:  It’s a newer standard;  It’s a XML application: defined using XML, uses XML to define XML languages!  Allows constraints on data types and contents; XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 20. XML Schema: a Brief Introduction (1 of 2) Page 20 The W3C XML Schema Definition Language is an XML language (W3C Recommendation) for describing and constraining the content of XML documents. The purpose of an XML Schema is to define the legal building blocks of an XML document, just like a DTD. An XML Schema:  defines elements that can appear in a document;  defines attributes that can appear in a document;  defines which elements are child elements;  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. XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 21. XML Schema: a Brief Introduction (2 of 2) Page 21 XML Schema has more features than DTD:  Supports data type;  Uses XML syntax;  Secures data communications  A date like this: “03-11-2004” could be interpreted as 3. November or as 11. March. An XML element like: <date type="date">2004-03-11</date> ensures a mutual understanding because the XML data type date requires the format YYYY-MM-DD.  Is extensible  A Schema can be used inside another schema or modified/extended/merged by other schemas. XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 22. XML Schema Vs. DTD: Example (1 of 4) Page 22 This is a simple example of a XML file: <?xml version="1.0"?> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> Where elements and file (data) structure are very simple. XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 23. XML Schema Vs. DTD: Example (2 of 4) Page 23 The DTD file that describes the previous XML sample could be: <!ELEMENT note (to, from, heading, body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)> And we saw elements descriptions and meaning before… XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 24. XML Schema Vs. DTD: Example (3 of 4) Page 24 The XML Schema that describe the XML sample data file could be: <?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"> <xs:element name="note"> <xs:complexType><xs:sequence> <xs:element name="to" type="xs:string"/> <xs:element name="from" type="xs:string"/> <xs:element name="heading" type="xs:string"/> <xs:element name="body" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 25. XML Schema Vs. DTD: Example (4 of 4) Page 25 Let’s focus on elements: the attributes contained in the <xs:schema> tag are a detail information we don’t need (now).  With respect to elements, the DTD <!ELEMENT> object becomes <xs:element>: the name of the element is an attribute of the tag itself;  A <xs:complexType> means that an element contains other elements;  The <xs:sequence> elements describe a mandatory list of elements inside another element, just like the <,> operator did in DTD;  The xs:string attribute defines a type (!) and says that the related elements can contain strings: <to>content string<to>. XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 26. References to XML Schema or DTD Page 26 So, how can a XML file refer to a given XML Schema or DTD that describe it? Let’s see the XML Schema: <?xml version="1.0"?> <note xmlns="http://www.w3schools.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com note.xsd"> … </note> And then the DTD: <?xml version="1.0"?> <!DOCTYPE note SYSTEM "http://www.w3schools.com/dtd/note.dtd"> <note> … </note> XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 27. XML Schema Data Types Page 27 This grammar language defines many data types:  xs:string – generic sequence of characters;  xs:boolean – true/false values that can be represented with 1/0 too;  xs:decimal – sequence of numbers only, with a possible minus sign (-) preponed and a decimal separator (.);  xs:positiveInteger – integer non-negative values;  xs:byte – a single byte, from –128 to 127;  xs:unsignedByte – an integer number, from 0 to 255;  xs:complexType – can contain other elements;  xs:sequence – describe a sequence of elements;  xs:choice – describe alternate elements; … XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 28. XML: Some (Very Few) References Page 28 The XML Standard: http://www.w3.org/XML/; XML Schema: http://www.w3.org/XML/Schema;  A tutorial: http://www.w3schools.com/schema/default.asp; DTD Tutorial: http://www.w3schools.com/dtd/default.asp; Java Technology & XML: http://java.sun.com/xml/; XML and C:  The XML C parser and toolkit of Gnome: http://xmlsoft.org/;  Apache Xerces API: http://xml.apache.org/index.html; Web Syndication (with XML): http://en.wikipedia.org/wiki/Web_syndication; XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 29. XML: Where From Here? Page 29 XML standard(s) has many other features and capabilities:  It allows querying a database through XML Query standard;  It allows automatic translations from XML to any other language ((X)HTML in primis), data structure, … through the use of XSL Transformation language family;  Can describe “well-known” data and information such as:  geometric drawings and diagrams through SVG (Scalable Vector Graphics);  mathematical expressions, through MathML;  three-dimensional environments, with X3D;  chess games and players information, with LCARS-ML, ChessGML, ChessML, …;  It allows information spreading and syndication with RSS, Atom, …  To be continued… Let’s take a look at the “big picture”! XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 30. XML Family: The Big Picture Page 30 XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel
  • 31. Page 31 www.alcatel.com XML Introduction / 6 November, 2013 All rights reserved © 2005, Alcatel