Skip to content

Database_Integration: standalone multi-language, multi-fund examples - #7

Merged
karlkauc merged 1 commit into
mainfrom
feature/db-integration-multilang
May 15, 2026
Merged

karlkauc merged 1 commit into
mainfrom
feature/db-integration-multilang

Conversation

@karlkauc

Copy link
Copy Markdown
Contributor

Gives a developer a standalone, runnable, heavily-commented example in their own language for both directions (FundsXML → DB and DB → FundsXML), against the given relational structure, handling multiple nodes (≥2 Funds, multi Portfolio/Position/ShareClass/Asset).

What's new

  • Multi-fund relational model — ddl/schema.sql redesigned: document → fund → portfolio → position, share_class per fund, document-scoped asset, with 1-based ordinals so order & duplicates round-trip exactly.
  • Four standalone programs, same CLI (init / import / export / roundtrip), each self-contained and over-commented as a teaching artifact:
    Language Driver Verified
    Python python/fundsxml_db.py stdlib sqlite3 + lxml ✅ locally
    Java java/FundsXmlDb.java sqlite-jdbc, native javax.xml (no JAXB) ✅ locally
    JavaScript javascript/fundsxml_db.mjs sql.js + @xmldom/xmldom + xpath ✅ locally
    C# csharp/FundsXmlDb.cs Microsoft.Data.Sqlite ✅ locally (.NET 8) + CI
  • Round-trip proven by equivalence — tools/xml_equiv.py compares the import file vs the exported-from-DB file, ignoring only the volatile DocumentGenerated timestamp and numeric/whitespace/attr-order formatting (child order is significant). Always paired with XSD validation (it intentionally ignores xmlns).
  • Round-trip-faithful fixture FundsXML_Files/4.2.9/positions/Multi-Fund_Positions.xml (2 funds; one with 2 portfolios; share classes; document-scoped assets), XSD-valid.
  • Oracle/SQL Server/Postgres load_from_fundsxml + generate_fundsxml SQL updated to the multi-fund nested-XMLTABLE / grouped-XMLAGG / FOR XML pattern (code references, not executed).
  • Data_Binding_JSON/python/fundsxml_json.py reworked to the consistent multi-fund shape (lossless → xml_equiv-equal on the fixture).
  • tools/fetch-tools.sh fetches sqlite-jdbc; CI adds setup-node/setup-dotnet and runs the multi-fund round-trip in all four languages (equivalence + XSD + cross-language identity) plus the single-fund sample. .gitignore: node_modules/, bin/ obj/, macOS metadata.

Verified locally (end-to-end)

Every language's export of the multi-fund fixture is xml_equiv-equal to the original and to every other language's export, and XSD-valid; Mixed-Fund_Positions.xml (n=1) still round-trips XSD-valid; JSON multi-fund round-trip is xml_equiv-equal.

🤖 Generated with Claude Code

Rework Database_Integration so a developer finds a runnable, heavily-commented
example in their own language for BOTH directions (FundsXML -> DB, DB ->
FundsXML), handling multiple nodes (>=2 Funds, multi-Portfolio/Position/
ShareClass/Asset).

- ddl/schema.sql: redesigned multi-fund model (document -> fund -> portfolio
  -> position; share_class per fund; document-scoped asset) with 1-based
  ordinals so order/duplicates round-trip exactly.
- Standalone same-CLI programs (init/import/export/roundtrip), all verified
  locally to produce import==export:
    python/fundsxml_db.py        (stdlib sqlite3 + lxml)
    java/FundsXmlDb.java         (sqlite-jdbc, native javax.xml, no JAXB)
    javascript/fundsxml_db.mjs   (sql.js + @xmldom/xmldom + xpath)
    csharp/FundsXmlDb.cs(+csproj) (Microsoft.Data.Sqlite)
- tools/xml_equiv.py: shared normalized comparator proving import file ==
  export file (ignores DocumentGenerated timestamp + numeric/whitespace/attr
  ordering; child order significant); always paired with XSD validation.
- FundsXML_Files/4.2.9/positions/Multi-Fund_Positions.xml: round-trip-faithful
  multi-fund fixture (2 funds, one with 2 portfolios), XSD-valid.
- Oracle/SQLServer/Postgres load+generate SQL updated to the multi-fund
  nested-XMLTABLE / grouped-XMLAGG / FOR XML pattern (code references).
- Data_Binding_JSON/python/fundsxml_json.py reworked to the multi-fund shape
  (lossless -> xml_equiv-equal on the fixture).
- tools/fetch-tools.sh fetches sqlite-jdbc; CI runs the multi-fund round-trip
  in all 4 languages (equivalence + XSD + cross-language) plus the single-fund
  sample; setup-node and setup-dotnet added. .gitignore: node_modules, bin/
  obj/, macOS metadata.

Verified locally: every language's export is xml_equiv-equal to the fixture
and to each other, and XSD-valid; Mixed-Fund (n=1) still round-trips.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@karlkauc
karlkauc merged commit fcabdcd into main May 15, 2026
2 checks passed
@karlkauc
karlkauc deleted the feature/db-integration-multilang branch May 15, 2026 19:46
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