Skip to content

Preserve raw XBRL and tighten validation#10

Open
ThomasMarcelis wants to merge 1 commit into
massive-com:masterfrom
ThomasMarcelis:improvements
Open

Preserve raw XBRL and tighten validation#10
ThomasMarcelis wants to merge 1 commit into
massive-com:masterfrom
ThomasMarcelis:improvements

Conversation

@ThomasMarcelis
Copy link
Copy Markdown

@ThomasMarcelis ThomasMarcelis commented May 2, 2026

This PR makes the parsed output keep more of the original XBRL instance document, and makes Validate() report structural problems more explicitly.

Main changes:

  • RawXBRL / XBRL now preserve the root XML name and attributes, raw context/unit slices, and raw reference elements such as schemaRef, linkbaseRef, roleRef, arcroleRef, and footnoteLink.
  • Segment elements now preserve nested XML through InnerXML.
  • Context scenario elements are preserved as raw XML, but still rejected by Validate() because scenario support is not implemented.
  • Validate() now checks contexts, units, duplicate IDs, period shape, entity identifiers, fact structure, broken fact references, and unsupported top-level item / tuple elements.
  • Fact.Validate() now returns specific errors for malformed numeric, non-numeric, nil, and fraction facts.
  • NumericValue() now returns errors for malformed numeric facts instead of panicking on missing fields.
  • Added Parse, ParseReader, and Decode helpers around the existing encoding/xml flow.

This is mostly additive API surface, but validation is intentionally stricter: some malformed documents that previously parsed without a useful validation error may now fail Validate().

Tests cover focused XML snippets, the existing AAPL and EDGR fixtures, examples, and parse/validate fuzzing.

Checked with go test ./....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant