XML
Extensible Markup Language
SOA Module
AY : 2023-2024
Objectives
Know the role of XML.
Learn the structure and syntax rules of an XML
document.
Outline
Introduction
Data Structure
XML overview
XML document structure
Introduction 1/2
The Yellow Pages
Introduction 2/2
• The data must be organized in a certain way, which
enables the automatic processing of the latter to be more
efficient and rapid.
using a data structure.
5
XML
1/2 Data Structure
• Data structure:
• An organization of information.
• is intended to contain data, in order to give them an
organization allowing them to simplify their
processing.
significantly reduce the complexity of an IT
application and reduce the error rate.
6
XML
2/2 Data Structure
• Different data structures exist:
- Table:
- Chain list:
- Tree:
7
XML
Description Languages for
structured document 1/3
⚫ The most common languages used to encode a structured
document using tags are:
SGML HTML XML
1986 1991 1996
Generalized Standard Hyper Text Extensible
Markup Language Markup Language Markup Language
8
XML
Description Languages for
structured document 2/3
⚫ SGML is a language used to specify the structure of any document. It is
understandable but it was not suitable for writing documents for the internet. It was
therefore necessary to derive the HTML language from it.[1]
⚫ HTML is the standard for web development but it is not possible to
Set something other than a Web page.
[1]
1986 1996
⚫ XML is a derivative of SGML. It tries to be more flexible than HTML and simpler
than SGML.
9
XML
Description Languages for
structured documents3/3
Complex Syntax
SGML
Non-flexible, frozen
HTML 1996
• Structuring, exchange of documents
XML
Simpler than SGML
More flexible than HTML
10
XML
XML overview
• Extensible Markup Language.
• Tag language.
• W3C Recommendation.
• XML described, structure, data exchange.
• Archive data.
11
XML
Why use XML?
• Readable: Tagged text with markup.
• Extensible: Supports application evolution.
• Formatting with style sheets.
• A meta language allowing the definition of languages adapted
to various beso1i9n86s.
• Supported by leading manufacturers: IBM, Microsoft .net,
SUN, etc.
12
XML
XML Tree
• An XML document consists of
Root Node
multiple nodes. Recipe
Node 1 Ingredients Title Category
· The tree of a
XML document is the
Ingredient Node 1.2
Node 1.1 Ingredient
hierarchical structure
of nodes. Name Node 1.1.1
Quantity Node 1.1.2
13
XML
Structure of a 1/8 XML document
• An XML document contains:
-a prolog.
-the element tree.
-possibly comments
14
XML
Structure of an XML 2/8 document
·Prolog
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
The XML Prolog:
▪ is a processing instruction for the application processing the XML document
▪ is optional, but highly recommended
▪ describes:
- XML language version ="1.0"
- Character encoding (default UTF-8) encoding="UTF-8"
- Dependence on external documents standalone="yes"
15
XML
Structure of an XML 3/8 document
• XML nodes
There are three types of XML nodes:
1 The elements
2 Attributes
3 Entities
16
XML
Structure of a 4/8 XML document
1 The elements
• A clip opens and closes with a tag
• The name of the clip is listed in the opening tag and the closing
tag.
<category>Dessert</category>
Opening Tag Closing Tag
17
XML
Structure of a 5/8 XML document
2 Attributes
• The attribute is in the opening tag of an element
• Attribute is not included in closing tag
• An element can contain multiple attributes
• The same attribute cannot be present only once in an element
• The order of attributes does not matter within an element
• The attribute value is enclosed in quotation marks
<unit quantity ="g" >100</quantity>
18
XML
Structure of an XML 6/8 document
23 Entities
• Some characters have special meaning in XML (special characters)
Example: >, &, "
• Entities have been predefined to use reserved characters
by;&entity;
• An entity is a character string starting with & and ending
• An entity is replaced by the character string that it represents.
19
XML
Structure of a 7/8 XML document
Predefined entities
Character Entity
& &
< <
> >
" "a;
' '
Example:
<message>salary < 1000</message>
20
XML
Structure of an 8/8 XML document
• Comments
<!— This is a comment —>
Comments are ignored when interpreting the XML
document.
21
XML
The syntax rules
• An XML document has a single root element.
• An element may:
▪Be empty
<empty/>
▪Contain a character string
<category>Dessert</category>
▪Contain child elements (which must be properly nested)
<ingredient>
<name>butter</name>
<quantity>100</quantity>
</ingredient>
· XML is case sensitive
<Category>Incorrect</category>
22
XML
Sample XML Document
Prolog
version="1.0" encoding="ISO-8859-1"
standalone="yes"?> <ENGINES>
<ENGINE make = "Peugeot">
<POWER>5</POWER>
<CYLINDER>1.2</CYLINDER>
<FUEL>Gasoline</FUEL >
Attribute
</ENGINE>
<ENGINE made = "Renault">
<POWER>4</POWER>
<CYLINDER>1.3</CYLINDER>
<FUEL>Diesel & Diesel</ FUEL >
</ENGINE>
</ENGINES> Entity
23
XML
Well-formed XML document
XML
<product quantity= "80">
<id> 123</id>
<product>
Well-formed XML document
XML syntax compliance
24
XML
Grammar
1 DTD
• A Document Type Definition (DTD) is a grammar used to define an XML document type
structure.
2 XSD
• XML Schema is an XML document format description language used to define the
structure and content type of an XML document.[2]
• This definition makes it possible in particular to check the validity of this document.
25
XML
Valid XML Document
XSD
Valid XML Document
XSD Policy Compliance
26
XML
In summary
• XML is a data structuring language
• An XML document is structured using elements and
attributes
• An XML document must follow the syntax rules to be
well formed
27
XML
References
• [1]http://www.gchagnon.fr/cours/xml/base.html
• [2]http://fr.wikipedia.org/wiki/XML_Schem
28
XML