Skip to main content

Overview

Data definitions are the foundation of data extraction in Kodexa. They define the hierarchical structure of data elements you want to extract from documents, along with their types, validation rules, and extraction logic.

What is a Data Definition?

A Data Definition is a hierarchical structure of data elements. In configuration and API payloads, those elements are represented as taxons. A Data Definition defines:
  • What data to extract from documents
  • Where the data comes from (document content, metadata, formulas)
  • How to validate and format the data
  • What type of data it is (string, date, currency, etc.)

Key Concepts

Data Definition

Top-level container defining the complete data structure for extraction

Data Element

Individual field or group within a Data Definition

Data Group

Organizational container that groups related data elements without storing data itself

Value Path

Defines where the data element gets its value from (document, metadata, formula, etc.)

Data Definition Structure

Top-Level Configuration

Every data definition has these core properties:

Data Definition Properties


Data Element Configuration

Data elements are the individual fields and groups within a Data Definition. In configuration, each one is a taxon with extensive options organized into several categories.

Basic Properties

Every data element requires these fundamental properties:
name
string
required
Internal identifier (alphanumeric, hyphens, underscores only)
label
string
required
Human-readable display name
description
string
Detailed explanation of what this data element represents
enabled
boolean
default:"true"
Whether this data element is active (disabled elements cascade to children)
color
string
Hex color code for UI display (auto-generated if not specified)
generateName
boolean
default:"true"
Auto-generate the internal name from the label
externalName
string
Name used when publishing to external systems (auto-generated from label if not specified)

Data Source (Value Path)

The valuePath determines where the data element gets its value from:
Extracts data directly from document content using AI/ML models or pattern matching.When to use: Standard document extraction (invoices, contracts, forms)Configuration:
Features:
  • Uses semantic definition as extraction prompt
  • Can leverage document structure and layout
  • Supports AI-assisted extraction
Pulls data from document metadata (filename, creation date, owner, etc.).When to use: Document properties, system fields, audit trailConfiguration:
Available metadata values:
  • FILENAME - Document filename
  • TRANSACTION_UUID - Unique transaction identifier
  • CREATED_DATETIME - Document creation timestamp
  • DOCUMENT_LABELS - Applied labels
  • OWNER_NAME - Document owner
  • DOCUMENT_STATUS - Processing status
  • PAGE_NUMBER - Current page number
Calculates values using formulas that reference other data elements.When to use: Computed fields, calculations, aggregationsConfiguration:
Features:
  • Reference other data elements with {field_name} or {group/field_name}
  • Built-in functions such as sum, average, if, isblank, and datemath
  • Conditional logic support
Generates review templates using Jinja2 templating.When to use: Human review interfaces, validation checklistsConfiguration:
Placeholder for derived values (less common, use FORMULA instead).

Data Types

The taxonType defines how the data should be treated and validated:
Use for: Names, addresses, descriptions, any text content
Use stringExtract and stringReplace to automatically clean extracted values. See String Filters below.

Data Groups and Hierarchies

Groups organize related data elements and can represent repeating structures:

Group Configuration

group
boolean
default:"false"
Mark as a group (container for other data elements)
children
Taxon[]
Array of child data elements nested under this group
cardinality
object
Define how many instances of this group can exist:
naturalKeys
object[]
Define unique identifiers for group instances:
eventSubscriptions
TaxonEventSubscription[]
Attach reactive JavaScript scripts to a group data element. Event subscriptions can derive values, enforce business rules, call Service Bridges, create data exceptions, or emit follow-up events when modeled data changes.
For the full runtime guide, including the JavaScript objects available to scripts, see Event-Based Scripting.

Validation Rules

Define business rules and data quality checks on the data element they apply to:

Validation Rule Properties

Validation and Conditional Formatting

Read the complete guide for rule placement, exception lifecycle, conditional formatting schema, and the formula language.

Conditional Formatting

Apply visual formatting based on data values:

Classification Features

