Skip to main content

Overview

Core Component Types (CCT) are the foundational building blocks of the UBL 2.1 type system. They extend XML Schema simple types and provide the base implementation for Unqualified Data Types (UDT). All CCT types are in the namespace urn:un:unece:uncefact:data:specification:CoreComponentTypeSchemaModule:2.

Type Hierarchy

XML Schema Simple Types

XSD Wrapper Types (XsdString, XsdDecimal, XsdDate, XsdBoolean, XsdNormalizedString)

CCT Types (CctTextType, CctAmountType, CctCodeType, CctIdentifierType, etc.)

UDT Types (UdtText, UdtAmount, UdtCode, UdtIdentifier, etc.)
CCT types serve as the intermediate layer between primitive XSD types and application-level UDT types. They provide common attribute handling and validation logic.

CctAmountType

A number of monetary units specified in a currency where the unit of the currency is explicit or implied.
content
string
required
The monetary amount as a decimal string
attributes
AllowedAttributes
Optional attributes for the amount
currencyID
string
The currency of the amount (ISO 4217 code)
currencyCodeListVersionID
string
The version ID of the UN/ECE Rec9 code list

Constructor

constructor(content: string, attributes?: AllowedAttributes)

Methods

parseToJson
() => any
Converts the amount to JSON format with #text for content and @attribute for attributes
setCurrencyID
(value: string) => void
Sets the currency identifier
setCurrencyCodeListVersionID
(value: string) => void
Sets the currency code list version identifier

Example

import { CctAmountType } from 'ubl-builder';

const amount = new CctAmountType('1500.00', {
  currencyID: 'USD'
});
Extends: XsdDecimal Reference: Datypic CCT AmountType

CctBinaryObjectType

A set of finite-length sequences of binary octets.
content
string
required
The binary content (typically base64 encoded)
attributes
AllowedAttributes
Optional attributes for the binary object
format
string
The format of the binary content (e.g., “PDF”, “PNG”)
mimeCode
string
required
The MIME type of the binary object (e.g., “application/pdf”, “image/png”)
encodingCode
string
The decoding algorithm (e.g., “base64”)
characterSetCode
string
The character set if MIME type is text
uri
string
URI where the binary object is located
filename
string
The filename of the binary object

Constructor

constructor(content: string, attributes?: AllowedAttributes)

Methods

parseToJson
() => any
Converts to JSON format
setFormat
(value: string) => void
Sets the format attribute
setMimecode
(value: string) => void
Sets the MIME code
setEncodingCode
(value: string) => void
Sets the encoding code
setCharacterSetCode
(value: string) => void
Sets the character set code
setUri
(value: string) => void
Sets the URI attribute
setFileName
(value: string) => void
Sets the filename attribute

Example

import { CctBinaryObjectType } from 'ubl-builder';

const pdf = new CctBinaryObjectType('JVBERi0xLjQKJe...', {
  mimeCode: 'application/pdf',
  encodingCode: 'base64',
  filename: 'document.pdf',
  format: 'PDF'
});
Extends: XsdNormalizedString CCTS Properties:
  • Unique ID: UNDT000002
  • Category Code: CCT
  • Representation Term: Binary Object
  • Primitive Type: binary
Reference: Datypic CCT BinaryObjectType

CctCodeType

A character string to identify and distinguish uniquely one instance of an object in an identification scheme from all other objects in the same scheme.
content
string
required
The code value
attributes
AllowedAttributes
Optional attributes for the code
listID
string
The identification of a list of codes
listAgencyID
string
The agency that maintains the list of codes
listAgencyName
string
The name of the agency
listName
string
The name of the code list
listVersionID
string
The version of the code list
name
string
The textual equivalent of the code content
languageID
string
The language identifier
listURI
string
URI where the code list is located
listSchemeURI
string
URI where the code list scheme is located

Constructor

constructor(content: string, attributes?: AllowedAttributes)

Methods

parseToJson
() => any
Converts to JSON format
setListID
(value: string) => void
Sets the list identifier
setListAgencyID
(value: string) => void
Sets the list agency identifier
setListAgencyName
(value: string) => void
Sets the list agency name
setListName
(value: string) => void
Sets the list name
setlistVersionID
(value: string) => void
Sets the list version identifier
setName
(value: string) => void
Sets the textual name/description
setLanguageID
(value: string) => void
Sets the language identifier
setListUri
(value: string) => void
Sets the list URI
setListSchemeURI
(value: string) => void
Sets the list scheme URI

