XSD SchemaLesson 89Free preview
XSD Empty
This lesson is part of XML · All levels
Summary
Empty elements are elements that must have no content or children, so they can only be attributed if they are declared. Syntactically, an empty element is denoted by <xs:complexType/> that contains nothing. If you want an element that has no content but still has attributes, use complexType that only contains attribute declarations.
Key points
- Self-closing produces an element without content
- In data documents, empty elements are written <tag/> or <tag></tag>
- ComplexType that contains only <xs:attribute> produces empty elements with attributes
- Attributes use="required" can be added to make the attribute mandatory
- The number of elements present is fixed by minOccurs
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.