XSD bo‘sh elementlar


Bo‘sh murakkab element kontentga ega bo‘la olmaydi, faqat atributlarga ega bo‘ladi.


ULASHISH

Bo‘sh murakkab elementlar

Bo‘sh XML elementi:

<product prodid="1345" />

Yuqoridagi "product" elementida umuman kontent yo‘q. Kontentsiz tipni aniqlash uchun kontentida elementlarga ruxsat beruvchi tipni aniqlashimiz kerak, lekin aslida hech qanday elementni e’lon qilmaymiz, masalan:

<xs:element name="product">   <xs:complexType>     <xs:complexContent>       <xs:restriction base="xs:integer">         <xs:attribute name="prodid" type="xs:positiveInteger"/>       </xs:restriction>     </xs:complexContent>   </xs:complexType> </xs:element>

Yuqoridagi misolda murakkab kontentga ega murakkab tipni aniqlaymiz. complexContent elementi murakkab tipning kontent modelini cheklash yoki kengaytirish niyatimiz borligini bildiradi, integer cheklovi esa bitta atributni e’lon qiladi, lekin hech qanday element kontentini kiritmaydi.

Biroq "product" elementini ixchamroq tarzda quyidagicha e’lon qilish mumkin:

<xs:element name="product">   <xs:complexType>     <xs:attribute name="prodid" type="xs:positiveInteger"/>   </xs:complexType> </xs:element>

Yoki complexType elementiga nom berib, "product" elementiga complexType nomiga ishora qiluvchi type atributini berishingiz mumkin (bu usuldan foydalansangiz, bir nechta element bitta murakkab tipga ishora qilishi mumkin):

<xs:element name="product" type="prodtype"/> <xs:complexType name="prodtype">   <xs:attribute name="prodid" type="xs:positiveInteger"/> </xs:complexType>


W3Schools Pathfinder

Yutuqlaringizni kuzating – bu bepul!