A Rust library for parsing and validating XBRL documents. This library expects UTF-8 encoded XML files.
XBRL (eXtensible Business Reporting Language) is a standard for financial reporting.
The main concepts of XBRL are:
- taxonomy: the dictionary and rulebook that defines how financial and business information is labeled, structured, and related
- instance document: a company's actual reported data
- discoverable taxonomy set (DTS): the full set of taxonomy files that define all concepts referenced in an instance
- XBRL Instance: parse facts, contexts, units
- XBRL Taxonomy: parse XSD schemas and linkbases (presentation, calculation, definition, labels, references)
- XBRL Validation: validate XBRL instance against XBRL taxonomy
- XBRL View: view facts of an XBRL instance, formatted according to the presentation linkbase
To download XBRL taxonomies, feature download needs to be enabled.
// Parse XBRL instance document from XML file
let instance = InstanceDocument::from_file("/path/to/financial_report.xml").unwrap();
// Validate instance document against taxonomy
let schema_refs = instance.schema_refs();
let taxonomy_root = "/path/to/taxonomies";
let loader = TaxonomyLoader::new().unwrap();
loader
.download_all(schema_refs.iter().map(String::as_str), taxonomy_root)
.unwrap();
let taxonomy = TaxonomySet::discover(schema_refs.to_vec(), taxonomy_root.into()).unwrap();
let validation_result = instance.validate(&taxonomy);Some integration tests require the downloaded taxonomy files in test_data/taxonomies: cargo run --bin download_taxonomies --release
# Run unit tests
cargo test --lib
# Run integration tests
cargo test --test '*'
# Run integration tests with full taxonomy
cargo test --features taxonomy-testConformance tests are based on the XBRL International Conformance
Suite
(2025-07-16). The downloaded test suite is required in
test_data/conformance to run the conformance tests.
# Run conformance tests
cargo test conformance_suite --features conformance-test| Category | Passed | Failed | Skipped | Total | Pass Rate |
|---|---|---|---|---|---|
| 100-schema | 61 | 15 | 0 | 76 | 80% |
| 200-linkbase | 117 | 87 | 0 | 204 | 57% |
| 300-instance | 228 | 77 | 0 | 305 | 75% |
| 400-misc | 4 | 7 | 0 | 11 | 36% |
| arc-duplication | 1 | 3 | 0 | 4 | 25% |
| uniqueParticleAttribution | 4 | 2 | 0 | 6 | 67% |
| TOTAL | 417 | 189 | 0 | 606 | 69% |
The package manager uv is required to run the Python benchmarks.
# Rust (HTML report is generated in target/criterion/report/index.html)
cargo bench
# Python (uv creates venv in ~/.cache/uv and installs arelle-release)
uv run benches/bench_xbrl.pyBenchmarked libraries:
DTS discovery for German HGB taxonomies (2020-04-01, ~50 MB of XSD/XML files).
Benchmark single_dts_2020: 1 entry point
| Library | Mean time | Speedup |
|---|---|---|
| Arelle | 1003.46 ms | 1x |
| xbrl-rs | 106.40 ms | 9x |
Benchmark full_dts_2020: 6 entry points combined into one DTS
| Library | Mean time | Speedup |
|---|---|---|
| Arelle | 3851.48 ms | 1x |
| xbrl-rs | 174.32 ms | 22x |
Benchmark validate_instance:
| Library | Mean time | Speedup |
|---|---|---|
| Arelle | 797.31 ms | 1x |
| xbrl-rs | 1.81 ms | 440x |
Benchmark memory usage:
| Library | Peak RSS | Reduction |
|---|---|---|
| Arelle | 1748 MB | 1x |
| xbrl-rs | 34 MB | 51x |