Skip to content

XBRL.from_directory() skips a schema saved as .xsd.xml and parses it as an instance #2070

Backlog

Description

@dgunning

XBRL.from_directory() only treats *.xsd files as schemas (parse_directory in edgar/xbrl/parsers/coordinator.py). A schema saved as .xsd.xml is never parsed as a schema, and because the instance filter only skips _lab.xml, _pre.xml, _cal.xml and _def.xml, the same file is handed to the instance parser instead.

Files downloaded from SEC end in .xsd, so this mostly affects local copies saved with an .xml suffix. Five of our own fixtures are named that way: tsla, msft, gbdc, aapl/10k_2022 and ibm/10k_2024 under tests/fixtures/xbrl/.

It showed up while reviewing #1992. With the Tesla fixture (June 2024 10-Q, 0001628280-24-032662), the schema's target namespace is never recorded, so by_extension() raises its "no filing schema with a target namespace was loaded" error:

from pathlib import Path
from edgar.xbrl import XBRL

tsla = Path("tests/fixtures/xbrl/tsla")
XBRL.from_directory(tsla).query().by_extension()   # ValidationError: no schema loaded

XBRL.from_files(instance_file=tsla / "tsla-20240630_htm.xml",
                schema_file=tsla / "tsla-20240630.xsd.xml").query().by_extension()  # 129 facts

Expected: from_directory() recognises *.xsd.xml as a schema and keeps it out of the instance list. The fix should also check that tests reading these five fixtures through from_directory() still pass once their schemas load, since element metadata such as period type and balance comes from the schema.

Activity

  1. added
    bug
    on Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions