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 astaxons. 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 ataxon with extensive options organized into several categories.
Basic Properties
Every data element requires these fundamental properties:Internal identifier (alphanumeric, hyphens, underscores only)
Human-readable display name
Detailed explanation of what this data element represents
Whether this data element is active (disabled elements cascade to children)
Hex color code for UI display (auto-generated if not specified)
Auto-generate the internal
name from the labelName used when publishing to external systems (auto-generated from label if not specified)
Data Source (Value Path)
ThevaluePath determines where the data element gets its value from:
Document (VALUE_OR_ALL_CONTENT)
Document (VALUE_OR_ALL_CONTENT)
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
Metadata (METADATA)
Metadata (METADATA)
Pulls data from document metadata (filename, creation date, owner, etc.).When to use: Document properties, system fields, audit trailConfiguration:Available metadata values:
FILENAME- Document filenameTRANSACTION_UUID- Unique transaction identifierCREATED_DATETIME- Document creation timestampDOCUMENT_LABELS- Applied labelsOWNER_NAME- Document ownerDOCUMENT_STATUS- Processing statusPAGE_NUMBER- Current page number
Formula (FORMULA)
Formula (FORMULA)
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, anddatemath - Conditional logic support
Review (REVIEW)
Review (REVIEW)
Generates review templates using Jinja2 templating.When to use: Human review interfaces, validation checklistsConfiguration:
Derived (DERIVED)
Derived (DERIVED)
Placeholder for derived values (less common, use FORMULA instead).
Data Types
ThetaxonType defines how the data should be treated and validated:
- String
- Number
- Currency
- Date
- Date Time
- Selection
- Boolean
- Other Types
Data Groups and Hierarchies
Groups organize related data elements and can represent repeating structures:Group Configuration
Mark as a group (container for other data elements)
Array of child data elements nested under this group
Define how many instances of this group can exist:
Define unique identifiers for group instances:
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:Semantic Definition
Semantic Definition
Provides guidance for AI extraction:Best practices:
- Be specific about what to look for
- Describe location hints
- Clarify edge cases
- Provide examples if helpful
Additional Context
Additional Context
Helps with record-based chunking and classification:Context types:
RECORD_DEFINITION- Describes the record structureRECORD_START_MARKER- Text indicating record startRECORD_END_MARKER- Text indicating record endRECORD_SECTION_STARTER_MARKER- Section start markerRECORD_SECTION_END_MARKER- Section end marker
Lexical Relations
Lexical Relations
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.
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.
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.- Common Patterns
- Examples
User Interaction
Common Patterns
Invoice Extraction
Complete example of a typical invoice data definition:Contract Data Extraction
Best Practices
Naming Conventions
Semantic Definitions
Good example:Group Structures
Validation Strategy
- Start Simple: Begin with basic “not empty” validations
- Add Business Rules: Implement domain-specific validations
- Make Critical Rules Non-Overridable: Block processing if essential data is wrong
- Allow Overrides for Quality Checks: Let users override formatting or minor issues
Formula Usage
Simple Calculations
Simple Calculations
Aggregations
Aggregations
Conditional Logic
Conditional Logic
Date Calculations
Date Calculations
Troubleshooting
Common Issues
Data element not appearing in UI
Data element not appearing in UI
Possible causes:
enabled: falseis set- Parent data element is disabled (disabling cascades to children)
notUserLabelled: truefor labeling interfaces
Extraction not working
Extraction not working
Check:
- Is
valuePathcorrect for your use case? - Is
semanticDefinitionclear and specific? - Are you using the right
taxonType? - Is the model trained for this document type?
Formula errors
Formula errors
Common mistakes:
- Referencing data elements that don’t exist
- Syntax errors in formula
- Circular references
Validation not triggering
Validation not triggering
Check:
- Is validation rule
disabled: false? - Does
conditionalFormulaevaluate to true? - Is
ruleFormulareturning 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
