Skip to content

The documents this library writes are checked against the schema - #42

Closed
fabeat wants to merge 4 commits into
mainfrom
feat/ooxml-gate
Closed

fabeat wants to merge 4 commits into
mainfrom
feat/ooxml-gate

Conversation

@fabeat

@fabeat fabeat commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

A .docx is Office Open XML, and a document that breaks the schema is a document that is not what it claims to be. Word opens it anyway, because Word is lenient where the schema is not, and nothing else in the suite could see it.

The check is Microsoft's own validator — the one the Open XML SDK Productivity Tool uses — vendored into tools/ooxml-validator, and it runs over the examples: the whole corpus of documents this library writes, built by examples/build.php. A gate over a selection is a gate over the selection.

The gate is red when it lands, and that is the point of landing it first.

errors
upstream PHPWord 1.4.0, before anything 1002
with PHPWord's four upstream fixes 151
of those, the three committed .dotx templates 44
of those, PHPWord's own writer 88
of those, this library 19 — a link's run properties, fixed by #41

So the fixes that are still missing are upstream: w:gridCol carries a w:type attribute the schema does not name (85), w:tblHeader carries w:val="1" where the SDK reads on or off alone (3), and the three committed templates carry their own w:pgSz, w:settings and style definitions (44). The gate turns green when those land; it is here first so that they are proved to have landed rather than believed to have.

The test skips itself where the .NET SDK is not, and says what is missing. The ooxml job in tests.yml installs the SDK with actions/setup-dotnet and runs the suite there, so the gate cannot be skipped in CI. The runner image ships a .NET SDK of its own, so the jobs that run the rest of the suite leave the ooxml suite out rather than measure the gate against whatever the image happens to carry — that is what keeps this one red cross from being three of them, and what keeps the SonarCloud job running while the gate is red.

A second test asks the validator about a document with an element in it that no schema names, which is what proves the gate can fail.

examples/build.php --no-previews is new: drawing a preview of each document's first page takes longer than everything else the build does, and the gate wants the documents.

A `.docx` is Office Open XML, and a document that breaks the schema is a
document that is not what it claims to be. Word opens it anyway, because Word
is lenient where the schema is not, and nothing else in the suite could see it.

The validator is Microsoft's own — the one the Open XML SDK Productivity Tool
uses — and it is run over the examples: the whole corpus of documents this
library writes, built by `examples/build.php`. A gate over a selection is a
gate over the selection.

The test skips itself where the .NET SDK is not, and says what is missing; the
job that installs the SDK runs it where it is, so the gate cannot be skipped
there. A second test asks the validator about a document with an error in it,
which is what proves that the gate can fail.
Drawing a preview of each document's first page takes longer than everything
else the build does, and the gate that reads the documents wants the documents.

The previews are still emptied with the rest of `out/`: a preview of a
document that is no longer built is a picture of nothing, which is the same
thing the directory is emptied for.
The gate is red when it lands: over the twenty-nine documents the build
writes, Microsoft's validator reports a thousand and two errors, and with the
four fixes upstream in PHPWord's writer it reports a hundred and fifty-one, of
which forty-four belong to the three committed templates and eighty-eight to
PHPWord itself.
…e suite

The runner image ships a .NET SDK, so the test does not skip itself there and
the gate would have failed the test matrix over a document that is nobody's
business but the gate's — and the analysis job needs the test job to have
passed. The gate has a job of its own, with the SDK version the validator is
built for, and the other jobs leave the suite out.
@sonarqubecloud

Copy link
Copy Markdown

@fabeat

fabeat commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator Author

Combined into #49, which carries this and the rest of the campaign in one pull request. Nothing is lost: the commits are in it, and the release notes are folded into the 0.3.1 section.

@fabeat fabeat closed this Oct 31, 2026
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