Vous êtes sur la page 1sur 3

XML schema

o Defning Simple Type Element


Data <FirstName> Don </FirstName>
Schema <xs:element name = FirstName type =
xs:string/>
o Defning ttri!"te
Data title = #ntro$"ction
Schema <xs:attri!"te name = title type = xs:string/>
o Defning %omplex Type Element && %omplex content mo$el
Data:
<"thor>
<FirstName> Don </FirstName>
<'astName> %ham!erlin </'astName>
</"thor>
Schema
<xs:element name = FirstName type = xs:string/>
<xs:element name = 'astName type = xs:string/>
<xs:element name = "thor>
<xs:complexType>
<xs:se("ence>
<xs:element re) = FirstName/>
<xs:element re) = 'astName/>
</xs:se("ence>
</xs:complexType>
</xs:element>
o Defning %omplex Type Element && Simple %ontent Type *ith
ttri!"te
Data
<+aragraph lang"age = English >
,-' has !ecome the most pop"lar $ata mo$el..
</+aragraph>
Schema
<xs:attri!"te name = lang"age type = xs:string/>
<xs:element name = +aragraph>
<xs:complexType>
<xs:simple%ontent>
<xs:extension !ase = xs:string>
<xs:attri!"te re) = lang"age/>
</xs:extension>
</xs:simple%ontent>
</xs:complexType>
</xs:element>
o Defning %omplex Type Element && %omplex %ontent Type *ith
ttri!"te
Data
<%hapter lang"age = English >
<+aragraph> ..</+aragraph>
<+aragraph> ..</+aragraph>
</%hapter>
Schema
<xs:attri!"te name = lang"age type = xs:string/>
<xs:element name = paragraph type = xs:string/>
<xs:element name = %hapter>
<xs:complexType>
<xs:se("ence>
<xs:element re) = +aragraph/>
</xs:se("ence>
<xs:attri!"te re) = lang"age/>
</xs:complexType>
</xs:element>
Example XML Schema
</xml 0ersion=12341 enco$ing=1#S5&6678&21 />
<xs:schema xmlns:xs=1http://***3*93org/:442/,-'Schema1>
<xs:element name=1shipor$er1>
<xs:complexType>
<xs:se("ence>
<xs:element name=1or$erperson1 type=1xs:string1/>
<xs:element name=1shipto1>
<xs:complexType>
<xs:se("ence>
<xs:element name=1name1 type=1xs:string1/>
<xs:element name=1a$$ress1 type=1xs:string1/>
<xs:element name=1city1 type=1xs:string1/>
<xs:element name=1co"ntry1 type=1xs:string1/>
</xs:se("ence>
</xs:complexType>
</xs:element>
<xs:element name=1item1 max5cc"rs=1"n!o"n$e$1>
<xs:complexType>
<xs:se("ence>
<xs:element name=1title1 type=1xs:string1/>
<xs:element name=1note1 type=1xs:string1 min5cc"rs=141/>
<xs:element name=1("antity1 type=1xs:positi0e#nteger1/>
<xs:element name=1price1 type=1xs:$ecimal1/>
</xs:se("ence>
</xs:complexType>
</xs:element>
</xs:se("ence>
<xs:attri!"te name=1or$eri$1 type=1xs:string1 "se=1re("ire$1/>
</xs:complexType>
</xs:element>
</xs:schema>
Example DTD
<;D5%T<+E T=S%>ED?'E @
<;E'E-ENT T=S%>ED?'E A%>NNE'BC>
<;E'E-ENT %>NNE' ADNNEEFD<BC>
<;E'E-ENT DNNEE AG+%DTC>
<;E'E-ENT D< ADTEFA>5'#D<H+E5IE-S'5TBCBC>
<;E'E-ENT >5'#D< AG+%DTC>
<;E'E-ENT DTE AG+%DTC>
<;E'E-ENT +E5IE-S'5T AT#-EFT#T'EFDES%E#+T#5N/C>
<;E'E-ENT T#-E AG+%DTC>
<;E'E-ENT T#T'E AG+%DTC>
<;E'E-ENT DES%E#+T#5N AG+%DTC>
<;TT'#ST T=S%>ED?'E N-E %DT GEEJ?#EED>
<;TT'#ST %>NNE' %>N %DT GEEJ?#EED>
<;TT'#ST +E5IE-S'5T =TE %DT G#-+'#ED>
<;TT'#ST T#T'E ET#NI %DT G#-+'#ED>
<;TT'#ST T#T'E 'NI?IE %DT G#-+'#ED>
K>