XML Schema ရည်ညွှန်းချက် Element
❮ XML Schema ကိုးကားချက် အပြည့်အစုံ
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
attribute element သည် attribute ကိုသတ်မှတ်သည်။
ဒြပ်စင်အချက်အလက်
- ပင်မ ဒြပ်စင်များ- attributeGroup၊ schema၊ complexType၊ ကန့်သတ်ချက် (ရိုးရှင်းသောအကြောင်းအရာနှင့် ရှုပ်ထွေးသောအကြောင်းအရာနှစ်ခုလုံး)၊ extension (ရိုးရှင်းသောအကြောင်းအရာနှင့် ရှုပ်ထွေးသောအကြောင်းအရာနှစ်ခုလုံး)
အထားအသို
<attribute
default=string
fixed=string
form=qualified|unqualified
id=ID
name=NCName
ref=QName
type=QName
use=optional|prohibited|required
any attributes
>
(annotation?,(simpleType?))
</attribute>
(အမှတ်အသား ? အမှတ်အသားသည် ဒြပ်စင်အား ရည်ညွှန်းချက်ဒြပ်စင်အတွင်း သုည သို့မဟုတ် တစ်ကြိမ် ဖြစ်ပေါ်နိုင်ကြောင်း ကြေငြာသည်)
Attribute | Description |
---|---|
default | Optional. Specifies a default value for the attribute. Default and fixed attributes cannot both be present |
fixed | Optional. Specifies a fixed value for the attribute. Default and fixed attributes cannot both be present |
form | Optional. Specifies the form for the attribute. The default value is
the value of the attributeFormDefault attribute of the element
containing the attribute. Can be set to one of the following:
|
id | Optional. Specifies a unique ID for the element |
name | Optional. Specifies the name of the attribute. Name and ref attributes cannot both be present |
ref | Optional. Specifies a reference to a named attribute. Name and ref attributes cannot both be present. If ref is present, simpleType element, form, and type cannot be present |
type | Optional. Specifies a built-in data type or a simple type. The type attribute can only be present when the content does not contain a simpleType element |
use | Optional. Specifies how the attribute is used. Can be one
of the following values:
|
any attributes | Optional. Specifies any other attributes with non-schema namespace |
ဥပမာ ၁
<xs:attribute name="code">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[A-Z][A-Z]"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
အထက်ဖော်ပြပါ ဥပမာသည် "ကုဒ်" ရည်ညွှန်းချက်တွင် ကန့်သတ်ချက်တစ်ခုရှိကြောင်း ဖော်ပြသည်။ လက်ခံနိုင်သော တစ်ခုတည်းသောတန်ဖိုးမှာ a မှ z မှ စာလုံးကြီးနှစ်လုံးဖြစ်သည်။
ဥပမာ ၂
ရှုပ်ထွေးသောအမျိုးအစားတစ်ခုအတွင်း ရှိပြီးသား attribute အဓိပ္ပါယ်ဖွင့်ဆိုချက်ကို အသုံးပြု၍ attribute တစ်ခုကြေငြာရန်၊ ref attribute ကိုသုံးပါ-
<xs:attribute name="code">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[A-Z][A-Z]"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:complexType name="someComplexType">
<xs:attribute ref="code"/>
</xs:complexType>
ဥပမာ ၃
ရည်ညွှန်းချက်များတွင် ပုံသေတန်ဖိုး သို့မဟုတ် ပုံသေသတ်မှတ်ထားသောတန်ဖိုးတစ်ခုရှိနိုင်သည်။ အခြားတန်ဖိုးကို မသတ်မှတ်ထားသောအခါတွင် မူရင်းတန်ဖိုးကို attribute တွင် အလိုအလျောက်သတ်မှတ်ပေးပါသည်။ အောက်ပါဥပမာတွင် မူရင်းတန်ဖိုးမှာ "EN" ဖြစ်သည်-
<xs:attribute name="lang" type="xs:string" default="EN"/>
အခြားတန်ဖိုးကို မသတ်မှတ်ထားသည့်အခါ ပုံသေတန်ဖိုးကိုလည်း attribute တွင် အလိုအလျောက်သတ်မှတ်ပေးပါသည်။ မူရင်းတန်ဖိုးများနှင့် မတူဘဲ၊ ပုံသေထက် အခြားတန်ဖိုးကို သင်သတ်မှတ်ပါက၊ စာရွက်စာတမ်းသည် မမှန်ကန်ဟု ယူဆပါသည်။ အောက်ပါဥပမာတွင် ပုံသေတန်ဖိုးသည် "EN" ဖြစ်သည်-
<xs:attribute name="lang" type="xs:string" fixed="EN"/>
ဥပမာ ၄
ရည်ညွှန်းချက်အားလုံးသည် ပုံမှန်အားဖြင့် ရွေးချယ်နိုင်သည် ရည်ညွှန်းချက်သည် ရွေးချယ်နိုင်သည်ဟု ပြတ်သားစွာ သတ်မှတ်ရန်၊ "အသုံးပြုရန်" အရည်အချင်းကို အသုံးပြုပါ-
<xs:attribute name="lang" type="xs:string" use="optional"/>
ရည်ညွှန်းချက်တစ်ခုပြုလုပ်ရန် လိုအပ်သည်-
<xs:attribute name="lang" type="xs:string" use="required"/>
❮ XML Schema ကိုးကားချက် အပြည့်အစုံ