Skip to content

fix(bcf): export schema-valid BCF and read 3.0 colouring - #826

Open
helenkwok wants to merge 1 commit into
ThatOpen:mainfrom
helenkwok:fix/bcf-export-schema
Open

helenkwok wants to merge 1 commit into
ThatOpen:mainfrom
helenkwok:fix/bcf-export-schema

Conversation

@helenkwok

Copy link
Copy Markdown
Contributor

Fixes #825.

  • utils/xml.ts: XML.escape (the same helper as in fix(ids): decode XML entities on load and escape values on export #818, so the two merge cleanly).
  • extensions.xml: XML declaration first, values escaped, placeholder schema location removed. documents.xml: Filename and Description escaped.
  • bcf.version: empty <Version .../>.
  • .bcfv: 3.0 <Color> wraps its components in <Components> (2.1 unchanged); AspectRatio written only for 3.0, after FieldOfView / ViewToWorldScale; AuthoringToolId as a child element; ids escaped.
  • <Exceptions> uses exceptionComponents instead of repeating the selection.
  • Viewpoint files are named <guid>.bcfv, and the markup references the same name.
  • Import reads 3.0 <Color><Components> as well as 2.1 <Color><Component>.

Clipping planes in .bcfv, the toJSON snapshot encoding and 2.1 extensions are left for separate changes (listed in the issue).

Test

New src/openbim/BCFTopics/bcf-export.test.ts exports a topic with & and < in its type, label and document, a viewpoint titled Level 2/North with a selection, an exception and a colour, for both 2.1 and 3.0. It checks that every XML file is well-formed (fast-xml-parser's XMLValidator), the extensions file starts with the declaration, values are escaped, the viewpoint file is <guid>.bcfv at the topic root and matches the markup, the 3.0 and 2.1 colour and camera layouts, and that load() reads back the same colouring, selection and exceptions.

  • With this change: 7 of 7 pass; packages/core vitest run 64 of 64; tsc --noEmit and eslint on the changed files report the same as main.
  • Without it: all 7 fail.
  • Outside the test, the exported 3.0 files (bcf.version, extensions.xml, documents.xml, markup.bcf, .bcfv) all validate with xmllint --schema against BCF-XML release_3_0/Schemas, and the 2.1 markup.bcf, .bcfv and bcf.version against release_2_1/Schemas.

The includeSelectionTag: true path (AuthoringToolId) needs a loaded model, so it is covered by reading the schema, not by the test.

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following:

  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Follow the Conventional Commits v1.0.0 standard for PR naming (e.g. feat(examples): add hello-world example).
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

- extensions.xml: XML declaration first, values escaped, no placeholder schema
  location; documents.xml and component ids escaped (XML.escape).
- bcf.version: empty Version element, as the schema requires.
- .bcfv: 3.0 Color wraps its components in <Components>; AspectRatio only in
  3.0, after FieldOfView / ViewToWorldScale; AuthoringToolId as a child element.
- Exceptions use exceptionComponents (they repeated the selection, hiding the
  selected elements in other viewers).
- Viewpoint files are named by guid; a title with "/" made nested folders.
- Import reads 3.0 <Color><Components> as well as 2.1 <Color><Component>.

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.

BCF export: extensions.xml and documents.xml are not well-formed, 3.0 viewpoints fail the schema, and exceptions repeat the selection

1 participant