XBRLens parses XBRL filings, normalizes dimensional facts, and validates calculation relationships.
moon add ggbond44439/xbrlens@0.1.6let instance = match @xbrlens.parse_instance_xml(source, @xbrlens.XbrlLimits::strict()) {
Ok(value) => value
Err(err) => abort(err.to_string())
}
let facts_json = match @xbrlens.export_json(instance) {
Ok(value) => value
Err(err) => abort(err.to_string())
}moon run cmd/main -- inspect '<instance-xml>'
moon run cmd/main -- facts '<instance-xml>'
moon run cmd/main -- facts --csv '<instance-xml>'
moon run cmd/main -- validate '<instance-xml>'
moon run cmd/main -- calc '<instance-xml>' '<taxonomy-xml>' '<linkbase-xml>'
moon run cmd/main -- diff '<left-instance-xml>' '<right-instance-xml>'moon run examples/smoke
moon run cmd/main -- calc "$(cat fixtures/sample/instance.xml)" "$(cat fixtures/sample/taxonomy.xsd)" "$(cat fixtures/sample/calculation.xml)"python scripts/differential_check.py
python scripts/benchmark.py --iterations 3moon check --target all
moon test --target wasm
moon test --target wasm-gc
moon test --target js
moon fmt --checkpub(all) struct CalculationGroup {
role_uri : String
parent : QName
relations : Array[CalculationRelation]
} derive(Eq, Debug)pub(all) struct CliInvocation {
command : CliCommand
args : Array[String]
json : Bool
csv : Bool
help : Bool
} derive(Eq, Debug)pub(all) struct FactDiagnostic {
kind : FactDiagnosticKind
severity : FactDiagnosticSeverity
concept : QName
context_ref : String
unit_ref : String?
fact_ids : Array[String]
message : String
offset : Int
} derive(Eq, Debug)fn FactDiagnosticSeverity::not_equal(x : FactDiagnosticSeverity, y : FactDiagnosticSeverity) -> Boolpub(all) struct FactExportRow {
fact_id : String?
concept : String
namespace_uri : String
local_name : String
context_ref : String
entity_scheme : String
entity_identifier : String
period_type : String
instant : String?
start_date : String?
end_date : String?
unit_ref : String?
unit : String?
value : String
canonical_value : String?
nil : Bool
decimals : String?
precision : String?
language : String?
dimensions_json : String
} derive(Eq, Debug)pub(all) struct LabelLink {
role_uri : String
locators : Array[LinkLocator]
labels : Array[LabelResource]
arcs : Array[LinkArc]
offset : Int
} derive(Eq, Debug)pub(all) struct ResolvedTaxonomy {
root_location : String
schemas : Array[ResolvedTaxonomySchema]
} derive(Eq, Debug)fn ResolvedTaxonomy::concept(self : ResolvedTaxonomy, namespace_uri : String, local_name : String) -> XbrlConcept?pub(all) struct ResolvedTaxonomySchema {
location : String
schema : XbrlSchema
source : String
} derive(Eq, Debug)fn ResolvedTaxonomySchema::not_equal(x : ResolvedTaxonomySchema, y : ResolvedTaxonomySchema) -> Boolfn TaxonomyCatalog::add(self : TaxonomyCatalog, location : String, namespace_uri : String, source : StringView) -> Result[Unit, XbrlError]fn TaxonomyCatalog::resolve(self : TaxonomyCatalog, root_location : String, limits : XbrlLimits) -> Result[ResolvedTaxonomy, XbrlError]pub(all) struct XbrlConcept {
name : QName
id : String?
type_name : QName
substitution_group : QName
kind : ConceptKind
period_type : ConceptPeriodType
balance : ConceptBalance
is_abstract : Bool
nillable : Bool
offset : Int
} derive(Eq, Debug)pub(all) struct XbrlContext {
id : String
entity_scheme : String
entity_identifier : String
period : XbrlPeriod
segment : XmlNode?
scenario : XmlNode?
dimensions : Array[DimensionMember]
offset : Int
} derive(Eq, Debug)pub(all) enum XbrlError {
InvalidLimit(String, Int)
LimitExceeded(String, Int, Int)
InvalidQName(String, Int)
MissingNamespace(String, Int)
XmlSyntax(String, Int)
UnsafeXml(String, Int)
InvalidDecimal(String, Int)
InvalidContext(String, Int)
InvalidUnit(String, Int)
InvalidTaxonomy(String, Int)
InvalidLinkbase(String, Int)
MissingConcept(String)
UnresolvedReference(String)
InvalidDimension(String, Int)
DuplicateFact(String, Int)
CalculationMismatch(String, String, String)
InvalidFact(String, Int)
UnsupportedFeature(String)
Io(String)
} derive(Eq, Debug)pub(all) struct XbrlInstance {
schema_refs : Array[String]
contexts : Array[XbrlContext]
units : Array[XbrlUnitDefinition]
facts : Array[XbrlFact]
} derive(Eq, Debug)pub(all) struct XbrlLinkbase {
label_links : Array[LabelLink]
presentation_links : Array[PresentationLink]
calculation_links : Array[CalculationLink]
} derive(Eq, Debug)fn XbrlLinkbase::calculation_groups(self : XbrlLinkbase, taxonomy : ResolvedTaxonomy) -> Result[Array[CalculationGroup], XbrlError]fn XbrlLinkbase::calculation_relations(self : XbrlLinkbase, taxonomy : ResolvedTaxonomy) -> Result[Array[CalculationRelation], XbrlError]fn XbrlLinkbase::check_calculations(self : XbrlLinkbase, taxonomy : ResolvedTaxonomy, instance : XbrlInstance) -> Result[CalculationReport, XbrlError]fn XbrlLinkbase::labels(self : XbrlLinkbase, taxonomy : ResolvedTaxonomy) -> Result[Array[ConceptLabel], XbrlError]fn XbrlLinkbase::presentation_relations(self : XbrlLinkbase, taxonomy : ResolvedTaxonomy) -> Result[Array[PresentationRelation], XbrlError]pub(all) struct XbrlSchema {
target_namespace : String
imports : Array[TaxonomyImport]
concepts : Array[XbrlConcept]
role_types : Array[RoleType]
offset : Int
} derive(Eq, Debug)fn XbrlSchema::concept(self : XbrlSchema, namespace_uri : String, local_name : String) -> XbrlConcept?pub(all) struct XmlNode {
name : QName
attributes : Array[XmlAttribute]
namespaces : Array[NamespaceBinding]
children : Array[XmlNode]
text : String
offset : Int
} derive(Eq, Debug)fn audit_instance_source(source : StringView, limits : XbrlLimits) -> Result[SecurityAudit, XbrlError]fn check_calculations(linkbase : XbrlLinkbase, taxonomy : ResolvedTaxonomy, instance : XbrlInstance) -> Result[CalculationReport, XbrlError]fn resolve_qname(lexical : StringView, bindings : Array[NamespaceBinding], use_default_namespace : Bool) -> Result[QName, XbrlError]Install
Download zipXBRLens parses XBRL filings, normalizes dimensional facts, and validates calculation relationships.