Simple Types

A simple type is a structure that represents a simple value only.

Simple types are data structures like strings, numbers, and booleans. They can also be customized with facets so that only a certain range of numbers, or a certain set of codes, for example, are allowed.

Simple types can be used in two ways in the model:

  • Core defines attribute personNameInitialIndicator. Its type is a boolean - a simple type.
  • Core defines simple type AddressCategoryCodeSimpleType, which constrains a string down to a few possible codes, like residential and business.

Provided types

Common simple types provided by XML include xs:string, xs:token, xs:date, xs:date-time, xs:integer, xs:decimal, and xs:boolean.

Simple types provided by JSON are string, integer, decimal, and boolean. Dates are simply strings in JSON, but if they follow the format set by ISO 8601, they can be converted into dates in JavaScript.

Kinds of simple types

In addition to the simple types built into XML and JSON and user-defined simple types with facets (typically codes), NIEM supports two additional kinds of simple types:

  • List Types

    A list type is a simple type that allows for values to be repeated, separated by a space.

  • Union Types

    A union type is a simple type that represents the combined set of allowable values from other simple types.

Modeling guidance

Representation term “SimpleType”

A simple type name must end with the representation term “SimpleType”.

XML

Instance example

The following is an example of attribute nc:personNameInitialIndicator. It has simple type xs:boolean.

<nc:PersonMiddleName nc:personNameInitialIndicator="true">Q</nc:PersonMiddleName>

The attribute has a simple value: the boolean “true”.

Schema example

This example shows a subset of nc:AddressCategoryCodeSimpleType.

<xs:simpleType name="AddressCategoryCodeSimpleType">
  <xs:annotation>
    <xs:documentation>A data type for a kind of address.</xs:documentation>
  </xs:annotation>
  <xs:restriction base="xs:token">
    <xs:enumeration value="business">
      <xs:annotation>
        <xs:documentation>business</xs:documentation>
      </xs:annotation>
    </xs:enumeration>
    <xs:enumeration value="residential">
      <xs:annotation>
        <xs:documentation>residential</xs:documentation>
      </xs:annotation>
    </xs:enumeration>
  </xs:restriction>
</xs:simpleType>

Schema template

This template shows the creation of a simple type with an enumeration. Other kinds of facets could be used instead.

<xs:simpleType name="NAMESimpleType">
  <xs:annotation>
    <xs:documentation>A data type for ...</xs:documentation>
  </xs:annotation>
  <xs:restriction base="SIMPLETYPE">
    <xs:enumeration value="CODE">
      <xs:annotation>
        <xs:documentation>CODE_DEFINITION</xs:documentation>
      </xs:annotation>
    </xs:enumeration>
  </xs:restriction>
</xs:simpleType>

JSON

Instance example

The following shows an example of a property with a value based on a simple type:

{
  "nc:AddressCategoryCode": "residential"
}

Schema example

{
  "nc:AddressCategoryCodeSimpleType": {
    "type": "string",
    "description": "A data type for a kind of address.",
    "oneOf": [
      {
        "enum": [ "business" ],
        "description": "business"
      },
      {
        "enum": [ "residential" ],
        "description": "residential"
      }
    ]
  }
}

See Facets (JSON) for examples of simple types with other kinds of facets.

Schema templates

The following is a template for a simple type with an enumeration:

{
  "NAME": {
    "type": "BASE_TYPE",
    "description": "A data type for ...",
    "oneOf": [
      {
        "enum": [ "CODE" ],
        "description": "DEFINITION"
      }
    ]
  }
}

The following is another template for a simple type with an enumeration:

{
  "definitions": {
    "SIMPLE_TYPE": {
      "description": "TYPE_DEFINITION",
      "type": "BASE_TYPE",
      "FACET_KIND": "FACET_VALUE"
    },
  }
}

NDR references

NDR 5.0
Rule Applicability Title
NDR 9-10 REF, EXT Simple type definition is top-level
NDR 9-11 REF No simple type disallowed derivation
NDR 9-12 REF, EXT Simple type has data definition
NDR 11-4 REF, EXT Name of simple type ends in SimpleType
NDR 11-8 REF, EXT Name of a code simple type ends in CodeSimpleType
NDR 11-9 REF, EXT Code simple type corresponds to a code list
NDR 11-47 REF, EXT Standard opening phrase for simple type data definition
NDR 4.0
Rule Applicability Title
NDR 9-10 REF, EXT Simple type definition is top-level
NDR 9-11 REF No simple type disallowed derivation
NDR 9-12 REF, EXT Simple type has data definition
NDR 11-3 REF, EXT Name of simple type ends in SimpleType
NDR 11-7 REF, EXT Name of a code simple type ends in CodeSimpleType
NDR 11-8 REF, EXT Code simple type corresponds to a code list
NDR 11-45 REF, EXT Standard opening phrase for simple type data definition