Skip to content

Refactor/consolidate remaining identical duplicates - #569

Open
JieXiong9119 wants to merge 6 commits into
develop-v2from
refactor/patch-deduplicate
Open

JieXiong9119 wants to merge 6 commits into
develop-v2from
refactor/patch-deduplicate

Conversation

@JieXiong9119

Copy link
Copy Markdown
Contributor

Any background context you want to provide?

Issue #356 lists the duplicate element names that remained after the earlier "trivial" deduplication round (#323, #324, #325, PR #349, released in v2.4.0). At base 4f69954, 32 names were still on the ignored_dupes exception list in spec/validation_spec.rb, with 177 named declarations between them.

This PR covers only the duplicates whose declarations are identical, so they can be merged into one global element plus ref uses without changing what validates. Context-specific duplicates, which would need renames (breaking) or type widening (minor), are left for separate work.

The proposal is included: proposals/2026/Consolidate Remaining Identical Duplicate Elements.md.

What does this PR do?

Classification: PATCH. No element is renamed or moved, no sequence is reordered, no type is widened or narrowed, and no content becomes required. Existing instance documents validate exactly as before, so no migration script is needed.

Schema changes in BuildingSync.xsd:

Element Use sites converted to ref Shared global
Capacity 4 Existing global auc:Capacity, unchanged. The 17 other uses were already refs.
ControlSystemTypes 3 New global with inline type: ref="auc:ControlSystemType" with minOccurs="0" and maxOccurs="unbounded".
Controls 19 (general) New global with inline type: local Control of type auc:ControlGeneralType with maxOccurs="unbounded". The lighting Controls stays local because it uses ControlLightingType.
Other 16 New global typed as the empty auc:OtherType. The 5 Other declarations with their own inline content stay local.
CBECS 2 New global typed auc:CBECSType, which is unchanged.
  • Occurrence attributes stay on each use site. The globals carry none.
  • Documentation written on a use site is kept on that use site.
  • Control is not made global because that name collides with gbXML.

Impact:

  • Named element declarations: 1585 → 1527 (−58).
  • Duplicate names: 32 → 29.
  • Declarations across the original 32 names: 177 → 119.
  • ignored_dupes: removed Capacity, CBECS and ControlSystemTypes. Nothing was added.

Tests in spec/validation_spec.rb:

  • A structure check: declaration and ref counts, and occurrence attributes on every ref.
  • Behaviour tests:
    • Capacity: all four contexts, valid and invalid cases.
    • ControlSystemTypes: all three plant types.
    • General Controls and lighting Controls: what each accepts and rejects.
    • Other: the empty global form and the five inline forms that stay local.
    • CBECS: both contexts. Accepts an empty element and zones 1–5. Rejects zone 6, a repeated ClimateZone, and text content.

Known downstream effect:

  • The schema viewer on buildingsync.net does not show the children of a ref that points to a global element with a named complexType (schema#474, now BuildingSync-website#229).
  • Until that fix ships, the viewer will not show ClimateZone under CBECS. Validation is not affected.
  • The other new globals use inline or empty types, so the viewer shows them correctly.
  • Generated bindings such as bsyncpy may need to be regenerated. XPath consumers are not affected because instance paths do not change.

How should this be manually tested?

  1. bundle exec rake: all examples validate. Expected result: 13 examples, 0 failures.
  2. bundle exec rake generate_data_dictionary: no name conflicts. Delete the generated docs/DataDictionary.xlsx and docs/enumerations.json afterwards.
  3. poetry run pre-commit run --all-files.
  4. Optional: compare against the base commit site by site.
    • Each use site of the five elements, compared between 4f69954 and this branch, should have:
      • the same ancestor path, parent compositor and sibling position;
      • the same minOccurs/maxOccurs;
      • the same resolved content model, with refs expanded and annotations ignored;
      • the same local documentation.
    • Verified result: all 67 use sites identical, 44 of them converted to refs.
    • One difference is expected and documentation-only: 15 converted Other sites and both CBECS sites had no documentation of their own, so they now show the global's text.

What are the relevant tickets?

Screenshots (if appropriate)

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant