sommairelexique langages & documents réfs paul franchi si 4 2013-14 techs...... 13/01/2014...

52
Sommaire Lexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs . . . . . . 03/07/22 Transparent - 1 Chap IV DTD "Document Type Definition" Chap VII XML Schémas révision Nov 2013: contenu mixte % Entity xmlns:not déterminsime edutechwiki extension DTD ext

Upload: dartagnan-leray

Post on 03-Apr-2015

102 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

Langages & Documents RéfsRéfs

Paul FranchiSI 4

2013-14

TechsTechs

..

..

..

..

.

..

11/04/23 Transparent - 1

Chap IV

DTD "Document Type Definition"

Chap IV

DTD "Document Type Definition"

Chap VII

XML Schémas

révision Nov 2013:contenu mixte% Entityxmlns:notdéterminsimeedutechwikiextension DTD ext

Page 2: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

LexiqueLexique

RéfsRéfs

TechsTechs

SommaireSommaire

..

..

..

..

.

..

Transparent 211/04/23

Sommaire du Cours

Chap I - Documents: Historique, Modèles, Standards et Références

Chap II - HTML: voir le cours CIP1-CMD & HTML5

Chap III - XML: "eXtensible Markup Language", les Bases

Chap IV - DTD: "Document Type Definition"

Chap V - CSS: Feuilles de Styles en Cascades& CSS3

Chap VI - DOM, DHTML: "Domain Object Model "& Programmation

Dynamique en HTML & SPRY & JQuery

Chap VII - XSD: Schémas XML

Chap VIII - XML "Advanced" Processeurs et Dialectes: XPath, Xlink

Chap IX - XSLT: Transformations XML

Chap X - RDF: "Resource Description Framework"

Chap IX - AJAX: "Asynchronous JavaScript And XML"

Savoir-Faire: Know Hows

HTML XHTML CSS JS+DOM MATHML XPATH XLINK XSLT

Etat de l'art:

HTML5 CSS3 SPRY SVG RDF AJAX XUL

Page 3: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

LexiqueLexique

RéfsRéfs

TechsTechs

SommaireSommaire

..

..

..

..

.

..

Transparent 311/04/23

Web W3C tutorial : http://www.w3schools.com/

Mozilla Development Center http://developer.mozilla.org/en/docs/Main_Page

W3C, http://www.w3.org/

EdutechWiki http://edutechwiki.unige.ch/

Web Developer's Bookmarks http://antriksh.com/resources/

Biblio: many issues at EPU's lib

Some Références

Page 4: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

LexiqueLexique

RéfsRéfs

TechsTechs

SommaireSommaire

..

..

..

..

.

..

Transparent 411/04/23

Documentation et Manuels Documents du web

liste de balises HTML

code des couleurs RVB

code HTML des caractères ISO

liste des extensions de fichiers (formats)

Expressions Rationnelles

Manuels. Expressions régulières sous Em

acs

Recherche et remplacement sous Emacs

compléments Emacs

grep sous Unix

Tutoriaux du Web W3C : http://www.w3schools.com/

Edutechwiki : http://edutechwiki.unige.ch/

CSS Play : http://www.cssplay.co.uk/index

Zen Garden :

http://www.csszengarden.com/tr/francais/

CSS in10 steps :

http://www.barelyfitz.com/screencast/html-training/css/positioning/

10 steps to better CSS:

http://shapeshed.com/journal/10_steps_to_better_css/

Page 5: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

LexiqueLexique

RéfsRéfs

TechsTechs

SommaireSommaire

..

..

..

..

.

..

Transparent 511/04/23

Références Web

Page 6: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

LexiqueLexique

RéfsRéfs

TechsTechs

SommaireSommaire

..

..

..

..

.

..

Transparent 611/04/23

API – Application Programming Interface ANSI – American National Standards Institute ASCII – American Standard Code for Information Interchange (128 car.) AJAX – Asynchronous JavaScript & XML CSS – Cascading Style Sheets DHTML – Dynamic HTML DOM – Document Object Model DTD – Document Type Definition HTML – HyperText Markup Language HTTP – HyperText Transfer Protocol ISO - International Standards Organization Mozilla - Fondation (global community for free and open Internet software)) MVC - Model View Controler RDF - Resource Description Framework REST - Representational State Transfer RIA - Rich Internet Application RSS - Really Simple Syndication SGML - Standard Generalized Markup Language SOAP - Simple Access Object Protocol SPRY - Extensions JS pour HTML - Adobe Lab. SVG - Scalable Vector Graphics UNICODE – World wide Code (16 bits) UTF-8 – Unicode version 8 bits URL / URI – Uniform Resource Locator / Identifier XML – eXtensible Markup Language XBL – XML Binding Language (Mozilla) XForms – XML Forms XHTML – HTML 4 en XML XLink – XML Linking Language XPath – XML Path Language XPointer – XML Pointer Language XSL - eXtensible Stylesheet Language XSLT – XSL Transformations XSL-FO – XSL Formatting Objects XSD – XML Schémas Définition Language XUL – XML User Language (Mozilla) W3C – World Wide Web Consortium Web2.0 – Web dit "sémantique" WHATWG - Web Hypertext Application Technology Working Group WSDL - Web Service Description Language

Lexique

Page 7: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

Langages & Documents RéfsRéfs

Paul FranchiSI 4

2013-14

TechsTechs

..

..

..

..

.

..

11/04/23 Transparent - 7

Chap IV- DTD

"Document Type Definition"

Chap IV- DTD

"Document Type Definition"

Structure des Documents

Opérateurs Régulièrs

Dialectes XML

EntitésValidation

Structure des Documents

Opérateurs Régulièrs

Dialectes XML

EntitésValidation

Page 8: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 811/04/23

Document Type Definition La DTD définit les constructions « valides » pour un

document XML ou HTML.

La DTD définit la structure du document et le type des éléments possibles.

La déclaration de DTD est optionnelle (mais, avec mode "quirks" pour xml sous I.E.).

La DTD permet d’établir la validité d’un document

La DTD permet de définir des modèles de documents: Dialectes, Echanges

Déclaration externe de la DTD <!DOCTYPE nomDoc SYSTEM  "dtd-file" >

Déclaration interne de la DTD<!DOCTYPE root-element [ ( element-declaration ) * ]>

La DTD définit les constructions « valides » pour un document XML ou HTML.

La DTD définit la structure du document et le type des éléments possibles.

La déclaration de DTD est optionnelle (mais, avec mode "quirks" pour xml sous I.E.).

La DTD permet d’établir la validité d’un document