Example

import { CctCodeType } from 'ubl-builder';

const code = new CctCodeType('USD', {
  listID: 'ISO4217',
  listAgencyID: 'ISO',
  name: 'US Dollar'
});
Extends: XsdNormalizedString

CctIdentifierType

A character string to identify and distinguish uniquely one instance of an object in an identification scheme from all other objects in the same scheme.
content
string
required
The identifier value
attributes
AllowedAttributes
Optional attributes for the identifier
schemeID
string
The identification scheme (e.g., “GLN”, “DUNS”)
schemeName
string
The name of the identification scheme
schemeAgencyID
string
The agency maintaining the scheme
schemeAgencyName
string
The name of the agency
schemeVersionID
string
The version of the scheme
schemeDataURI
string
URI where the scheme data is located
schemeURI
string
URI where the scheme is located

Constructor

constructor(content: string, attributes?: AllowedAttributes)

Methods

parseToJson
() => any
Converts to JSON format
setSchemeID
(scheme: string) => void
Sets the scheme identifier
setSchemeName
(schemeName: string) => void
Sets the scheme name
setSchemeAgencyID
(value: string) => void
Sets the scheme agency identifier
setSchemeAgencyName
(value: string) => void
Sets the scheme agency name
setSchemeVersionID
(value: string) => void
Sets the scheme version identifier
setSchemeDataURI
(value: string) => void
Sets the scheme data URI
setSchemeURI
(value: string) => void
Sets the scheme URI

Example

import { CctIdentifierType } from 'ubl-builder';

const gln = new CctIdentifierType('1234567890123', {
  schemeID: 'GLN',
  schemeName: 'Global Location Number',
  schemeAgencyID: 'GS1'
});
Extends: XsdNormalizedString

CctTextType

A character string to identify and distinguish uniquely one instance of an object in an identification scheme from all other objects in the same scheme.
content
string
required
The text content
attributes
AllowedAttributes
Optional attributes
languageID
string
The language identification (e.g., “en”, “es”, “fr”)
languageLocaleID
string
The language locale identifier (e.g., “en-US”, “es-MX”)

Constructor

constructor(content: string, attributes?: AllowedAttributes)

Methods

validateContent
() => void
Validates the text content
parseToJson
() => any
Converts to JSON format
setLanguageID
(value: string) => void
Sets the language identifier
setLanguageLocaleID
(value: string) => void
Sets the language locale identifier

Example

import { CctTextType } from 'ubl-builder';

const description = new CctTextType('Product description');
Extends: XsdString

CctNumericType

Numeric information that is assigned or determined by calculation, counting, or sequencing. It does not require a unit of quantity or unit of measure.
content
string
required
The numeric value as a string
attributes
AllowedAttributes
Optional attributes
format
string
Whether the number is an integer, decimal, real number, or percentage

Constructor

constructor(content: string, attributes?: AllowedAttributes)

Methods

parseToJson
() => any
Converts to JSON format
setFormat
(value: string) => void
Sets the format attribute

Example

import { CctNumericType } from 'ubl-builder';

const count = new CctNumericType('42', { format: 'integer' });
Extends: XsdDecimal Reference: Datypic CCT NumericType

CctQuantityType

A counted number of non-monetary units possibly including fractions.
content
string
required
The quantity value
attributes
AllowedAttributes
Optional attributes
unitCode
string
The unit of measure (e.g., “EA”, “KGM”, “LTR”)
unitCodeListID
string
The unit code list identifier
unitCodeListAgencyID
string
The agency maintaining the unit code list
unitCodeListAgencyName
string
The name of the agency

Constructor

constructor(content: string, attributes?: AllowedAttributes)

Methods

validateContent
() => void
Validates the quantity content
parseToJson
() => any
Converts to JSON format
setUnitCode
(value: string) => void
Sets the unit code
setUnitCodeListID
(value: string) => void
Sets the unit code list identifier
setUnitCodeListAgencyID
(value: string) => void
Sets the unit code list agency identifier
setUnitCodeListAgencyName
(value: string) => void
Sets the unit code list agency name

