XSD SchemaLesson 91Free preview
XSD Text-only
This lesson is part of XML · All levels
Summary
Text-based elements that still require attributes should use <xs:simpleContent> within <xs:complexType>. Since simpleContent must not contain elements, it can only be <xs:extension> or <xs:restriction> that lower the text type such as xs:string or xs:decimal. This pattern is suitable for unit-type values, such as prices accompanied by currency attributes.
Key points
- SimpleContent can only contain an extension or restriction
- Extension base="xs:decimal" uses the text type and then adds the attribute
- There should be no child element in simpleContent
- Restriction is used to limit the value of a text, for example by enumeration
- Attributes declared in such an extension or restriction
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.