Sobes.tech
Junior

What data types exist in XSD?

sobes.tech AI

Answer from AI

  • Simple Types
    • Derived from built-in types:
      • xs:boolean
      • xs:byte, xs:short, xs:int, xs:long
      • xs:unsignedByte, xs:unsignedShort, xs:unsignedInt, xs:unsignedLong
      • xs:decimal
      • xs:float, xs:double
      • xs:string
      • xs:date, xs:time, xs:dateTime
      • xs:duration
      • xs:gYearMonth, xs:gYear, xs:gMonthDay, xs:gDay, xs:gMonth
      • xs:anyURI
      • xs:QName
      • xs:NOTATION
      • xs:base64Binary
      • xs:hexBinary
      • xs:language
      • xs:normalizedString, xs:token (derived from xs: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)
  • 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>