Example

import { CctQuantityType } from 'ubl-builder';

const qty = new CctQuantityType('100', { unitCode: 'EA' });
Extends: XsdDecimal CCTS Properties:
  • Unique ID: UNDT000018
  • Category Code: CCT
  • Representation Term: Quantity
  • Primitive Type: decimal
Reference: Datypic CCT QuantityType

CctMeasureType

Numeric information that is assigned or determined by calculation, counting, or sequencing. It does not require a unit of quantity or unit of measure.
content
string
required
The measurement value
attributes
AllowedAttributes
required
Attributes for the measure (unitCode is required)
unitCode
string
required
The type of unit of measure
unitCodeListVersionID
string
The version of the measure unit code list

Constructor

constructor(content: string, attributes: AllowedAttributes)
Unlike other CCT types, CctMeasureType requires the attributes parameter with at least the unitCode property.

Methods

parseToJson
() => any
Converts to JSON format
setUnitCode
(value: string) => void
Sets the unit code
setunitCodeListVersionID
(value: string) => void
Sets the unit code list version identifier

Example

import { CctMeasureType } from 'ubl-builder';

const length = new CctMeasureType('150.5', { unitCode: 'MTR' });
Extends: XsdDecimal Reference: Datypic CCT NumericType

Common Patterns

Importing CCT Types

import {
  CctAmountType,
  CctBinaryObjectType,
  CctCodeType,
  CctIdentifierType,
  CctNumericType,
  CctQuantityType,
  CctMeasureType
} from 'ubl-builder';

Using as Base Classes

CCT types are typically extended by UDT types, but can be used directly:
import { CctAmountType } from 'ubl-builder';

// Direct usage
const amount = new CctAmountType('1000.00', { currencyID: 'USD' });

// Extended in custom types
class CustomAmountType extends CctAmountType {
  constructor(content: string) {
    super(content, { currencyID: 'USD' });
  }
}

JSON Serialization

All CCT types implement parseToJson() method:
import { CctCodeType } from 'ubl-builder';

const code = new CctCodeType('USD', {
  listID: 'ISO4217',
  name: 'US Dollar'
});

const json = code.parseToJson();
// {
//   "#text": "USD",
//   "@listID": "ISO4217",
//   "@name": "US Dollar"
// }

Attribute Management

CCT types provide both constructor-based and setter-based attribute management:
import { CctIdentifierType } from 'ubl-builder';

// Constructor approach
const id1 = new CctIdentifierType('123', {
  schemeID: 'GLN',
  schemeName: 'Global Location Number'
});

// Setter approach
const id2 = new CctIdentifierType('456');
id2.setSchemeID('DUNS');
id2.setSchemeName('D-U-N-S Number');

Type Comparison

CCT TypePurposeRequired AttributesBase Type
CctAmountTypeMonetary amountsNone (currencyID recommended)XsdDecimal
CctBinaryObjectTypeBinary datamimeCodeXsdNormalizedString
CctCodeTypeCode valuesNoneXsdNormalizedString
CctIdentifierTypeIdentifiersNoneXsdNormalizedString
CctTextTypeText stringsNoneXsdString
CctNumericTypeNumbersNoneXsdDecimal
CctQuantityTypeQuantitiesNone (unitCode recommended)XsdDecimal
CctMeasureTypeMeasurementsunitCodeXsdDecimal

Validation

Some CCT types include content validation:
import { CctQuantityType, CctTextType } from 'ubl-builder';

// Quantity validation
const qty = new CctQuantityType('100.5', { unitCode: 'KGM' });
qty.validateContent(); // Validates decimal format

// Text validation
const text = new CctTextType('Sample text');
text.validateContent(); // Validates string content

UDT Types

Unqualified Data Types that extend CCT types

Invoice Builder

Using types in UBL documents

References

CCT types form the bridge between primitive XML Schema types and application-specific UDT types. While you can use CCT types directly, it’s recommended to use UDT types in most cases as they provide more semantic meaning and align with UBL 2.1 specifications.

Build docs developers (and LLMs) love