XSD 元素
<any> အအုပ်အချုပ်သည် အယူအဆဖြစ်သော အအုပ်အချုပ်များ ကို အသုံးပြု၍ XML ကောင်းမှုကို ဖွဲ့စည်းနိုင်သော အရည်အချင်းကို ဖွဲ့စည်းနိုင်သည်။
<any> အအုပ်အချုပ်
<any> အအုပ်အချုပ်သည် အယူအဆဖြစ်သော အအုပ်အချုပ်များ ကို အသုံးပြု၍ XML ကောင်းမှုကို ဖွဲ့စည်းနိုင်သော အရည်အချင်းကို ဖွဲ့စည်းနိုင်သည်။
ဤအကြောင်းအရာ "family.xsd" အယူအဆဖြစ်သော XML schema မှ တစ်ခုတည်းသော အချို့သော အချက်အလက်များ ဖြစ်သည်။ ဤအချက်အလက်များ "person" အအုပ်အချုပ် အား ပြောင်းလဲခြင်း ပြုသည်။ <any> အအုပ်အချုပ်ကို အသုံးပြု၍ "person" အအုပ်အချုပ်၏ အရေးအသားကို အပိုက်အပိုက် ဖြင့် ဖွဲ့စည်းနိုင်ပါသည်။
<xs:element name="person"> <xs:complexType> <xs:sequence> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> <xs:any minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element>
ဤအခါ "children" အအုပ်အဖွဲ့ အသုံးပြုရန် ကျွန်တော်တို့သည် "person" အအုပ်အဖွဲ့ ကို ဖွဲ့စည်းရန် ကြံစည်နေကြသည်။ ဤအခါ "children" အအုပ်အဖွဲ့ ကို အသုံးပြုရန် မည်သည့် အခြေခံ schema မှ မဆို အသုံးပြုနိုင်ပါသည်。
အောက်ပါ schema ဖိုင်(အမည် "children.xsd" ဖြစ်သည်)ကို ကြည့်ပါ:
<?xml version="1.0" encoding="ISO-8859-1"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.codew3c.com" xmlns="http://www.codew3c.com" elementFormDefault="qualified"> <xs:element name="children"> <xs:complexType> <xs:sequence> <xs:element name="childname" type="xs:string" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
အောက်ပါ XML ဖိုင်(အမည် "Myfamily.xml" ဖြစ်သည်)သည် နှစ်ခုစလုံး စည်းကမ်းများ "family.xsd" နှင့် "children.xsd" မှ အရေးကြီးသော အရာများ အသုံးပြုသည်:
<?xml version="1.0" encoding="ISO-8859-1"?> <persons xmlns="http://www.microsoft.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:SchemaLocation="http://www.microsoft.com family.xsd http://www.codew3c.com children.xsd"><firstname>David</firstname> Smith <children> <childname>mike</childname>Tony Smith
上面这个 XML 文件是有效的,这是由于 schema "family.xsd" 允许我们通过在 "lastname" 元素后的可选元素来扩展 "person" 元素。