La DTD permet de définir des modèles de documents: Dialectes, Echanges

Déclaration externe de la DTD <!DOCTYPE nomDoc SYSTEM  "dtd-file" >

Déclaration interne de la DTD<!DOCTYPE root-element [ ( element-declaration ) * ]>

Page 9: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 911/04/23

Document Type Definition

Déclaration externe <!DOCTYPE nomDoc SYSTEM  "dtd-file" > Déclaration externe <!DOCTYPE nomDoc SYSTEM  "dtd-file" >

<?xml version="1.0"?>

<!DOCTYPE note SYSTEM  "note.dtd" > <note> <to>Vous</to> <to>Les Autres</to> <from>Moi</from> <body>N'oubliez pas de rendre vos TPs </body> <erreur> Pour tester la validité </erreur></note>

•xml•dtd

<!–- note.dtd -->

<!ELEMENT note (to+, from, subject?, body) ><!-- ici ordre imposé des éléments--> <!ELEMENT to (#PCDATA) > <!ELEMENT from (#PCDATA) > <!ELEMENT subject (#PCDATA) > <!ELEMENT body (#PCDATA) ><!-- commentaires au format xml -->

Page 10: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 1011/04/23

Document Type Definition

Déclaration interne<!DOCTYPE root-element [ ( element-declaration ) * ]>

Déclaration interne<!DOCTYPE root-element [ ( element-declaration ) * ]>

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

<!DOCTYPE note[

<!ELEMENT note (to+, from, subject?, body)><!-- ici ordre imposé des éléments--> <!ELEMENT to (#PCDATA) > <!ELEMENT from (#PCDATA)> <!ELEMENT subject (#PCDATA)> <!ELEMENT body (#PCDATA)><!-- commentaires au format xml --> ]><note> <to>Vous</to> <to>Others</to> <from>Moi</from> <body>N'oubliez pas de rendre vos TPs </body> <erreur> Pour tester la validité </erreur></note> •xml

Page 11: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 1111/04/23

SyntaxeUne DTD définit un modèle de document (XML, HTML) en terme de:

Elements Attributes Entities PCDATA CDATA

Commentaires multilignes entre -- et --, dans les <! > Texte - (#PCDATA) «parsed character data» - analysé par le parseur XML

Entité - fragment de texte nommé réutilisable<!ENTITY accueil "Bienvenue … " ><!ENTITY doc1 "document1.xml" ><!ENTITY monSite "http://www.essi.fr/~pfz" ><!ENTITY lt "&#60;" -- utilisation &lt; -- > Elément – nœud associé à 2 balises (O et F) et un contenu (evt vide)<!ELEMENT auteur (#PCDATA) -- type TEXT -- ><!ELEMENT html (head, body) ><!ELEMENT void EMPTY -- vide -- > <!ELEMENT libre ANY -- non typé, mais les sous éléments ? -- >

Attribut – nœud (une information) associé à une balise (O) et une valeur <!ATTLIST lettre ref CDATA #REQUIRED date CDATA #IMPLIED >

Section de Code – non analysée par le parseur XML<! [ CDATA [ ici code source non analysé avec < > mais pas "]]" ….. ] ] >

Une DTD définit un modèle de document (XML, HTML) en terme de: Elements Attributes Entities PCDATA CDATA

Commentaires multilignes entre -- et --, dans les <! > Texte - (#PCDATA) «parsed character data» - analysé par le parseur XML

Entité - fragment de texte nommé réutilisable<!ENTITY accueil "Bienvenue … " ><!ENTITY doc1 "document1.xml" ><!ENTITY monSite "http://www.essi.fr/~pfz" ><!ENTITY lt "&#60;" -- utilisation &lt; -- > Elément – nœud associé à 2 balises (O et F) et un contenu (evt vide)<!ELEMENT auteur (#PCDATA) -- type TEXT -- ><!ELEMENT html (head, body) ><!ELEMENT void EMPTY -- vide -- > <!ELEMENT libre ANY -- non typé, mais les sous éléments ? -- >

Attribut – nœud (une information) associé à une balise (O) et une valeur <!ATTLIST lettre ref CDATA #REQUIRED date CDATA #IMPLIED >

Section de Code – non analysée par le parseur XML<! [ CDATA [ ici code source non analysé avec < > mais pas "]]" ….. ] ] >

Page 12: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 1211/04/23

10 types d'attributs pour XML: CDATA -- une chaîne de caractères

<!ATTLIST lettre ref CDATA #REQUIRED date CDATA #IMPLIED > NMTOKEN -- une unité lexicale (nom) XML NMTOKENS -- liste de NMTOKEN séparés par des espaces

<!ATTLIST journal année NMTOKEN #REQUIRED ><!ATTLIST concerts dates NMTOKENS #IMPLIED >

ENUMERATION -- liste de valeurs entre (), séparés par des | <!ATTLIST peinture couleur ( rouge | vert | bleu ) #REQUIRED >

ENTITY-- nom d'entité non analysé ENTITIES -- liste de ENTITY séparés par des espaces

<!ATTLIST notreLogo source ENTITY #FIXED > ID -- identificateur (nom) unique XML IDREF -- référence à un ID IDREFS -- liste de ID séparés par des espaces

<!ATTLIST employé num_secu ID #REQUIRED > NOTATION -- le nom d'une notation déclarée dans la DTD <!NOTATION gif SYSTEM "image/gif" >

<!ATTLIST image type NOTATION (gif | png| jpeg) #REQUIRED >

Valeurs par défaut des attributs (en majuscules) #IMPLIED -- optionnel et valeur par défaut non fournie dans la DTD #REQUIRED -- obligatoire mais pas de valeur par défaut fournie dans la DTD #FIXED -- la valeur par défaut est fixée (et non modifiable) dans la DTD chaîne -- la valeur par défaut modifiable

10 types d'attributs pour XML: CDATA -- une chaîne de caractères

<!ATTLIST lettre ref CDATA #REQUIRED date CDATA #IMPLIED > NMTOKEN -- une unité lexicale (nom) XML NMTOKENS -- liste de NMTOKEN séparés par des espaces

<!ATTLIST journal année NMTOKEN #REQUIRED ><!ATTLIST concerts dates NMTOKENS #IMPLIED >

ENUMERATION -- liste de valeurs entre (), séparés par des | <!ATTLIST peinture couleur ( rouge | vert | bleu ) #REQUIRED >

ENTITY-- nom d'entité non analysé ENTITIES -- liste de ENTITY séparés par des espaces

<!ATTLIST notreLogo source ENTITY #FIXED > ID -- identificateur (nom) unique XML IDREF -- référence à un ID IDREFS -- liste de ID séparés par des espaces

<!ATTLIST employé num_secu ID #REQUIRED > NOTATION -- le nom d'une notation déclarée dans la DTD <!NOTATION gif SYSTEM "image/gif" >

<!ATTLIST image type NOTATION (gif | png| jpeg) #REQUIRED >

Valeurs par défaut des attributs (en majuscules) #IMPLIED -- optionnel et valeur par défaut non fournie dans la DTD #REQUIRED -- obligatoire mais pas de valeur par défaut fournie dans la DTD #FIXED -- la valeur par défaut est fixée (et non modifiable) dans la DTD chaîne -- la valeur par défaut modifiable

Attributs

Page 13: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 1311/04/23

Attributs - Exemples

DTDs:<!ELEMENT square EMPTY> <!ATTLIST square width CDATA "0"><!ATTLIST person code CDATA #REQUIRED><!ATTLIST contact fax CDATA #IMPLIED><!ATTLIST sender company CDATA #FIXED "Microsoft"> <!ATTLIST payment type (check|cash) "cash">

valid XML:<square width="100" /> <square /><person code="007" /><contact fax="555-667788" /> <contact /> <sender company="Microsoft" /> <payment type="check" /> <payment type="cash" />

invalid XML:<person /><sender company="W3Schools" />

DTDs:<!ELEMENT square EMPTY> <!ATTLIST square width CDATA "0"><!ATTLIST person code CDATA #REQUIRED><!ATTLIST contact fax CDATA #IMPLIED><!ATTLIST sender company CDATA #FIXED "Microsoft"> <!ATTLIST payment type (check|cash) "cash">

valid XML:<square width="100" /> <square /><person code="007" /><contact fax="555-667788" /> <contact /> <sender company="Microsoft" /> <payment type="check" /> <payment type="cash" />

invalid XML:<person /><sender company="W3Schools" />

Page 14: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 1411/04/23

Avoid using attributes ?

Some of the problems with attributes are: attributes cannot contain multiple values (child elements can) attributes are not easily expandable (for future changes) attributes cannot describe structures (child elements can) attributes are more difficult to manipulate by program code attribute values are not easy to test against a DTD

If you use attributes as containers for data, you end up with documents that are difficult to read and maintain. Try to use elements to describe data. Use attributes only to provide information that is not relevant to the data.

Don't end up like this (this is not how XML should be used):

<note day="12" month="11" year="2002" to="Tove" from="Jani" heading="Reminder" body="Don't forget me this weekend!">

</note>

Some of the problems with attributes are: attributes cannot contain multiple values (child elements can) attributes are not easily expandable (for future changes) attributes cannot describe structures (child elements can) attributes are more difficult to manipulate by program code attribute values are not easy to test against a DTD

If you use attributes as containers for data, you end up with documents that are difficult to read and maintain. Try to use elements to describe data. Use attributes only to provide information that is not relevant to the data.

Don't end up like this (this is not how XML should be used):

<note day="12" month="11" year="2002" to="Tove" from="Jani" heading="Reminder" body="Don't forget me this weekend!">

</note>

Page 15: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 1511/04/23

Avoid using attributes: Exception! Sometimes I assign ID references to elements. These ID

references can be used to access XML elements in much the same way as the NAME or ID attributes in HTML. This example demonstrates this:

<messages> <note id="p501"> <to>Tove</to> <from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body> </note> <note id="p502"> <to>Jani</to><from>Tove</from><heading>Re:Reminder</heading> <body>I will not!</body> </note></messages>

The ID in these examples is just a counter, or a unique identifier, to identify the different notes in the XML file, and not a part of the note data.

What I am trying to say here is that metadata (data about data) should be stored as attributes, and that data itself should be stored as elements.

Sometimes I assign ID references to elements. These ID references can be used to access XML elements in much the same way as the NAME or ID attributes in HTML. This example demonstrates this:

<messages> <note id="p501"> <to>Tove</to> <from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body> </note> <note id="p502"> <to>Jani</to><from>Tove</from><heading>Re:Reminder</heading> <body>I will not!</body> </note></messages>

The ID in these examples is just a counter, or a unique identifier, to identify the different notes in the XML file, and not a part of the note data.

What I am trying to say here is that metadata (data about data) should be stored as attributes, and that data itself should be stored as elements.

Page 16: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 1611/04/23

Des Arbres Rationnels

Elem obligatoire - 1 fois <!ELEMENT html (body) >

Elem optionnel - 0 ou 1 fois <!ELEMENT html (head?, body) >

Elem 0 ou n fois <!ELEMENT chapitre ( section * ) >

Elem 1 ou n fois <!ELEMENT pour (destinataire +) >

Elem au choix <!ELEMENT message (note | lettre) >

Elem mixte <!ELEMENT chapitre (#PCDATA | section) *>

DTD pour des livres (exemple simplifié et partiel)

Elem obligatoire - 1 fois <!ELEMENT html (body) >

Elem optionnel - 0 ou 1 fois <!ELEMENT html (head?, body) >

Elem 0 ou n fois <!ELEMENT chapitre ( section * ) >

Elem 1 ou n fois <!ELEMENT pour (destinataire +) >

Elem au choix <!ELEMENT message (note | lettre) >

Elem mixte <!ELEMENT chapitre (#PCDATA | section) *>

DTD pour des livres (exemple simplifié et partiel)

<!ELEMENT LIVRE ( DESCRIPTION, CORPS )><!ELEMENT DESCRIPTION (TITRE, SOUSTITRE?, AUTEUR+, DATE )><!ELEMENT CORPS ( DEDICACE?, PROLOGUE?, SOMMAIRE?, (CHAPITRE I SECTION, ILLUSTRATION*)+ , REFERENCES* I BIBLIOGRAPHIE )>

<!ELEMENT LIVRE ( DESCRIPTION, CORPS )><!ELEMENT DESCRIPTION (TITRE, SOUSTITRE?, AUTEUR+, DATE )><!ELEMENT CORPS ( DEDICACE?, PROLOGUE?, SOMMAIRE?, (CHAPITRE I SECTION, ILLUSTRATION*)+ , REFERENCES* I BIBLIOGRAPHIE )>

Page 17: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 1711/04/23

XML : une DTD pour lettre

<!DOCTYPE lettre [<!ELEMENT lettre (haut, corps, bas) ><!ATTLIST lettre ref CDATA #REQUIRED

date CDATA #REQUIRED ><!ELEMENT haut (exp, date, dest+) ><!ELEMENT corps (obj?, cont) ><!ELEMENT bas (pol?, sign) >

<!ELEMENT date (#PCDATA) ><!ELEMENT exp (#PCDATA) ><!ATTLIST exp soc CDATA #IMPLIED >

<!ELEMENT dest (#PCDATA) ><!ATTLIST dest adr CDATA #IMPLIED >

<!ELEMENT obj (#PCDATA) ><!ELEMENT cont (pol?, section*) ><!ELEMENT section (soussec*) >

<!ELEMENT sign EMPTY><!ATTLIST sign CDATA #REQUIRED >

<!ENTITY maSign «PaulSign.jpg>]>

<!DOCTYPE lettre [<!ELEMENT lettre (haut, corps, bas) ><!ATTLIST lettre ref CDATA #REQUIRED

date CDATA #REQUIRED ><!ELEMENT haut (exp, date, dest+) ><!ELEMENT corps (obj?, cont) ><!ELEMENT bas (pol?, sign) >

<!ELEMENT date (#PCDATA) ><!ELEMENT exp (#PCDATA) ><!ATTLIST exp soc CDATA #IMPLIED >

<!ELEMENT dest (#PCDATA) ><!ATTLIST dest adr CDATA #IMPLIED >

<!ELEMENT obj (#PCDATA) ><!ELEMENT cont (pol?, section*) ><!ELEMENT section (soussec*) >

<!ELEMENT sign EMPTY><!ATTLIST sign CDATA #REQUIRED >

<!ENTITY maSign «PaulSign.jpg>]>

Page 18: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 1811/04/23

DTD par Expressions Régulières

Opérateur Description exemple

’ ET

ou

suite requise

A ’ B

B doit suivre A

mais A ne peut pas suivre B

| Alternative (OU) HAUT | BAS

( ) groupement ( A | B ) ’ C

A OU B suivi de C

* 0 ou plusieurs

répétitions

Section *

0 ou plusieurs sections

+ 1 ou plusieurs

répétitions

Auteur +

1 ou plusieurs auteurs

? optionnel Fax ?

<!–- note.dtd --> <!ELEMENT note (subject?, body) | (body, subject?) ><!-- expression non déterministe ->

Page 19: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 1911/04/23

DTD – Validation

<!-- script sous IE 5.0 et + --><script type="text/javascript">var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")xmlDoc.async="false"xmlDoc.validateOnParse="true"xmlDoc.load("note_dtd_error.xml")document.write("<br>Error Code: ")document.write(xmlDoc.parseError.errorCode)document.write("<br>Error Reason: ")document.write(xmlDoc.parseError.reason)document.write("<br>Error Line: ")document.write(xmlDoc.parseError.line)</script>

Avec le W3C Validator on-line

Avec xmllint ss libxml (Linux, Win, Mac)

Avec le parseur XML sous DOM• load(), loadXML() pour fichiers, chaînes XML

Page 20: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 2011/04/23

Données vs Document (1)

Description rigide avec un ordre imposé des éléments Description rigide avec un ordre imposé des éléments

<!DOCTYPE personne [

<!ELEMENT personne (nom+, activité*)><!ELEMENT nom EMPTY><!ATTLIST nom prenom CDATA #REQUIRED

famille CDATA #REQUIRED><!ELEMENT activité EMPTY><!ATTLIST activité quelle CDATA #REQUIRED>]>

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

<personne> <nom prenom= "Alan" famille= "Turing" /> <activité quelle= "mathématicien"/> <activité quelle= "informaticien"/> <activité quelle= "inventeur"/></personne>

Page 21: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 2111/04/23

sans ordre imposé des éléments: "flexible et ouverte" sans ordre imposé des éléments: "flexible et ouverte"

<!DOCTYPE biographie [

-- structure des documents WXML qui peuvent contenir dans n'importe quel ordre des éléments (structurés ou non) de type• texte, non structuré• image, structurée, peut être omise• paragraphe, non structuré• nom, non structuré• lien, hypertexte peut être associé à tous les éléments• date, structurée en jj/mm/aa• personne, structurée en nom et image--]>

<?xml version="1.0"?>

Données vs Document (2)

Page 22: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 2211/04/23

Description "flexible et ouverte" Description "flexible et ouverte"

<!DOCTYPE biographie [<!ELEMENT personne (nom, image) ><!ELEMENT nom #PCDATA >

<!ATTLIST personne naissance CDATA #IMPLIED mort CDATA #IMPLIED >

<!ELEMENT image EMPTY ><!ATTLIST image source CDATA #REQUIRED

width NMTOKEN #REQUIREDheight NMTOKEN #REQUIREDalt CDATA #IMPLIED >

<!ATTLIST lien xlink:type(simple) #IMPLIEDxlink:href CDATA #IMPLIED >

<!ENTITY %tout "(#PCDATA|image|parag|nom|lien|date|personne)* ><!ELEMENT biographie %tout; ><!ELEMENT emphase %tout; ><!ELEMENT parag %tout; >]>

<?xml version="1.0"?>

Données vs Document (2)

Page 23: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 2311/04/23

DTD - pour un programme TV

<!DOCTYPE TVSCHEDULE [

<!ELEMENT TVSCHEDULE (CHANNEL+)><!ELEMENT CHANNEL (BANNER, DAY+)><!ELEMENT BANNER (#PCDATA)><!ELEMENT DAY (DATE, (HOLIDAY|PROGRAMSLOT+ )+ )><!ELEMENT HOLIDAY (#PCDATA)><!ELEMENT DATE (#PCDATA)><!ELEMENT PROGRAMSLOT (TIME, TITLE, DESCRIPTION?)><!ELEMENT TIME (#PCDATA)><!ELEMENT TITLE (#PCDATA)> <!ELEMENT DESCRIPTION (#PCDATA)>

<!ATTLIST TVSCHEDULE NAME CDATA #REQUIRED><!ATTLIST CHANNEL CHAN CDATA #REQUIRED><!ATTLIST PROGRAMSLOT VTR CDATA #IMPLIED><!ATTLIST TITLE RATING CDATA #IMPLIED><!ATTLIST TITLE LANGUAGE CDATA #IMPLIED>]>

Page 24: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 2411/04/23

DTD - pour un catalogue de produits

<!DOCTYPE CATALOG [ <!ENTITY AUTHOR "John Doe"> <!ENTITY COMPANY "JD Power Tools, Inc."> <!ENTITY EMAIL "[email protected]">

<!ELEMENT CATALOG (PRODUCT+)><!ELEMENT PRODUCT (SPECIFICATIONS+, OPTIONS?,P RICE+, NOTES?)><!ATTLIST PRODUCTNAME CDATA #IMPLIEDCATEGORY (HandTool|Table|Shop-Professional) "HandTool"PARTNUM CDATA #IMPLIEDPLANT (Pittsburgh|Milwaukee|Chicago) "Chicago"INVENTORY (InStock|Backordered|Discontinued) "InStock">

<!ELEMENT SPECIFICATIONS (#PCDATA)> <!ATTLIST SPECIFICATIONSWEIGHT CDATA #IMPLIEDPOWER CDATA #IMPLIED>

<!ELEMENT OPTIONS (#PCDATA)> <!ATTLIST OPTIONSFINISH (Metal|Polished|Matte) "Matte" ADAPTER (Included|Optional|NotApplicable) "Included"CASE (HardShell|Soft|NotApplicable) "HardShell">

<!ELEMENT PRICE (#PCDATA)> <!ATTLIST PRICEMSRP CDATA #IMPLIEDWHOLESALE CDATA #IMPLIEDSTREET CDATA #IMPLIEDSHIPPING CDATA #IMPLIED>

<!ELEMENT NOTES (#PCDATA)>]>

Page 25: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 2511/04/23

Entités "générales" internes/externes

<?xml version="1.0"?>

<!DOCTYPE biographie [<!ENTITY writer "Donald Duck."><!ENTITY copyright "Copyright W3Schools.">]>

<biographie > <author>&writer; &copyright;</author> </biographie >

<?xml version="1.0" ?>

<!DOCTYPE biographie [ <!ENTITY writer SYSTEM "http://www.w3schools.com/entities.dtd"><!ENTITY copyright SYSTEM "http://www.w3schools.com/entities.dtd"> ]><biographie > <author>&writer; &copyright;</author> </biographie >

Page 26: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 2611/04/23

Entités & Localisation dans XML

en-US/find-file.dtd

<!ENTITY findLabel "Find">

<?xml version="1.0" ?>

<!DOCTYPE note SYSTEM  "$LANG/find_file.dtd" >

<description value="&findLabel;"/>

fr-FR/find-file.dtd

<!ENTITY findLabel "Cherche">

jp_JP/find-file.dtd

<!ENTITY findLabel " 検索 ">

Page 27: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

définies en interne ou externe mais "utilisées" dans les DTDs externes

"importer" une DTD externe

définies en interne ou externe mais "utilisées" dans les DTDs externes

"importer" une DTD externe

Transparent 2711/04/23

Entités Paramêtres [P comme %]

<?xml version="1.0" ?>

<!DOCTYPE student [

<!ENTITY % student SYSTEM "http://www.university.com/student.dtd">

%student;

]>

<!--external DTD example--> <!ENTITY % p "(#PCDATA)"> <!ELEMENT student (id,surname,firstname,dob,(subject)*)> <!ELEMENT id %p;> <!ELEMENT surname %p;> <!ELEMENT firstname %p;> <!ELEMENT dob %p;> <!ELEMENT subject %p;> >

Page 28: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré Transparent 2811/04/23

DTD et Namespaces

<!DOCTYPE ld:personne [<!ELEMENT ld:personne (ld:nom+, ld:activité*)><!ELEMENT ld:nom EMPTY><!ATTLIST ld:nom prenom CDATA #REQUIRED

famille CDATA #REQUIRED><!ELEMENT ld:activité EMPTY><!ATTLIST ld:activité quelle CDATA #REQUIRED><!ATTLIST ld:personne xmlns:ld CDATA #FIXED "http://polytech/pfz/LANGDOC" >]>

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

<personne xmlns = "http://polytech/pfz/LANGDOC"> <nom prenom= "Alan" famille= "Turing" /> <activité quelle= "mathématicien"/> <activité quelle= "informaticien"/> <activité quelle= "inventeur"/></personne>

Page 29: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 2911/04/23

DTD – Applications Production de Documents

Edition Structurée Validation de structure

Programmation XSLT Parsing DOM & SAX Tree–traversal evaluatio n

Echange de Documents Validation

Fragmentation de Documents

Internationalisation (localisation) entités "locales" (Mozilla, Adobe, Boilerplate, etc.)

mais utilisation non compatible avec la syntaxe XML => XML-Schémas

Production de Documents Edition Structurée Validation de structure

Programmation XSLT Parsing DOM & SAX Tree–traversal evaluatio n

Echange de Documents Validation

Fragmentation de Documents

Internationalisation (localisation) entités "locales" (Mozilla, Adobe, Boilerplate, etc.)

mais utilisation non compatible avec la syntaxe XML => XML-Schémas

Page 30: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 3011/04/23

HTML 4.01 - Strict, Transitional, Frameset: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"

"http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"

"http://www.w3.org/TR/html4/frameset.dtd">

XHTML 1.0 - Strict, Transitional, Frameset: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

MathML 2.0 - DTD: <!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN"

"http://www.w3.org/TR/MathML2/dtd/mathml2.dtd">

XHTML + MathML + SVG - DTD: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"

"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">

SVG 1.0 - DTD: <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-

SVG-20010904/DTD/svg10.dtd">

SVG 1.1 Full - DTD: <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"

"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

HTML 4.01 - Strict, Transitional, Frameset: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"

"http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"

"http://www.w3.org/TR/html4/frameset.dtd">

XHTML 1.0 - Strict, Transitional, Frameset: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

MathML 2.0 - DTD: <!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN"

"http://www.w3.org/TR/MathML2/dtd/mathml2.dtd">

XHTML + MathML + SVG - DTD: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"

"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">

SVG 1.0 - DTD: <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-

SVG-20010904/DTD/svg10.dtd">

SVG 1.1 Full - DTD: <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"

"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

DTDs Standards (W3C)

http://www.w3.org/QA/2002/04/valid-dtd-list.html

http://www.w3.org/QA/2002/04/valid-dtd-list.html

XML Tools

Page 31: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

Langages & Documents RéfsRéfs

Paul FranchiSI 4

2013-14

TechsTechs

..

..

..

..

.

..

11/04/23 Transparent - 31

Chap VII -

XML Schémas

Chap VII -

XML Schémas

XSD

Types simples

Types complexes

Exemple W3C

Tutoriel W3Schools

Tutoriel Schéma @Edutechwiki

XSD

Types simples

Types complexes

Exemple W3C

Tutoriel W3Schools

Tutoriel Schéma @Edutechwiki

Page 32: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 3211/04/23

Langages de Schémas

Page 33: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 3311/04/23

XML – Schémas

Le W3C propose (2001) XSD comme une alternative à la DTD fondée sur XML

un schéma décrit la structure d'un document valide XML

XSD est le dialecte XML de définition des Schémas XML

Schémas vs DTD types de données des éléments et leurs attributs dérivation de type et héritage supporte les espaces de noms syntaxe XML outils XML: éditeurs, parser, DOM, XSL extensibles pour de futurs développements

Le W3C propose (2001) XSD comme une alternative à la DTD fondée sur XML

un schéma décrit la structure d'un document valide XML

XSD est le dialecte XML de définition des Schémas XML

Schémas vs DTD types de données des éléments et leurs attributs dérivation de type et héritage supporte les espaces de noms syntaxe XML outils XML: éditeurs, parser, DOM, XSL extensibles pour de futurs développements

Page 34: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 3411/04/23

XSD - Mon premier Schéma

<?xml version="1.0" ?>

<message

xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"

xsi:noNamespaceSchemaLocation="message.xsd">

Hello

</message>

<?xml version="1.0" ?>

<xs:schema xmlns:xs ="http://www.w3.org/2001/XMLSchema" >

<xs:element name="message" type="xs:string" />

</xs:schema>

Page 35: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 3511/04/23

XSD - Un exemple du W3C

http://www.w3schools.com/schema/schema_howto.asp

Un document "note" http://www.w3schools.com/schema/schema_howto.asp

Un document "note"

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

<!--DOCTYPE note SYSTEM "http://www.w3schools.com/dtd/note.dtd" -->

<note

xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"

xmlns = "si4/LangDoc"

xsi:schemaLocation ="si4/LangDoc note.xsd"

><to> Vous </to><to> Moi </to><to> Les Autres </to>

<from> Moi </from>

<heading> Rappel < /heading >

<body> N'oubliez pas de rendre vos TPs ! </body>

</note>

Page 36: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 3611/04/23

XSD - Un exemple du W3C

Une DTD de note Une DTD de note

<!ELEMENT note (to+, from, heading?, body)>

<!ELEMENT to (#PCDATA)>

<!ELEMENT from (#PCDATA)>

<!ELEMENT heading (#PCDATA)>

<!ELEMENT body (#PCDATA)>

•dtd

Page 37: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 3711/04/23

XSD - Un exemple du W3C

Un Schéma de note Un Schéma de note

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

<xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema"

targetNamespace = "si4/LangDoc"

xmlns = "si4/LangDoc"

elementFormDefault = "qualified">

<xs:element name="note">

<xs:complexType> <xs:sequence>

<xs:element name="to" type="xs:string" maxOccurs="unbounded"/>

<xs:element name="from" type="xs:string"/>

<xs:element name="heading" type="xs:string" minOccurs="0"/>

<xs:element name="body" type="xs:string"/>

</xs:sequence> </xs:complexType>

</xs:element>

</xs:schema>

Page 38: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 3811/04/23

XSD - Exemple du W3C

Un Schéma de note Un Schéma de note

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

<xs:schema xmlns:xs=" http://www.w3.org/2001/XMLSchema "

targetNamespace="si4/LangDoc"

xmlns="si4/LangDoc"

elementFormDefault="qualified" >

<xs:element name="note">

<xs:complexType> <xs:sequence>

<xs:element name="to" type="xs:string" maxOccurs="unbounded"/>

<xs:element name="from" type="xs:string"/>

<xs:element name="heading" type="xs:string" minOccurs="0"/>

<xs:element name="body" type="xs:string"/>

</xs:sequence> </xs:complexType>

</xs:element>

</xs:schema>

•xsd

Page 39: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 3911/04/23

Eléments de Schémas <xs:schema>

Type (8)<xs:simpleType> <xs:complexType> <xs:simpleContent> <xs:complexContent> <xs:extension> <xs:restriction> <xs:list> <xs:union>

Indicateur (7)<xs:all> <xs:any> <xs:anyAttribute> <xs:attributeGroup><xs:choice> <xs:group> <xs:sequence>

Identité (5)<xs:field> <xs:key> <xs:keyref> <xs:selector> <xs:unique>

Importation (3)<xs:import> <xs:include> <xs:redefine>

Restriction (12)<xs:(max|min)(Exc|Inc)lusive> <xs:(max|min)Length> <xs:enumeration> <xs:pattern> <xs:(total|fraction)Digits><xs:length> <xs:whiteSpace>

Documentation (3)<xs:documentation> <xs:annotation> <xs:appinfo>

Type (8)<xs:simpleType> <xs:complexType> <xs:simpleContent> <xs:complexContent> <xs:extension> <xs:restriction> <xs:list> <xs:union>

Indicateur (7)<xs:all> <xs:any> <xs:anyAttribute> <xs:attributeGroup><xs:choice> <xs:group> <xs:sequence>

Identité (5)<xs:field> <xs:key> <xs:keyref> <xs:selector> <xs:unique>

Importation (3)<xs:import> <xs:include> <xs:redefine>

Restriction (12)<xs:(max|min)(Exc|Inc)lusive> <xs:(max|min)Length> <xs:enumeration> <xs:pattern> <xs:(total|fraction)Digits><xs:length> <xs:whiteSpace>

Documentation (3)<xs:documentation> <xs:annotation> <xs:appinfo>

Déclaration (3)<xs:element> <xs:attribute> <xs:notation>

Déclaration (3)<xs:element> <xs:attribute> <xs:notation>

Page 40: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 4011/04/23

XSD – Types Simples Types prédéfinis

xs:string xs:decimal xs:integer xs:boolean xs:date xs:time

Eléments <xs:element name="lastname" type="xs:string"/> <xs:element name="age" type="xs:integer"/> <xs:element name="dateborn" type="xs:date"/>

Attributs <xs:attribute name="lang" type="xs:string"/>

Restrictions <xs:restriction base="xs:integer"> <xs:minInclusive value="0"/> <xs:maxInclusive value="100"/> <xs:enumeration value="Lundi"/> <xs:pattern value="([a-z][A-Z])+"/>

Types prédéfinis xs:string xs:decimal xs:integer xs:boolean xs:date xs:time

Eléments <xs:element name="lastname" type="xs:string"/> <xs:element name="age" type="xs:integer"/> <xs:element name="dateborn" type="xs:date"/>

Attributs <xs:attribute name="lang" type="xs:string"/>

Restrictions <xs:restriction base="xs:integer"> <xs:minInclusive value="0"/> <xs:maxInclusive value="100"/> <xs:enumeration value="Lundi"/> <xs:pattern value="([a-z][A-Z])+"/>

Page 41: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré Transparent 4111/04/23

XSD – Types Prédéfinis

Simple Type Examples Explanation

negativeInteger ... -2, -1

long -9223372036854775808, ... -1, 0, 1, ...

9223372036854775807

decimal -1.23, 0, 123.4, 1000.00

float -INF, -1E4, -0, 0, 12.78E-2, 12, INF,

NaN

boolean true, false, 1, 0

duration P1Y2M3DT10H30M12.3S 1 year, 2 months, 3 days, 10 hours, 30 minutes, and 12.3 sec

dataTime 1999-05-31T13:20:00.000-05:00 May 31st 1999 at 1.20pm Eastern Standard Time

date 1999-05-31

time 13:20:00.000, 13:20:00.000-05:00

gYear 1999

Name shipTo XML 1.0 Name type

QName po:USAddress XML Namespace QName

http://www.example.com/

language en-GB, en-US, fr valid values for xml:lang as defined in XML 1.0

Page 42: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 4211/04/23

XSD – Types Complexes (1)

Eléments & types <xs:element name="employee">

<xs:complexType> <xs:sequence> <xs:element name="firstname"

type="xs:string"/> <xs:element name="lastname"

type="xs:string"/> </xs:sequence> </xs:complexType>

</xs:element>

<xs:complexType name="persontype"> <xs:sequence> <xs:element name="firstname" type="xs:string"/>

<xs:element name="lastname" type="xs:string"/> </xs:sequence>

</xs:complexType>

<xs:element name="person" type="persontype"/> <xs:element name="studient" type="persontype"/>

Eléments & types <xs:element name="employee">

<xs:complexType> <xs:sequence> <xs:element name="firstname"

type="xs:string"/> <xs:element name="lastname"

type="xs:string"/> </xs:sequence> </xs:complexType>

</xs:element>

<xs:complexType name="persontype"> <xs:sequence> <xs:element name="firstname" type="xs:string"/>

<xs:element name="lastname" type="xs:string"/> </xs:sequence>

</xs:complexType>

<xs:element name="person" type="persontype"/> <xs:element name="studient" type="persontype"/>

Page 43: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 4311/04/23

XSD – Types Complexes (2) Eléments & types

<xs:complexType name="personinfo"> <xs:sequence> <xs:element name="firstname" type="xs:string"/>

<xs:element name="lastname" type="xs:string"/> </xs:sequence>

</xs:complexType>

<xs:complexType name="fullpersoninfo"> <xs:complexContent> <xs:extension base="personinfo"> <xs:sequence> <xs:element name="address" type="xs:string"/> <xs:element name="city" type="xs:string"/> <xs:element name="country" type="xs:string"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType>

<xs:element name="studient" type=" fullpersoninfo"/>

Eléments & types

<xs:complexType name="personinfo"> <xs:sequence> <xs:element name="firstname" type="xs:string"/>

<xs:element name="lastname" type="xs:string"/> </xs:sequence>

</xs:complexType>

<xs:complexType name="fullpersoninfo"> <xs:complexContent> <xs:extension base="personinfo"> <xs:sequence> <xs:element name="address" type="xs:string"/> <xs:element name="city" type="xs:string"/> <xs:element name="country" type="xs:string"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType>

<xs:element name="studient" type=" fullpersoninfo"/>

Page 44: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 4411/04/23

Sequence – les "child" dans l'ordre décrit<xs:element name="person">

<xs:complexType> <xs:sequence> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/>

</ xs:sequence> </xs:complexType> </xs:element>

All – tous les "child" exactement 1 fois dans n'importe quel ordre<xs:element name="adresse">

<xs:complexType> <xs:all> <xs:element name="email" type="xs:string"/> <xs:element name="postale" type="xs:string"/>

</xs:all> </xs:complexType> </xs:element> Choice – un seul "child" au choix une fois<xs:element name="tel">

<xs:complexType> <xs:choice> <xs:element name="portable" type="xs:string"/> <xs:element name="fixe" type="xs:string"/>

</ xs:choice> </xs:complexType> </xs:element>

Sequence – les "child" dans l'ordre décrit<xs:element name="person">

<xs:complexType> <xs:sequence> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/>

</ xs:sequence> </xs:complexType> </xs:element>

All – tous les "child" exactement 1 fois dans n'importe quel ordre<xs:element name="adresse">

<xs:complexType> <xs:all> <xs:element name="email" type="xs:string"/> <xs:element name="postale" type="xs:string"/>

</xs:all> </xs:complexType> </xs:element> Choice – un seul "child" au choix une fois<xs:element name="tel">

<xs:complexType> <xs:choice> <xs:element name="portable" type="xs:string"/> <xs:element name="fixe" type="xs:string"/>

</ xs:choice> </xs:complexType> </xs:element>

XSD – Indicateurs

maxOccurs, minOccurs

<xs:element name="child_name"type="xs:string" maxOccurs="unbounded"minOccurs="0"/>

maxOccurs, minOccurs

<xs:element name="child_name"type="xs:string" maxOccurs="unbounded"minOccurs="0"/>

Page 45: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 4511/04/23

XSD – Types Complexes(3) Contenu texte et attributs seulement<xs:element name="shoesize"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:integer"> <xs:attribute name="country" type="xs:string" /> </xs:extension> </xs:simpleContent> </xs:complexType></xs:element>

Contenu mixte: élements et texte<xs:element name="letter"> <xs:complexType mixed="true"> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="orderid"

type="xs:positiveInteger"/> <xs:element name="shipdate" type="xs:date"/> </xs:sequence> </xs:complexType></xs:element>

Contenu texte et attributs seulement<xs:element name="shoesize"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:integer"> <xs:attribute name="country" type="xs:string" /> </xs:extension> </xs:simpleContent> </xs:complexType></xs:element>

Contenu mixte: élements et texte<xs:element name="letter"> <xs:complexType mixed="true"> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="orderid"

type="xs:positiveInteger"/> <xs:element name="shipdate" type="xs:date"/> </xs:sequence> </xs:complexType></xs:element>

<letter>

Dear Mr.<name>John Smith</name> .

Your order <orderid>1032</orderid>

will be shipped on

<shipdate>2011-07-13</shipdate> .

</letter>

<shoesize country="FR">

35

</shoesize>

Page 46: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 4611/04/23

Un exemple complet - shiporder.xml

Sur le tutorial W3C http://www.w3schools.com/schema/schema_example.asp

Sur le tutorial W3C http://www.w3schools.com/schema/schema_example.asp

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

<shiporder orderid="889923"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:noNamespaceSchemaLocation="shiporder.xsd">

<orderperson>John Smith</orderperson>

<shipto>

<name>Ola Nordmann</name>

<address>Langgt 23</address> <city>Stavanger</city> <country>Norway</country>

</shipto>

<item>

<title>Empire Burlesque</title> <note>Special Edition</note>

<quantity>1</quantity> <price>10.90</price>

</item>

<item>

<title>Hide your heart</title> <quantity>1</quantity> <price>9.90</price>

</item> </shiporder>

•xml

Page 47: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 4711/04/23

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

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="shiporder"> <xs:complexType> <xs:sequence>

<xs:element name="orderperson" type="xs:string"/>

<xs:element name="shipto"> <xs:complexType> <xs:sequence>

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

<xs:element name="address" type="xs:string"/>

<xs:element name="city" type="xs:string"/>

<xs:element name="country" type="xs:string"/>

</xs:sequence> </xs:complexType> </xs:element>

<xs:element name="item" maxOccurs="unbounded">

<xs:complexType> <xs:sequence>

<xs:element name="title" type="xs:string"/>

<xs:element name="note" type="xs:string" minOccurs="0"/>

<xs:element name="quantity" type="xs:positiveInteger"/>

<xs:element name="price" type="xs:decimal"/>

</xs:sequence> </xs:complexType> </xs:element>

</xs:sequence> <xs:attribute name="orderid" type="xs:string" use="required"/>

</xs:complexType></xs:element>

</xs:schema>

•xml

un schéma basique

shiporder.xsd (v1)

Page 48: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 4811/04/23

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

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<!-- definition of simple elements --><xs:element name="orderperson" type="xs:string"/><xs:element name="name" type="xs:string"/><xs:element name="address" type="xs:string"/><xs:element name="city" type="xs:string"/><xs:element name="country" type="xs:string"/><xs:element name="title" type="xs:string"/><xs:element name="note" type="xs:string"/><xs:element name="quantity" type="xs:positiveInteger"/><xs:element name="price" type="xs:decimal"/>

<!-- definition of attributes --><xs:attribute name="orderid" type="xs:string"/>

<!-- definition of complex elements --><xs:element name="shipto"><xs:complexType> <xs:sequence> <xs:element ref="name"/> <xs:element ref="address"/> <xs:element ref="city"/> <xs:element ref="country"/> </xs:sequence> </xs:complexType> </xs:element>

<xs:element name="item"> <xs:complexType> <xs:sequence> <xs:element ref="title"/> <xs:element ref="note" minOccurs="0"/> <xs:element ref="quantity"/> <xs:element ref="price"/> </xs:sequence> </xs:complexType></xs:element>

<xs:element name="shiporder"> <xs:complexType> <xs:sequence> <xs:element ref="orderperson"/> <xs:element ref="shipto"/> <xs:element ref="item" maxOccurs="unbounded"/> </xs:sequence> <xs:attribute ref="orderid" use="required"/> </xs:complexType></xs:element></xs:schema>

•xsd

un schéma élaboréshiporder.xsd (v2)

Page 49: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 4911/04/23

XSD - NoteS: extension à plusieurs notes

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

<!--DOCTYPE note SYSTEM "http://www.w3schools.com/dtd/note.dtd" -->

<notes

xmlns = "http://www.essi.fr/~LANGDOC"

xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation ="http://www.essi.fr/~LANGDOC notes.xsd" >

<note>

<to> Vous </to><to> Moi </to><to> Les Autres </to> <from> Moi </from>

<body> N'oubliez pas de rendre vos TPs ! </body>

</note>

<note>

<to> … </to> <from> … </from>

<body> …….! </body>

</note>

</notes>

Page 50: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 5011/04/23

XSD - Notes

Une DTD de notes Une DTD de notes

<!ELEMENT notes (note*)>

<!ELEMENT note ((to+ | from | subject)+, body)>

<!ELEMENT to (#PCDATA)>

<!ELEMENT from (#PCDATA)>

<!ELEMENT subject (#PCDATA)>

<!ELEMENT body (#PCDATA)>

<!ATTLIST note time CDATA "00:00:00">

•dtd

Page 51: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 5111/04/23

XSD - Notes

Un Schéma de notes (p1) Un Schéma de notes (p1)

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

<xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema"

targetNamespace = "http://www.essi.fr/~LANGDOC"

xmlns:not="http://www.essi.fr/~LANGDOC"

elementFormDefault = "qualified">

<xs:element name="body"> <xs:complexType mixed="true" /> </xs:element>

<xs:element name="from"> <xs:complexType mixed="true" /> </xs:element>

<xs:element name="subject"> <xs:complexType mixed="true" /> </xs:element>

<xs:element name="to"> <xs:complexType mixed="true" /> </xs:element>

<xs:element name="notes">

<xs:complexType> <xs:sequence>

<xs:element ref="not:note" minOccurs="0" maxOccurs="unbounded" />

</xs:sequence> </xs:complexType>

</xs:element>

•xsd

Page 52: SommaireLexique Langages & Documents Réfs Paul Franchi SI 4 2013-14 Techs...... 13/01/2014 Transparent - 1 Chap IV DTD "Document Type Definition" Chap

SommaireSommaire

LexiqueLexique

RéfsRéfs

TechsTechsDocument Type

Definition

DTD-Syntaxe

DTD – Validation

XSD - Mon premier Schéma

Entités internes/externes dans XML

Entités Paramêtres dans XML

XSD - Un exemple du W3C

Eléments de Schémas >

Attributs - Exemples

DTDs Standards (W3C)

un schéma élaboré

Transparent 5211/04/23

XSD - Notes Un Schéma de notes (p2) Un Schéma de notes (p2)

<xs:element name="note">

<xs:complexType> <xs:sequence>

<xs:choice minOccurs="1" maxOccurs="3">

<xs:element ref="not:to" maxOccurs="unbounded" />

<xs:element ref="not:from" />

<xs:element ref="not:subject" />

</xs:choice>

<xs:element ref="not:body" />

</xs:sequence>

<xs:attribute name="time" type="xs:string" use="optional" default="00:00:00" />

</xs:complexType>

</xs:element>

<xs:element name="notes"><xs:complexType> <xs:sequence>

<xs:element ref="not:note" minOccurs="0" maxOccurs="unbounded" />

</xs:sequence> </xs:complexType>

</xs:element>

</xs:schema> •xsd