Junior
What data types exist in XSD?
sobes.tech AI
Answer from AI
- Simple Types
- Derived from built-in types:
xs:booleanxs:byte,xs:short,xs:int,xs:longxs:unsignedByte,xs:unsignedShort,xs:unsignedInt,xs:unsignedLongxs:decimalxs:float,xs:doublexs:stringxs:date,xs:time,xs:dateTimexs:durationxs:gYearMonth,xs:gYear,xs:gMonthDay,xs:gDay,xs:gMonthxs:anyURIxs:QNamexs:NOTATIONxs:base64Binaryxs:hexBinaryxs:languagexs:normalizedString,xs:token(derived fromxs:string)xs:ID,xs:IDREF,xs:IDREFS,xs:ENTITY,xs:ENTITIES,xs:NMTOKEN,xs:NMTOKENS(for XML-specific types)
- Restricted types (restriction)
- List types (list)
- Union types (union)
- Derived from built-in types:
- Complex Types
- Contain elements and attributes
- Can have content models:
empty(attributes only)element-only(elements only)mixed(elements and text content)simpleContent(attributes and simple text content)
- Can use:
xs:sequence(sequence of elements)xs:choice(one of the provided elements)xs:all(all listed elements in any order, each at most once)
Example of defining a simple restricted type:
<!-- Definition of a new type PositiveInteger, which is a positive whole number -->
<xs:simpleType name="PositiveInteger">
<xs:restriction base="xs:int">
<xs:minInclusive value="1"/>
</xs:restriction>
</xs:simpleType>
Example of defining a complex type:
<!-- Definition of a complex type Person containing elements name and age -->
<xs:complexType name="Person">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="age" type="xs:int"/>
</xs:sequence>
</xs:complexType>