Help AI/ML models understand and classify content:
Provides guidance for AI extraction:
Best practices:
  • Be specific about what to look for
  • Describe location hints
  • Clarify edge cases
  • Provide examples if helpful
Helps with record-based chunking and classification:
Context types:
  • RECORD_DEFINITION - Describes the record structure
  • RECORD_START_MARKER - Text indicating record start
  • RECORD_END_MARKER - Text indicating record end
  • RECORD_SECTION_STARTER_MARKER - Section start marker
  • RECORD_SECTION_END_MARKER - Section end marker
Synonyms and antonyms for embedding-based classification:
Use for:
  • Improving classification accuracy
  • Handling terminology variations
  • Training embedding models

Advanced Options

Chunking Strategy

chunkingStrategy controls how a document is divided into segments before extraction. It is set on group taxons (typically the root taxon) and is a spatial-only selector — it applies to spatial documents (and legacy callers that do not specify a document mixin). Setting it on a non-spatial document is a misconfiguration that the extraction resolvers reject.
Valid values: Defaults for spatial / legacy group taxons: If a group taxon does not explicitly set chunkingStrategy, one is filled in automatically (existing values are never overridden):
  • If the planner has marked the group as non-embedded (its own chunk context), it defaults to classifiedContent.
  • Otherwise — including an unplanned or unconfigured taxonomy — it defaults to document, so the whole document is extracted as a single chunk.
Because these defaults apply only to group taxons on spatial (or legacy) documents, a typical spatial taxonomy extracts without needing to set chunkingStrategy at all. Set it explicitly when you want a different segmentation than the default.
If no enabled root taxon declares a chunkingStrategy and none is filled in by default (for example, a spatial taxonomy whose root taxons are not group taxons, so the automatic document default never applies), the extraction produces zero chunks and no data. This is a valid outcome for a blank taxonomy, so it is not an error — the extraction logs a warning instead. See Extraction produces no data if you expected output.

Display Configuration

Control how fields appear in the UI:

String Filters

Automatically clean extracted values using regex patterns. Extract keeps only matching characters, Replace removes matching characters. If both are set, extract runs first. The original value is preserved separately.

User Interaction


Common Patterns

Invoice Extraction

Complete example of a typical invoice data definition:

Contract Data Extraction


Best Practices

Naming Conventions

Semantic Definitions

Write semantic definitions as if explaining to a human what to look for. Be specific about:
  • What the field represents
  • Where it typically appears
  • How to identify it
  • Edge cases to consider
Good example:
Avoid:

Group Structures

Validation Strategy

  1. Start Simple: Begin with basic “not empty” validations
  2. Add Business Rules: Implement domain-specific validations
  3. Make Critical Rules Non-Overridable: Block processing if essential data is wrong
  4. Allow Overrides for Quality Checks: Let users override formatting or minor issues

Formula Usage


Troubleshooting

Common Issues

Possible causes:
  • enabled: false is set
  • Parent data element is disabled (disabling cascades to children)
  • notUserLabelled: true for labeling interfaces
Solution: Check enabled status up the hierarchy
Check:
  1. Is valuePath correct for your use case?
  2. Is semanticDefinition clear and specific?
  3. Are you using the right taxonType?
  4. Is the model trained for this document type?
Common mistakes:
  • Referencing data elements that don’t exist
  • Syntax errors in formula
  • Circular references
Test: Use formula builder to validate syntax
Check:
  • Is validation rule disabled: false?
  • Does conditionalFormula evaluate to true?
  • Is ruleFormula returning the expected boolean?

Next Steps

Data Types Reference

Reference guide for all supported data types

Formula Reference

Complete formula function reference

Selection Option Formulas

Compute dropdown options dynamically using JavaScript and service bridges

Event-Based Scripting

Attach reactive JavaScript behavior to group data elements

Scripting Reference

Complete API reference for Kodexa JavaScript scripting

Validation and Formatting

Common validation rule and conditional formatting patterns