| Attribute ในเอกสาร XSD | ใช้กำหนด attribute โดยจะมีชนิดข้อมูลตามที่กำหนด |
|---|---|
| Use Attribute ในเอกสาร XSD | ใช้กำหนดว่า keyword ได้แก่ required, optional, proibited เพื่อกำหนดความสำคัยของ attribute |
| Default Attribute ในเอกสาร XSD | ใช้กำหนด ค่าข้อมูล ในกรณีที่ไม่มีการกำหนดค่าข้อมูล ให้กับ attribute นี้มา |
| ComplexType ในเอกสาร XSD | ใช้กำหนด ค่าข้อมูล ให้กับ attribute โดยจะมีค่าข้อมูลนี้เสมอ |
subject:Attribute ในเอกสาร XSD
syntax:<xsd:attribute name="attributeName" type="typeData" />
position:<xsd:complexType> ... </xsd:complexType>
content:ใช้กำหนด attribute โดยจะมีชนิดข้อมูลตามที่กำหนด
example:<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:complexType name="football"> <xsd:sequence> <xsd:element name="stadium" type="xsd:NMTOKEN" /> <xsd:element name="manager" type="xsd:NMTOKEN" /> <xsd:element name="footballer" type="xsd:NMTOKEN" /> </xsd:sequence> <xsd:attribute name="logo" type="xsd:NMTOKEN" /> </xsd:complexType> </xsd:schema>
subject:Use Attribute ในเอกสาร XSD
syntax:<xsd:attribute use="value" />
position:<xsd:complexType> ... </xsd:complexType>
content:ใช้กำหนดว่า keyword เพื่อแทนความหมายดังต่อไปนี้ require คือ ต้องมีเสมอ optional คือ มีหรือไม่มีก็ได้ prohibited คือ ไม่ต้องมีเสมอ
example:<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:complexType name="football"> <xsd:sequence> <xsd:element name="stadium" type="xsd:NMTOKEN" /> <xsd:element name="manager" type="xsd:NMTOKEN" /> <xsd:element name="footballer" type="xsd:NMTOKEN" /> </xsd:sequence> <xsd:attribute name="logo" type="xsd:NMTOKEN" use="require" /> </xsd:complexType> </xsd:schema>
subject:Default Attribute ในเอกสาร XSD
syntax:<xsd:attribute default="value" />
position:<xsd:complexType> ... </xsd:complexType>
content:ใช้กำหนด ค่าข้อมูล ในกรณีที่ไม่มีการกำหนดค่าข้อมูล ให้กับ attribute นี้มา
example:<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:complexType name="football"> <xsd:sequence> <xsd:element name="stadium" type="xsd:NMTOKEN" /> <xsd:element name="manager" type="xsd:NMTOKEN" /> <xsd:element name="footballer" type="xsd:NMTOKEN" /> </xsd:sequence> <xsd:attribute name="logo" type="xsd:NMTOKEN" default="bamboo.png" /> </xsd:complexType> </xsd:schema>
subject:ComplexType ในเอกสาร XSD
syntax:<xsd:attribute fixed="value" />
position:<xsd:complexType> ... </xsd:complexType>
content:ใช้กำหนด ค่าข้อมูล ให้กับ attribute โดยจะมีค่าข้อมูลนี้เสมอ
example:<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:complexType name="football"> <xsd:sequence> <xsd:element name="stadium" type="xsd:NMTOKEN" /> <xsd:element name="manager" type="xsd:NMTOKEN" /> <xsd:element name="footballer" type="xsd:NMTOKEN" /> </xsd:sequence> <xsd:attribute name="logo" type="xsd:NMTOKEN" fixed="bamboo.png" /> </xsd:complexType> </xsd:schema>