In NIEM, multiple representations of a concept are typically handled via abstract elements and substitution groups. This allows for replacement of the abstract element in an instance with one or more of the substitutions.
Abstract element nc:PersonHairColorAbstract has multiple substitutions, allowing for free-text or code value representations.
In cases where the concept not only has multiple representations but also additional properties describing the concept, a new type is needed to bundle the representations and additional properties together. This is the representation pattern.
The major difference between the two examples is that there are other date-related properties in addition to the multiple date representations; hair color has multiple representations only.
The table below shows an example outlining the difference between regular abstract elements + substitutions versus the representation pattern.
Pattern | Abstract Element + Substitutions | Representation Pattern |
---|---|---|
Type | n/a | nc:DateType |
--Multiple representations |
nc:PersonHairColorAbstract
|
nc:DateRepresentation
|
--Additional Content | n/a |
|
Just because an abstract element is contained in a type does not mean it follows the representation pattern. Element nc:PersonHairColorAbstract is used in type nc:PersonType, but hair color is simply a property of a person, not a full representation of a person.
Country codes are one example of the representation pattern in NIEM.
Two of the authoritative sources for country codes in the NIEM 4.0 release are GENC (Geopolitical Names, Entities, and Codes) and ISO 3166-1. Both of these standards have 2-character, 3-character, and numeric representations. In addition to these, NIEM also includes a text representation.
In NIEM 4.0, country codes were refactored in order to use the representation pattern. This provided multiple benefits:
See Country Code Representations for information about the different representation formats used with country codes, including CSV files for GENC codes.
Because NIEM (1) has multiple representations for country codes and (2) country codes are used in many different contexts throughout the model, they were a good candidate for the representation pattern.
In NIEM 3.2, before the representation pattern was used, a new country code element was created for each usage of a code set. These elements include:
NIEM 3.2 Element | Type |
---|---|
nc:DocumentCountryISO3166Alpha2Code | iso_3166:CountryAlpha2CodeType |
nc:LocationCountryISO3166Alpha2Code | iso_3166:CountryAlpha2CodeType |
nc:LocationCountryGENCCode | genc:CountryAlpha3CodeType |
nc:MilitaryCountryGENCCode | genc:CountryAlpha3CodeType |
nc:PersonCitizenshipISO3166Alpha2Code | iso_3166:CountryAlpha2CodeType |
nc:PersonNationalityISO3166Alpha2Code | iso_3166:CountryAlpha2CodeType |
biom:ForensicSourceCountryISO3166Alpha2Code | iso_3166:CountryAlpha2CodeType |
biom:RecordingSourceCountryISO3166Alpha2Code | iso_3166:CountryAlpha2CodeType |
mo:FacilityAllegianceCountryCode | genc:CountryAlpha3CodeType |
In order to simplify and enable reuse, the representation pattern was used in NIEM 4.0 and type nc:CountryType
was created. This type contains abstract element nc:CountryRepresentation
, which allows for substitution by GENC and ISO 3166 code elements, as well as other NIEM and local elements.
Using the representation pattern, NIEM 4.0 country code elements include:
NIEM 4.0 Element | Type |
---|---|
nc:DocumentCountry | nc:CountryType |
nc:LocationCountry | nc:CountryType |
nc:MilitaryCountry | nc:CountryType |
biom:ForensicSourceCountry | nc:CountryType |
biom:RecordingSourceCountry | nc:CountryType |
mo:FacilityAllegianceCountry | nc:CountryType |
This approach adds greater consistency with less duplication. Any element of type nc:CountryType
may use one or more of the different country code representations. And each semantic concept only has to be defined once.
In NIEM 4.0, the addition of nc:CountryType
made it possible to reuse multiple representations, rather than requiring a new element to be created for each usage.
Release | Location Country Elements | Types |
---|---|---|
|
|
|
|
|
|
The following diagram shows type nc:CountryType
, which carries representations of a country across NIEM exchanges.
nc:CountryType
is used by nc:LocationType
and nc:DocumentType
nc:CountryType
has an element nc:CountryRepresentation
,
which may be replaced in an instance by a number of ways to identify a country.The example below shows the declaration of type nc:CountryType
and one element that uses this type:
<xs:complexType name="CountryType">
<xs:annotation>
<xs:documentation>A data type for a country, territory, dependency, or other such geopolitical subdivision of a location.</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="structures:ObjectType">
<xs:sequence>
<xs:element ref="nc:CountryRepresentation" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="nc:CountryAugmentationPoint" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="LocationCountry" type="nc:CountryType" nillable="true">
<xs:annotation>
<xs:documentation>A country, territory, dependency, or other such geopolitical subdivision of a location.</xs:documentation>
</xs:annotation>
</xs:element>
The following shows three different examples of element nc:LocationCountry
, each using a different representation provided by nc:CountryType
:
<nc:LocationCountry>
<nc:LocationCountryISO3166Alpha2Code>US</nc:LocationCountryISO3166Alpha2Code>
</nc:LocationCountry>
<nc:LocationCountry>
<nc:CountryCode>USA</nc:CountryCode>
</nc:LocationCountry>
<nc:LocationCountry>
<nc:LocationCountryName>United States</nc:LocationCountryName>
</nc:LocationCountry>
In addition to the GENC and ISO 3166 representations, other representations may be used with NIEM 4, either by additional substitutions for nc:CountryRepresentation
, or by providing additional code list URIs with nc:CodeType
(see Code Lists for more).
An IEPD (information exchange package definition), which specifies a message, may include one or more of these representations to convey countries. Which representations are used is determined by the community of interest developing the message specification.
A representation pattern is modeled by a type that contains an abstract representation element and one or more additional properties.
The representation element must be abstract. This allows for substitution by the alternate representations.
The name of the representation element must end with “Representation”.
The example below shows an element with type nc:DateType.
<nc:ActivityDate>
<nc:Date>2017-06-01</nc:Date>
<nc:DateMarginOfErrorDuration>P3M</nc:DateMarginOfErrorDuration>
</nc:ActivityDate>
The example below shows..
<xs:complexType name="DateType">
<xs:annotation>
<xs:documentation>A data type for a calendar date.</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="structures:ObjectType">
<xs:sequence>
<xs:element ref="nc:DateRepresentation" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="nc:DateAccuracyAbstract" minOccurs="0" maxOccurs="1"/>
<xs:element ref="nc:DateMarginOfErrorDuration" minOccurs="0" maxOccurs="1"/>
<xs:element ref="nc:DateAugmentationPoint" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="DateRepresentation" abstract="true">
<xs:annotation>
<xs:documentation>A data concept for a representation of a date.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Date" type="niem-xs:date" substitutionGroup="nc:DateRepresentation" nillable="true">
<xs:annotation>
<xs:documentation>A full date.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="DateTime" type="niem-xs:dateTime" substitutionGroup="nc:DateRepresentation">
<xs:annotation>
<xs:documentation>A full date and time.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:complexType name="NAMEType">
<xs:annotation>
<xs:documentation>A data type for ...</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="structures:ObjectType">
<xs:sequence>
<xs:element ref="nc:NAMERepresentation" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="..." minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="nc:NAMEAugmentationPoint" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="NAMERepresentation" abstract="true">
<xs:annotation>
<xs:documentation>A data concept for a representation of a ...</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="REPRESENTATION-1" type="TYPE" substitutionGroup="nc:NAMERepresentation" nillable="true">
<xs:annotation>
<xs:documentation>DEFINITION</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="REPRESENTATION-2" type="TYPE" substitutionGroup="nc:NAMERepresentation" nillable="true">
<xs:annotation>
<xs:documentation>DEFINITION</xs:documentation>
</xs:annotation>
</xs:element>
The example below shows an element with type nc:DateType.
{
"nc:ActivityDate": {
"nc:Date": "2017-06-01",
"nc:DateMarginOfErrorDuration": "P3M"
}
}
The example below shows..
Because JSON Schema does not support substitution groups, representation properties should be added directly to the type. In XML Schema, the representations would be created as substitutable for an abstract element instead.
{
"$schema": "http://json-schema.org/draft-04/schema#",
"additionalProperties": false,
"properties": {
"nc:Date": {
"description": "A full date.",
"oneOf": [
{
"$ref": "#/definitions/niem-xs:date"
},
{
"type": "array",
"items": {
"$ref": "#/definitions/niem-xs:date"
}
}
]
},
"nc:DateTime": {
"description": "A full date and time.",
"oneOf": [
{
"$ref": "#/definitions/niem-xs:dateTime"
},
{
"type": "array",
"items": {
"$ref": "#/definitions/niem-xs:dateTime"
}
}
]
}
}
"definitions": {
"nc:DateType": {
"description": "A data type for a calendar date.",
"allOf": [
{
"$ref": "#/definitions/_base"
},
{
"type": "object",
"properties": {
"nc:Date": {
"$ref": "#/properties/nc:Date"
},
"nc:DateTime": {
"$ref": "#/properties/nc:DateTime"
},
"nc:ZuluDateTime": {
"$ref": "#/properties/nc:ZuluDateTime"
},
"nc:DateMarginOfErrorDuration": {
"$ref": "#/properties/nc:DateMarginOfErrorDuration"
}
}
}
]
}
}
}
The template belows shows the declaration of a type following the representation pattern, plus two representation properties.
{
"$schema": "http://json-schema.org/draft-04/schema#",
"additionalProperties": false,
"properties": {
"REPRESENTATION-1": {
"description": "DEFINITION",
"oneOf": [
{
"$ref": "#/definitions/TYPE"
},
{
"type": "array",
"items": {
"$ref": "#/definitions/TYPE"
}
}
]
},
"REPRESENTATION-2": {
"description": "DEFINITION",
"oneOf": [
{
"$ref": "#/definitions/TYPE"
},
{
"type": "array",
"items": {
"$ref": "#/definitions/TYPE"
}
}
]
}
}
"definitions": {
"REPRESENTATION-TYPE": {
"description": "A data type for ...",
"allOf": [
{
"$ref": "#/definitions/_base"
},
{
"type": "object",
"properties": {
"REPRESENTATION-1": {
"$ref": "#/properties/REPRESENTATION-1"
},
"REPRESENTATION-2": {
"$ref": "#/properties/REPRESENTATION-2"
},
"ADDITIONAL-CONTENT": {
"$ref": "#/properties/ADDITIONAL-CONTENT"
}
}
}
]
}
}
}
Representationpattern
Rule | Applicability | Title |
---|---|---|
NDR 10-42 | REF, EXT | Name of element that ends in Representation is abstract |
NDR 10-43 | REF, EXT | A substitution for a representation element declaration is a value for a type |
Rule | Applicability | Title |
---|---|---|
NDR 10-42 | REF, EXT | Name of element that ends in Representation is abstract |
NDR 10-43 | REF, EXT | A substitution for a representation element declaration is a value for a type |