Skip to content

Map XSD types sharing a local name to distinct tables - #78

Open
martinv13 wants to merge 3 commits into
cre-dev:mainfrom
martinv13:claude/issue-77-xsd-schema-2jly79
Open

martinv13 wants to merge 3 commits into
cre-dev:mainfrom
martinv13:claude/issue-77-xsd-schema-2jly79

Conversation

@martinv13

Copy link
Copy Markdown
Collaborator

Complex types were keyed by their local name only, so two types sharing a local name were mapped
to the same table. The second one was either merged into the first or dropped, because the name
collision was mistaken for a recursive definition. Both cases lost data without an error.

This shows up in two ways:

  • within a single schema, when two elements with the same name have different anonymous types,
  • across schemas, when two imported namespaces define a type with the same name.

DataModel._get_type_key now assigns a key per XSD type, appending a numeric suffix and logging a
warning when local names collide.

Tests

orders.xsd declares detail twice with a different anonymous complex type, in itemtype and in
shipordertype, with matching data in order3.xml. The existing parametrized tests cover it, and
the model output snapshots are regenerated. Reverting model.py makes 12 of them fail.

Compatibility

A schema that already contains such a collision now produces one more table, and the second type
gets a suffixed key. This recovers data that was previously dropped, but the generated model
changes for those schemas.

Docs

A note in the getting started guide on documents mixing several schemas, and a caveat on xs:any
wildcards being discarded. CLAUDE.md gets a section asking for minimal bug fixes covered by
sub-cases of existing sample models.

Refs #77

🤖 Generated with Claude Code

https://claude.ai/code/session_01DYgbAh7586edNcD8HXyvcP

Complex types were keyed by their local name only, so two types sharing
a local name in different namespaces were mapped to the same table. The
second one was silently merged into the first, or dropped when the name
collision was mistaken for a recursive definition. Types are now keyed
per XSD type, appending a numeric suffix when local names collide.

Add a documentation page on combining several schemas, covering wrapper
schemas replacing xs:any wildcards with the payload schema, and a
caveat section about wildcards.

Refs cre-dev#77

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TGCUjv7869FF3vgK1ezSV9
Replace the dedicated test model and test module with a sub-case of the
orders sample model: 'detail' is declared twice with a different
anonymous complex type, so both types share a local name. The existing
parametrized tests cover it, and the model output snapshots are
regenerated.

Replace the page on combining several schemas with a short note in the
getting started guide, and point the wildcards caveat to it.

Document in CLAUDE.md that bug fixes should stay minimal and be covered
by sub-cases of existing sample models and tests.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DYgbAh7586edNcD8HXyvcP
The wildcards and type naming details in the getting started note are
already covered by the caveats page, and the cross reference to the note
is not needed there. The model output snapshots already fail when two
types sharing a local name are merged, so the added test checked nothing
new.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DYgbAh7586edNcD8HXyvcP

This branch has not been deployed

No deployments
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.

2 participants