XSD SchemaLesson 86Free preview
XSD Attributes
This lesson is part of XML · All levels
Summary
<xs:attribute> is used to declare the attribute of an element with the same data type as a simple element. The attribute is stated in <xs:complexType> and is inherently optional, so use use="required" if it is required. Just like elements, attributes also support default and fixed values.
Key points
- Attributes declared in <xs:complexType> belong to related elements
- Use="required" makes the attribute mandatory, use="prohibited" prohibits it
- Without the use attribute, the value is optional.
- Attributes can only appear once so there is no maxOccurs.
- Default and fixed also apply to attributes
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.