Sie sind auf Seite 1von 18

XML

Structuredun d undocumentxml DTD LeschmaXSD

Structured dun undocumentXML


Un U d documentXMLcontient i les l l lmentssuivants: i
Leprologue
<?xml version="1.0" version "1 0"encoding="ISO encoding "ISO88591"?>

Unarbrecontenantleslmentsdudocumentquiforment lesnudsdelarbre Descommentaires


<! commentaire>

Leslments:unlmentxml esttoutcequiest contenuentreunebaliseouvranteetunebalise f fermante. t


Unlmentpeutcontenirdautreslmentsetdutexte.

DocumentXMLbienform
Tout T tlment l tdoit d itavoir i unebalise b li fermante f t Lesbalisessontsensibleslacasse. LeslmentsXMLdoiventtrecorrectementimbriques Undocumentxml doitavoirunlmentracine Lesvaleursdesattributsxml doiventtreentreguillemets""ou

Lesentits:5entitsprdfiniesenxml:
Uniquementlescaractres<et&sontstrictementinterditsdansun d document txml l
&lt; &gt; &amp; & &apos; &quot; < > & ' "

Remarques
Enxml l les l espacessontprservs Dansundocumentxml lecaractreLFreprsente unsautdeligne. Rgles g denommage g deslments:
Lenomdunlmentpeutcontenirdeslettres,des chiffresetdautrescaractres. Lenomnedoitpascommencerparunchiffreouun caractredeponctuation Unnomnedoitpascommencerparxml. Unnomnedoitpascontenirdespace.

DTD
Undocumentxml valideestundocument parrapport pp uneDTD bienformetvalidep (DocumentTypeDefinition) UnedclarationDTDpeuttreinterneou externeundocumentXML. Dclarationinterne:

Dclarationinterne
<?xml version="1.0"?> version "1 0"?> <!DOCTYPE note [ <!ELEMENT note (A,DE,Titre,Corps)> <!ELEMENT A (#PCDATA)> ( ) <!ELEMENT DE (#PCDATA)> <!ELEMENT Titre (#PCDATA)> <!ELEMENT Corps(#PCDATA)> ]> <note> <A>Timah</A> <DE>Hatim</DE> <Titre>Rappel</Titre> <Corps>Votrecommandeatexpdie</Corps> </note>

Dclarationexterne
D Dansl led document txml, l ajouter j t la l dclaration d l ti suivante:
<!DOCTYPEelt_racine elt racine SYSTEM"definition definition.dtd dtd"> > Exemple:<!DOCTYPE note SYSTEM" note.dtd">

Crerlefichiernote.dtd note dtdsuivant:


<!ELEMENT note (A,DE,Titre,Corps)> <!ELEMENT A (#PCDATA)> <!ELEMENT DE (#PCDATA)> <!ELEMENT Titre (#PCDATA)> ( ) <!ELEMENT Corps(#PCDATA)>

Blocsd dun undocumentxml


Elments Attributs Entits PCDATA:parsedcharacterdata. CDATA:lesdonnesdetypeCDATAneseront pasanalysesparunanalyseur.

Dclarationd dun unlment


<!ELEMENTelement type>
Exemple:<!ELEMENTnote#PCDATA> Valeurspossiblespourcatgorie
EMPTY:lmentvide (#PCDATA) ANY,exmple:<!ELEMENTnoteANY> <!ELEMENTnote(A,DE,Titre,Corps)>:leslmentsfils doiventapparatredanslemmeordre. Multiplicit: l l +,* *,? ? |exemple<!ELEMENTnomelement (header|message)>

DclarationdesattributsdansunDTD
Pourchaque attribut
<!ATTLISTelementnom_attribut type yp valeur_default> Exemple:<!ATTLISTpaymenttypeCDATA"carte"> carte >

Typesd dattributs attributs


CDATA:caractres CDATA t (en1|en2|..):liste devaleurs ID:idunique IDREF:iddunautre lment IDREFS:une liste dids dautres lments NMTOKEN:unnomxmlvalide NMTOKENS:unnomxmlvalide ENTITY:une entit ENTITIES:une liste dentits NOTATION notation NOTATION: t ti Xml::une valeur xmlprdfinie

Valeurspardfaut
Value:une valeur #REQUIRED #IMPLIED:lattribut nest pasobligatoire #FIXEDval:lavaleur val delattribut est fixe Exemple: <!ATTLISTpaiement type (chque|numraire|carte)"carte">

Lesentits
<!ENTITYmatiere "Technologiesxml."> Utilisation<cours>&matiere;</cours> Dclarationexterneduneentit
<!ENTITYnom_entit SYSTEM"URI/URL">

Lesfeuillesdestylecss
Lierunefeuilledestyleundocumentxml
<?xmlstylesheet y type="text/css" yp / href=" style.css"?>

Exemple:

ExempledeDTD
<!ELEMENT clients li t (client*)> ( li t*)> <!ELEMENT client (nom,prenom,commandes?)> <!ELEMENT nom (#PCDATA)> <!ELEMENT prenom (#PCDATA)> <!ELEMENT commandes (commande+)> <!ELEMENT commande (date,article+)> (date article+)> <!ELEMENT date (#PCDATA)> <!ELEMENT article (ref,designation,prix,quantite)> <!ELEMENT ref (#PCDATA)> <!ELEMENT designation (#PCDATA)> <!ELEMENT prix (#PCDATA)> <!ELEMENT quantite (#PCDATA)> <!ATTLIST commande ref CDATA#REQUIRED>

Documentclients clients.xml xml


<?xml version= version="1 1.0 0"encoding= encoding="utf utf8 8"?> <!DOCTYPE clients SYSTEM"clients.dtd"> <clients> <client> <nom> Hatim </nom> <prenom> TimaH </prenom> <commandes> <commande ref="1"> <date> 10/10/10 </date> <article> <ref> 10 </ref> <designation> Caf </designation> <prix> 150 </prix> <quantite> 15 </quantite> / </article> <article> <ref> 1010 </ref> <designation> Th </designation> <prix> 100 </prix> <quantite> 10 /q </quantite> </article> </commande> </commandes> </client> </clients>

Style css Style.css


CATALOG{background b k dcolor: l #ffffff; #ffffff width:100%;} CD{display:block; marginbottom:30pt; marginleft:0;} TITLE{color:#FF0000; fontsize:20pt;} ARTIST{color:#0000FF; fontsize:20pt;} COUNTRY,PRICE,YEAR,COMPANY{display:block; color:#000000; marginleft:20pt;}

styles
Pseudo d slecteurs l before b f etafter f DATE{display:block;fontsize:32pt;fontweight:bold; t talign: text li center} t } DATE:before (ouafter){content:"Date:"} Css estunlangagedestylelimit
Deslmentspeuventtrecachspardisplay:none Unstyledfinipourunlments sapplique appliqueaussiaux nudsfilsdecetlment Deslmentsdetextepeuventtreajoutsavantouaprs unlmentsenutilisant:before, before after etcontent. content

display:block,none,listitem,table

Das könnte Ihnen auch gefallen