omega-office
I wrote omega-office so that the text of a word processing document and the cells of a spreadsheet can be
read by a tool whose every line anyone can inspect. It reads Office Open XML packages (ECMA-376, the same
text as ISO/IEC 29500): a .docx main document part as plain UTF-8 text, and one worksheet of an .xlsx
workbook as CSV. It is written in Omega (seeded Omegese) and built by the pinned seed-born compiler;
nothing else runs inside it. It is slice S2 of the no-black-box tools and stands on slice S1, omega-zip,
whose inflate and zip reader it carries in vendor/omega-zip/.
One program, officeread:
(named ooffice until 2026-11-10; renamed because ooffice is another office suite's launcher on some
Linux distributions)
| command | what it does |
|---|---|
officeread text FILE.docx | the text of the main document part, one paragraph per line (UTF-8, LF) |
officeread csv FILE.xlsx [SHEET] | one worksheet as CSV (RFC 4180, CR LF); SHEET is a sheet name, else a position 1, 2, ... when no sheet has that name; the first sheet by default |
officeread sheets FILE.xlsx | the sheet names in workbook order, one per line |
officeread xmlev FILE [ENTRY] | the XML event sequence of FILE, or of the zip entry ENTRY in FILE (the form the gate compares with expat) |
Every refusal is one line on stderr, officeread: MESSAGE (or ozip: MESSAGE from the zip engine), and a
documented exit code (table below). Standard output is buffered and written in 64 KiB pieces, the last at
the end, so only exit 0 means a complete result; after a refusal stdout may hold the pieces already
written (a 70000-byte text run before a mismatched end tag leaves 65536 bytes on stdout and exits 62).
What the proof proves, and what it does not
The gate below proves that the officeread built from exactly these sources by the pinned compiler gives the
oracles' output on the corpus (after the normalisation stated for each oracle, and with every difference
classified), refuses the malformed and out-of-bound inputs with the stated codes, kills the stated mutants,
and never traps or hangs on the cut and changed inputs of the sweep. It does not prove that officeread is
correct on every input, that it is fast, or that a file it reads is harmless: it reads what the package
says, within the bounds below.
Build
The compiler is omega-mv's seed-born seed/out/omc at the commit in PIN (sha256 in PIN). With an
omega-mv checkout at that commit (sh seed/omega-from-seed.sh rebuilds omc from the seed and must give
the same sha256):
OMC=/path/to/omega-mv/seed/out/omc
cat src/head.om vendor/omega-zip/vendor/omega-mv/seed/text/text.om vendor/omega-zip/src/io.om \
vendor/omega-zip/src/crc32.om vendor/omega-zip/src/inflate.om vendor/omega-zip/src/unzip.om \
src/xml.om src/sink.om src/opc.om src/docx.om src/xlsx.om src/main.om | $OMC > officeread && chmod +x officeread
The units must be in that order (src/head.om carries the om2 line; a text or const is visible only
after its line). The output is a static Linux AArch64 executable. tests/gate.om builds the same way (its
UNITS text) and is the receipt.
Gate
mkdir -p build && $OMC < tests/gate.om > build/gate-bin && chmod +x build/gate-bin && build/gate-bin $OMC
Run from the repository root. The last line on success:
OFFICEREADGATE PASS cases=182 mutants-killed=30/30 robust-runs=46464
It exits 0 on PASS, 1 on any failure, 3 (NOT_RUN) when the compiler's SHA-256 is not the pin. It computes that SHA-256 itself (FIPS 180-4). Then it:
- builds
build/gate/officereadfrom the units; - runs the cases of
tests/cases.txt: exit status, stdout against the oracle (exactly, or after the stated normalisation), and stderr (empty after success, exactly oneofficeread:orozip:line after a refusal); - builds each mutant of
tests/mutants.txt(one or more source lines replaced) and requires a case to fail on it; - robustness: every corpus input cut at 64 points and changed at 256 single bytes, 10 s limit each.
Every run must end with exit 0 or a documented refusal code, never a trap (101..114), a signal or the
time limit. For a zip package an exit 0 must print exactly what the unchanged package prints (a changed
byte inside compressed data is caught by the inflate checks or by the CRC-32, code 47). For a plain XML
file an exit 0 with different output is counted as
changed-plain: plain XML has no checksum, so a changed byte can simply be a changed character. - before step 2, builds
tests/docs.omwith the same compiler and runs it: publication checks of the repository's own text (rulestests/docrules.txt: no local home paths, no source note citing a file outside the repository or missing from it, no note leaving a question open, the licence present). It printsDOCS PASS ... mutants-killed=K/K(its own mutants,tests/docmutants.txt); any other result fails the gate.
Recorded 2026-11-10T07:18:51Z to 07:20:23Z on a clean git archive export of e767cdab (omega-zip 231dd336
vendored unchanged, the command named officeread), in the pool-19 ticket (taskset -c 19, nice 10). The
earlier receipts (ec493564: 169 cases, 20 mutants; c1a13734: 170 cases, 21 mutants, printed with the old
prefix OOFFICEGATE) are in this file's history:
OFFICEREADGATE cases passed: expat=33 libreoffice-text=5 libreoffice-csv=9 exact=13; refusals passed: xml=65 package=41 zip=3 usage=4
OFFICEREADGATE mutants=23 killed=23
OFFICEREADGATE robustness files=137 runs=43584 refused=40220 exact=2191 changed-plain=737 accepted-after-change=436 failures=0
OFFICEREADGATE robustness exit codes: 10:72 11:91 12:63 13:1 14:256 15:364 16:344 17:134 18:226 19:1 21:791 40:4059 42:185 43:13 44:56 46:1515 47:489 48:14 50:731 53:1023 60:8522 61:3967 62:554 63:9096 64:301 65:586 66:683 67:612 68:56 70:83 71:38 72:111 73:206 74:21 75:110 80:616 81:1012 82:729 84:111 85:4 86:159 87:484 88:110 89:1621
OFFICEREADGATE PASS cases=173 mutants-killed=23/23 robust-runs=43584
Robustness: 137 files (22 packages and 17 XML files that are read, 41 package and 57 XML refusal fixtures) x (64 cuts + 256 one-byte changes). No trap, signal or timeout; no package ever exited 0 with output other than its unchanged output (2191 runs printed exactly that; 489 changed bytes were caught by the CRC-32, 47, and the rest by the inflate, zip, XML and package checks). 737 runs on plain XML printed other events (a changed character), and 436 runs turned a plain XML refusal fixture into a well-formed file.
Mutants (tests/mutants.txt; one or two lines replaced) and the case that killed each:
| mutant | change | killed by |
|---|---|---|
| m-entity | entity decoding off (& gives ?) | x-basic |
| m-charref | character references off | x-basic |
| m-sstindex | shared string index off by one | c-cells |
| m-colref | column placement ignores the cell reference | c-cells |
| m-hardpath | relationship lookup replaced by the hard-coded path word/document.xml | t-alt |
| m-prefix | a prefixed element takes the default namespace | x-basic |
| m-doctype | DOCTYPE skipped instead of refused | rx-doctype-ext |
| m-movefrom | moved-from text printed | t-alt |
| m-quote | CSV quoting off | c-cells |
| m-attrspace | attribute-value normalisation off | x-text |
| m-crlf | line-end normalisation off | x-basic |
| m-utf8 | UTF-8 refusal off (the end-of-input check still refuses) | rx-utf8-then-mismatch |
| m-depth | nesting bound off | rb-depth1025 |
| m-phonetic | phonetic runs printed with shared strings | c-xalt |
| m-mediatype | media type of the main part not checked | rp-ctype |
| m-dotdot | .. segments not removed | t-alt |
| m-cellsep | table cells separated by a space | t-features |
| m-boolean | TRUE printed as FALSE | c-xstrict |
| m-utf16le | UTF-16LE read as big-endian | x-utf16le |
| m-fastpath | the inline character-data path stores a wrong byte | z-plain |
| m-cdatafast | ] and > take the inline character-data path, so ]]> in a package part is not refused | rp-cdataend |
| m-attrfast | < and & take the inline attribute-value path, so they are not refused in a package part | z-squote (and rp-attramp) |
| m-attrquote | ' takes the inline attribute-value path, so a value opened by ' does not end at its ' | z-squote |
| m-depthfast | the inline character-data path skips the depth check, so text after the root element of a package part is not refused | rp-textafter |
| m-namefast | the inline name path skips its first-character check, so </1p> in a package part is 62 (mismatched end tag), not 60 | rp-enddigit |
| m-ncname | an element's local part is not checked as an NCName | rx-ns-local-digit (and rx-ns-local-middot, rp-localdigit) |
| m-ncattr | an attribute's local part is not checked as an NCName | rx-ns-local-attr |
| m-ncdecl | the prefix of an xmlns:p declaration is not checked as an NCName | rx-ns-decl-digit |
| m-ncdec2 | the NameStartChar check after a colon decodes a two-byte character with the wrong lead-byte mask | x-ns-local2 |
| m-ncdec3 | the NameStartChar check after a colon reads one continuation byte of a three-byte character, not two | x-ns-local2 |
Without the fixtures rp-attramp, rp-attrlt and h-squote (the cases and corpus of c6d510e3), both new mutants
survive (2026-11-10T07:16Z): the inline paths of src/sink.om were only checked by plain-file refusals.
Negative controls, 2026-11-10T07:20:23Z to 07:21:51Z on the same export: the gate with another omc (omega-mv
seed/out/omc sha256 0bca06df...) prints `OFFICEREADGATE NOT_RUN: compiler sha256 is not the pin
6d1b1cf5...` and exits 3; with no argument it prints its usage and exits 3. A build whose stderr prefix is
officereaX: (the first 9 bytes equal, which the gate's earlier fixed 9-byte compare let through) fails
111 cases on the stderr check. omega-zip 28e91f99's own src/io.om (its fn wout) next to src/sink.om
is refused by omc (error 10): the vendored files need no patch only because the seam is now omega-zip's.
The first negative control (06:15:04Z, seed/rung4/om4.bin) is in this file's history.
Proposed fix by factory inspection bay 3 (review of 06d4b937, needs its own review): the gate on a clean
git archive export of 6307bdd2 (README.md is the only file that differs), 2026-11-10T08:17:06Z to
08:20:17Z, pool-0-2 (taskset -c 0-2, nice 19), exit 0, stderr empty: `cases passed: expat=34
libreoffice-text=5 libreoffice-csv=9 exact=13; refusals passed: xml=72 package=41 zip=3 usage=4`,
mutants=28 killed=28, robustness files=145 runs=46144 ... failures=0, last line
OFFICEREADGATE PASS cases=181 mutants-killed=28/28 robust-runs=46144. At 06d4b937 the mutants m-depthfast
and m-namefast survive (the inline paths of src/sink.om again checked only by plain-file refusals), and
06d4b937's own build prints the text of rp-localdigit.docx with exit 0 and accepts every rx-ns-local and
rx-ns-decl fixture (exit 0) where expat refuses: the NCName check (Namespaces in XML 1.0 section 3) was
missing on both paths.
Proposed fix by factory inspection bay 8 (review of fb793565, needs its own review): the gate on a clean
git archive export of 10e81848 (README.md is the only file that differs), 2026-11-10T13:38:04Z to
13:41:17Z, pool-0-2 (taskset -c 0-2, nice 19), exit 0, stderr empty: `DOCS PASS files=20 paths-files=8
forbid=5 need=2 cases-file=1 mutants-killed=7/7, cases passed: expat=35 libreoffice-text=5
libreoffice-csv=9 exact=13; refusals passed: xml=72 package=41 zip=3 usage=4, mutants=30 killed=30`,
robustness files=146 runs=46464 ... failures=0, last line
OFFICEREADGATE PASS cases=182 mutants-killed=30/30 robust-runs=46464. At fb793565 with only the two new
mutant lines added (2026-11-10T13:41:17Z to 13:44:28Z, same pool), m-ncdec2 and m-ncdec3 survive and the
gate exits 1 (mutants=30 killed=28): after a colon the corpus had only the lead bytes 0xC2, 0xC3, 0xE4,
0xE5 and 0xE6 (x-ns-local, x-names, rx-ns-local-middot), for which both mutated decodes give the same verdict.
tests/mkcases.om (Omega) regenerates every generated corpus file (corpus/gen) byte-identical.
Oracles
All oracles are test tools only, never part of omega-office; their outputs are committed with the commands
that made them (corpus/SOURCES.txt), so the gate itself needs only the pinned compiler.
| oracle | what it checks | cases |
|---|---|---|
expat 2.6.1 through python3 3.12.3 xml.sax (xmllint is not installed on the Spark) | the XML event sequence (xmlev) of 18 plain files and of 17 parts inside the corpus packages (the second set goes through the inflate sink and its fast path) | 35 |
LibreOffice 24.2.7.2 headless, txt:Text (encoded):UTF8 | text: equal after the normalisation below | 5 |
| LibreOffice 24.2.7.2 headless, CSV filter with token 9 false (values as stored, not as shown) and token 12 = the sheet | csv: equal after the normalisation below | 9 |
| reviewed or hand-derived expected files | text, csv, sheets outputs whose LibreOffice difference is classified (corpus/expect/*.lo.diff), and the packages LibreOffice does not open, derived by hand from the clauses below | 13 |
I chose LibreOffice over python3 zipfile plus xml.sax for the spreadsheet oracle because it is an independent implementation of the whole path (package, relationships, shared strings, cell placement), and with "values as stored" it prints the stored cell values; a Python reader would have been my own reading of the standard a second time.
Normalisation. Text: on both sides a leading UTF-8 byte order mark is removed (LibreOffice writes one), CR LF becomes LF, and spaces and tabs at the end of each line are removed. CSV: my CR LF record ends (RFC 4180 2.1) are read as LF (LibreOffice writes LF); nothing else is changed on either side.
Every difference class found, with its files and the reason:
| class | LibreOffice prints | officeread prints | why | files |
|---|---|---|---|---|
| list and outline labels | the label of a numbered or bulleted paragraph ( •, 1.), and 7 spaces for a heading with an empty outline label | no label | labels come from the numbering part and its counters, which this slice does not read | features, lists |
| tracked deletions | deleted text (removed words) as if it were present | nothing for del (17.13.5.14) and moveFrom (17.13.5.22) | I print the text with every tracked change accepted: deleted and moved-away content is not part of it | features (and h-alt, which LibreOffice does not open) |
| footnote marks | the reference mark (1) | nothing | the mark is a counter of the footnotes part; footnotes are not read | features |
| recalculated fields | its own value of a page field (0) | the field result stored in the document (1) | I print the stored result (17.16.18, 17.16.19); there is no layout to recompute it | features |
| tables | every cell paragraph on its own line | one row per line, cells separated by a tab, paragraphs inside a cell separated by a space | the table form this slice defines | features, tables, h-strict |
| formatted numbers | a date, time or percentage cell in its number format (2026-11-10, 01:30:00 PM, 12.5%) although token 9 asks for stored values | the stored number (46336, 0.5625, 0.125) | formats are in the styles part, the next slice; a date is stored as a number | types sheet 1 |
| number text | its canonical number (-0.0005, 7) | the stored text (-0.5e-3, 007) | values print as stored | h-xalt sheet 1 |
ISO 8601 date cells (t="d") | a serial number (46336) | the stored text (2026-11-10T00:00:00) | values print as stored | h-xalt sheet 1 |
| a formula with no stored value | its computed value (2) | an empty field | there is no formula engine; only stored values are read | h-xalt sheet 1 |
LibreOffice 24.2.7.2 writes no output for h-alt.docx (the main part under another name, prefixed package
relationships, the prefix x) or h-deflt.docx (media type from a Default element, an absolute target, no
prefix); I did not find which feature stops it. Their expected text
is derived by hand from the clauses and checked against the rules above line by line.
The expat oracle and the XML refusals: expat refuses 51 of the 56 XML refusal fixtures too. The other five
are rules of this reader: a document type declaration (rx-doctype, rx-doctype-ext: ECMA-376 Part 2
6.2.5 b forbids DTDs in package XML), an encoding other than UTF-8 or UTF-16 (rx-latin1: Part 2 6.2.5 a),
UTF-16 without a byte order mark (rx-utf16-nobom: XML 1.0 4.3.3 requires it) and version 1.1
(rx-version11). Expat also accepts the six one-past-the-bound files. Its verdict
on each is in corpus/refuse/ORACLE.txt.
Exit codes
| code | meaning | cases |
|---|---|---|
| 0 | done | |
| 1 | usage: unknown command or wrong arguments | ru-* |
| 2 | cannot open the file | rz-no-file |
| 3, 4 | read error, write error | |
| 10..22, 30..32, 40..53 | the zip engine (omega-zip README "Exit codes"): input ends early, bad Huffman codes, distance too far back, output above the bound, not a zip file (40), ZIP64 (41), split archive (42), encrypted entry (43), method other than stored or deflated (44), local header disagrees (46), CRC-32 mismatch (47), entry above 1 GiB (48), malformed central directory (50), entries overlap, a possible zip bomb (51), size mismatch (52, 53) | rz-not-zip, rz-empty, robustness |
| 60 | not well-formed XML (XML 1.0 productions: tags, attributes, references, comments, CDATA, PIs, content outside the root, ]]> in text) | rx-* |
| 61 | the XML ends before the document is complete (no root element, an open element or construct) | rx-truncated, rx-empty, rx-no-root, rx-comment-unclosed |
| 62 | an end tag does not match its start tag | rx-mismatch, rp-mismatch |
| 63 | bad UTF-8 (tx_u8st: overlong, surrogate, above U+10FFFF, stray or missing continuation), bad UTF-16 (lone surrogate, odd length), no byte order mark before UTF-16, a C0 control other than tab, LF and CR, or U+FFFE, U+FFFF (XML 1.0 2.2) | rx-utf8-, rx-utf16-, rx-control, rx-fffe |
| 64 | the XML declaration names an encoding other than that of the input, or a version other than 1.0 | rx-latin1, rx-utf16-declared, rx-version11 |
| 65 | a document type declaration: refused outright, so no entity beyond the five predefined ones exists and nothing is ever expanded or fetched (ECMA-376 Part 2 6.2.5 b) | rx-doctype, rx-doctype-ext, rp-doctype |
| 66 | an entity other than amp lt gt quot apos, or a character reference to a character XML 1.0 does not allow (0, surrogates, U+FFFE, U+FFFF, above U+10FFFF) | rx-entity, rx-cref*, rp-entity |
| 67 | namespace error (Namespaces in XML 1.0): an undeclared prefix, xmlns:p="", the prefix xmlns declared or used on an element, xml bound elsewhere or another prefix bound to its URI, a name with two colons or a colon at either end, a prefix or local part that is not an NCName (p:1x) | rx-ns-*, rp-prefix, rp-localdigit |
| 68 | duplicate attribute, by name or by namespace URI and local name | rx-dup-* |
| 70 | a name longer than 256 bytes | rb-name257 |
| 71 | more than 256 attributes on one element | rb-attr257 |
| 72 | attribute names and values of one start tag above 262144 bytes | rb-abytes |
| 73 | elements nested deeper than 1024 | rb-depth1025 |
| 74 | more than 4095 namespace declarations in scope, or above 262144 bytes of their prefixes and URIs | rb-ns4096 |
| 75 | an entity or character reference longer than 32 bytes between & and ; | rb-ref33 |
| 80 | not a package of the asked kind: no package relationships part, no relationship of type officeDocument, or the media type of the main part is not that of a word processing document (text) or a workbook (csv, sheets) | rp-norels, rp-notype, rp-ctype, rp-text-on-xlsx, rp-csv-on-docx, rp-sheets-on-docx |
| 81 | a part the package names is missing (the main part, the Media Types stream, a worksheet, the shared strings), or the sheet's relationship id is not in the workbook's Relationships part | rp-nomain, rp-noct, rq-*miss, rq-norel |
| 82 | a relationship target that is not a part name in this package: TargetMode External, a scheme, an empty or dot-ending segment, a directory, ?, #, \, a percent-encoded / or \, above 4095 bytes | rp-external, rp-scheme, rp-trailing, rp-pctslash |
| 83 | no sheet with that name or position | rq-nosheet* |
| 84 | the chosen sheet's relationship is not of type worksheet (a chartsheet, dialogsheet, ...) | rq-chart* |
| 85 | shared strings above 1048576 items or 16777216 bytes, or one cell's text above 16777216 bytes | rq-sstmany |
| 86 | a shared string index that is not a decimal below the number of items | rq-sst* |
| 87 | a cell or row reference that is malformed (lowercase, no row), out of range (column above XFD = 16384, row 0 or above 1048576), not ascending, or a cell reference whose row is not its row's | rq-ref*, rq-order, rq-roworder, rq-rowmis |
| 88 | a cell type other than those of ST_CellType, or a boolean that is not 0 or 1 | rq-type, rq-bool |
| 89 | a malformed package part: a wrong root element (Relationships, Types, workbook, sst, worksheet), a required attribute missing (Id, Type, Target; Extension, PartName, ContentType; sheet name and r:id), an unknown TargetMode, a media type or relationship id above 1024 bytes | rp-relsroot, rp-ctroot, rp-notarget, rp-badmode, rq-noid, rq-wbroot, rq-wsroot |
A trap (exit 101..114) would be a defect: the gate fails on one.
Bounds, and what happens at each
Nothing holds a whole part: the zip engine inflates a part 32 KiB at a time into the XML reader, which keeps only the tag being read and the open elements. Globals: 64,116 bytes from omega-zip, then the reader (1,095,268 bytes: a 256 KiB attribute pool, 256 KiB open-element names, 256 KiB namespace bytes, a 64 KiB text buffer), the output and file buffers (131,112 bytes), the package (26,880 bytes), the shared string table (16 MiB pool and 8 MiB of offsets) and one cell value (16 MiB): 43,265,936 bytes (41.26 MiB, computed by Wolfram from the declarations) in all; the compiler allows 1 GiB of globals and 16,777,216 elements per array (OMEGESE.md, Size limits). Like omega-zip, this is a streaming tool and is not a profiled unit: its loop bounds exceed the profile's 8192 and its globals the profile's 65,536 bytes (rule B3), by the lane's decision.
| bound | value | at the bound |
|---|---|---|
| element, attribute, end-tag or PI-target name | 256 bytes | refused, 70 |
| attributes on one element | 256 | refused, 71 |
| attribute names and values of one start tag | 262144 bytes | refused, 72 |
| element nesting | 1024 | refused, 73 |
| namespace declarations in scope | 4095 (4096 bindings with xml), 262144 bytes | refused, 74 |
| one entity or character reference | 32 bytes between & and ; | refused, 75 |
| the XML declaration | 512 bytes | refused, 60 |
| character data | none: delivered in 64 KiB pieces | |
| part names, relationship targets | 4095 bytes (merged path 8191) | refused, 82 |
| media type, relationship id | 1024 bytes | refused, 89 |
| shared strings | 1,048,576 items, 16,777,216 bytes of text | refused, 85 |
| one cell value (inline string or v) | 16,777,216 bytes | refused, 85 |
| columns, rows | XFD (16384), 1048576 | refused, 87 |
| zip entry, entries, names | 1 GiB, 65535, 4095 bytes (omega-zip) | 48, 41 (ZIP64), 45 |
plain XML file for xmlev | 64 TiB (1,000,000,000 reads of 64 KiB) | a trap would follow; not reachable in practice |
What it reads, and what it does not
text (ECMA-376 Part 1, WordprocessingML):
- Reads
document/body(17.2.3, 17.2.2): the character data of everyt(17.3.3.31) that is a child of a runr(17.3.2.25), anywhere in the body: in paragraphsp(17.3.1.22), hyperlinks (17.16.22), inserted runsins(17.13.5.18), moved-to runsmoveTo(17.13.5.25), content controlssdt(17.5.2.29 to 17.5.2.36), smart tags and custom XML (17.5.1), simple fields (17.16.19), and the result runs of complex fields (17.16.18). - In a run:
tab(17.3.3.32) andptab(17.3.3.23) print a tab;br(17.3.3.1) of type textWrapping or with no type andcr(17.3.3.4) print a line end, while page and column breaks print nothing;noBreakHyphen(17.3.3.18) prints U+2011,softHyphen(17.3.3.29) prints U+00AD. - A paragraph ends with LF; an empty paragraph is an empty line.
- Tables
tbl(17.4.37): each rowtr(17.4.78) is one line, the cellstc(17.4.65) separated by a tab. Inside a table, the paragraphs of one cell, and tabs and breaks, are separated by a space. A nested table's cells are joined into its outer cell with spaces. - Markup compatibility (ECMA-376 Part 3): in
AlternateContenttheFallbackis read and everyChoiceis skipped, since no Choice namespace is understood here. - Not printed: deleted runs
del(17.13.5.14) with theirdelText(17.3.3.7), moved-from runsmoveFrom(17.13.5.22); field codesinstrText(17.16.23) anddelInstrText(17.16.13); ruby textrt(17.3.3.24), whose base text is printed; drawings, VML pictures and embedded objects (drawing17.3.3.9,pict,object17.3.3.19) with any text box inside them;sym(17.3.3.30); all properties (pPr,rPr,sectPr,tblPr,tblPrEx,tblGrid,trPr,tcPr,sdtPr,sdtEndPr); footnote and endnote reference marks; list and heading labels. - Not read at all: footnotes, endnotes, comments, headers and footers (separate parts), the numbering and styles parts, the glossary document.
- Deleted text, decided: it is not printed. The standard says
delcontent "shall be treated as deleted content which has been tracked as a revision" (17.13.5.14), and moved-from content as "moved away from this location" (17.13.5.22). I print the document as it reads with its revisions accepted.
csv, sheets (ECMA-376 Part 1, SpreadsheetML):
- The workbook (18.2.27):
sheets(18.2.20) lists eachsheet(18.2.19) with itsnameandr:id. The worksheet and the Shared String Table are found through the workbook's Relationships part by relationship type (worksheet, sharedStrings), never by a fixed name. - Shared String Table (18.4.9): an item
si(18.4.8) is the text of itst(18.4.12), directly or in rich text runsr(18.4.4); phonetic runsrPh(18.4.6) are not part of the value. The whole table is held, up to its bound (above, 85). - Worksheet (18.3.1.99):
sheetData(18.3.1.80), rowsrow(18.3.1.73), cellsc(18.3.1.4). A cell is placed by its referencer, and follows the previous cell whenris absent (rows likewise); rows and cells must ascend (87). - A cell's value is
v(18.3.1.96), oris(18.3.1.53) for an inline string. Its typet(18.18.11 ST_CellType) is used as follows:n(the default) anddprint the stored text;sprints that shared string;str(a formula string) ande(an error such as#DIV/0!) print the stored text;inlineStrprints the inline string;bprintsTRUEorFALSE. Numbers are printed as written in the file, never reformatted. - Dates are stored as numbers (a serial day count) in cells with a date format, and I print that number. Turning it into a date needs the number format in the styles part: the next slice.
- Strings are ST_Xstring (22.9.2.19):
_xHHHH_is decoded on output (a surrogate pair of escapes is one character;_x005F_is an underscore). - The output is rows 1 to the last row that holds a value, each with fields 1 to the last column that
holds a value, so empty cells and rows are preserved and every record has the same number of fields. A
cell holds a value when it has
voris; a formula without a storedv, or a styled empty cell, holds none. RFC 4180: a field with a comma, a quote, CR or LF is quoted with quotes doubled (2.6, 2.7), and records end with CR LF (2.1). - The sheet is read twice: once for the last row and column, once to print.
- Not read: styles and number formats, formulas (only their stored results), hidden state (hidden sheets are listed and printed like any other), merged cells (the value is in the first cell), comments, tables, pivot tables, charts, external links, the dimension element.
Package (ECMA-376 Part 2, Open Packaging Conventions, 5th edition):
- The package Relationships part
_rels/.rels(6.5.2.2) names the main part (relationship type officeDocument, Transitional or Strict URI). - Its media type comes from the Media Types stream
[Content_Types].xml(7.2.3, 7.3.7): anOverridefor the part name, else aDefaultfor its extension. It must be the main part of a word processing document or template, or of a workbook or template (the media types of ECMA-376 Part 1). The part must exist before its media type is checked. - A part's own Relationships part is
_rels/NAME.relsbeside it (6.5.2.3). - A target is resolved against its source part (6.4.2, RFC 3986 5.2): dot segments are removed, and a
leading
/is relative to the package root. - The result is mapped to a ZIP item name (7.3.4): the leading
/removed, every non-ASCII byte percent-encoded. - Part names and extensions compare ASCII case-insensitively (6.2.2.3); relationship types compare exactly (6.5.3.4); media types compare ASCII case-insensitively (RFC 7231 3.1.1.1).
- Transitional and Strict namespaces are both read.
- Not supported: macro-enabled and other vendor media types (
.docm,.xlsm,.xlsbare refused with 80), percent-decoding of part names, interleaved parts (7.2.4), digital signatures (not checked), and a main part named only by a non-ASCII Override part name.
XML (W3C XML 1.0 Fifth Edition, Namespaces in XML 1.0 Third Edition):
- Elements, attributes, character data, the five predefined entities, decimal and hexadecimal character references, CDATA sections (their text), comments and processing instructions (skipped), one XML declaration at the start (version 1.0; encoding, when named, that of the input; standalone yes or no).
- Input is UTF-8, with or without a byte order mark, or UTF-16 with a byte order mark (big- or little-endian, surrogate pairs), turned into UTF-8.
- Line ends are normalised (2.11). In attribute values, a literal tab or line end becomes a space (3.3.3); a character reference stays as written.
- Names are checked against the Fifth Edition NameStartChar and NameChar ranges (2.3). The non-ASCII names
in the corpus (U+00E9, U+4E2D, U+5B50, U+00B7, and after a colon U+0416, U+0905, U+30A2) are accepted by
both readers; I did not compare the two readers range by range. One difference is known: a name with a
character at or above U+10000 (
<U+10000/>, or the local part ofa:U+10000) is accepted here, as the Fifth Edition allows, and refused by expat 2.6.1 (invalid token); no gate case covers it, so the four-byte branch of the check after a colon has no oracle case. - Namespace prefixes resolve from the declarations in scope, and the handlers compare namespace URIs, never
prefixes. A prefix and a local part are each an NCName (Namespaces 1.0 sections 3 and 4): the character
after the colon must be a NameStartChar, so
p:1x,p:-x,p:.x,p:U+00B7xandxmlns:1pare 67. - Not supported: DTDs (65), entities other than the five, encodings other than UTF-8 and UTF-16, XML 1.1,
colons in PI targets are not checked (Namespaces 1.0 section 7), and the
xml:spaceandxml:baseattributes have no effect.
Measured speed
MEASURED 2026-11-10T06:16:45Z to about 06:19Z on the Spark (DGX Spark GB10, Linux AArch64), one core:
taskset -c 10 inside the pool-10 ticket, nice 10, load average 18 to 22 on 20 cores. Times are from
/usr/bin/time (0.01 s resolution), using the binary the gate built (sha256 0b3fea09...c83ad7d5,
then named ooffice; not re-measured since), 3 runs
each with the same output bytes every time. Rates are by Wolfram from the median time. The inputs are made by
build/mkcases DIR big and packed with zip -X -6; they are not committed.
| command | input | median time (runs) | rate |
|---|---|---|---|
officeread text big.docx | 600000 paragraphs: a 109,689,060-byte (104.61 MiB) main part, 1,841,266 bytes zipped | 8.19 s (8.17, 8.19, 8.23) | 12.77 MiB/s of WordprocessingML; 57,488,890 bytes of text out |
officeread csv big.xlsx | 400000 rows of five cells: an 86,445,114-byte (82.44 MiB) sheet, read twice, and 1000 shared strings; 11,379,691 bytes zipped | 20.13 s (19.70, 20.13, 20.23) | 4.10 MiB/s of sheet (8.19 MiB/s of XML read over the two passes); 21,311,575 bytes of CSV out |
officeread xmlev big-document.xml | the same main part as a plain file | 19.96 s (19.95, 19.96, 19.98) | 5.24 MiB/s in; 573,489,174 bytes of events out (27.40 MiB/s) |
Where the time goes. I measured this with stub builds on a 20,018,876-byte part, before the last speed-ups:
inflate alone took 0.40 s, and the XML reader the rest. Printable ASCII in text, names and attribute values is
stored inline; every other byte goes through a chain of calls, and every element through its namespace
resolution and handler. That per-element work sets the rate, which is why a sheet (many small elements) reads
slower than a document. The first build took 21.94 s on the same text input. A typical document part (under
1 MB) takes well under 0.1 s.
Standards followed
- ECMA-376 Part 1, 5th edition (December 2016): Fundamentals and Markup Language Reference, the clauses named above (WordprocessingML 17, SpreadsheetML 18, ST_Xstring 22.9.2.19).
- ECMA-376 Part 2, 5th edition (December 2021): Open Packaging Conventions, 6.2.2, 6.2.5, 6.4, 6.5, 7.2.3, 7.3.4, 7.3.7.
- ECMA-376 Part 3: Markup Compatibility and Extensibility (AlternateContent, Choice, Fallback).
- W3C Extensible Markup Language (XML) 1.0, Fifth Edition: 2.2, 2.3, 2.4, 2.5, 2.6, 2.8, 2.11, 3.3.3, 4.1, 4.3.3, 4.6, appendix F.
- W3C Namespaces in XML 1.0, Third Edition: sections 3 to 6.
- RFC 4180 (CSV), RFC 3986 section 5.2 (resolving a relative reference), RFC 7231 3.1.1.1 (media types).
- The zip, inflate and CRC-32 standards of omega-zip: RFC 1951, the PKWARE APPNOTE 6.3.10, ISO 3309 / ITU-T V.42.
I read the standards' text (the Ecma downloads, on the Spark, not in this repository) and no other program's source; the tools named above were only run as oracles on files of this corpus.
Reuse of omega-zip, and decisions recorded
vendor/omega-zip/holds omega-zip at 231dd336:src/crc32.om,src/inflate.om,src/zlibd.om,src/unzip.om,src/io.omand its copy of omega-mvseed/text/text.om, all byte-identical (sha256 invendor/omega-zip/PIN), with no patch.- The output seam is omega-zip's own: io.om's
wflushrunsw = wout nwith the windowwin[0 .. n), and the program definesfn wout n ulong to ulong, returning n (ozip'ssrc/main.ompasses the window towoutfd, the output descriptor). Omega has no imports and one namespace, so the program that includes io.om supplies the onewout: heresrc/sink.om, the consumer of each inflated window. The call is an assignment so that a build withoutwoutis refused by omc (error 3); a barewout nwould compile as the assignmentwout = nand drop every byte. Before omega-zip d0490914 the seam was a one-line rename carried here asvendor/omega-zip/sink.patch(in this repository's history). src/zlibd.omis vendored with the others by the lane's decision; nothing in officeread calls it (not in the build), and it is kept for the next slice (PDF streams are zlib).- Memory: like omega-zip, officeread streams and is not a profiled unit; the profile's 65,536-byte total does not apply to it (the lane's decision). Every bound is stated above with its refusal.
- The zip engine's own refusals keep its
ozip:prefix and its codes; mine start at 60.
Files
src/: the units (head,xml,sink,opc,docx,xlsx,main).vendor/omega-zip/: S1, pinned and unchanged (PIN).tests/gate.om,tests/cases.txt,tests/mutants.txt,tests/mkcases.om;tests/docs.omwithtests/docrules.txtandtests/docmutants.txt(publication checks, run by the gate).corpus/: sources, packages, refusal fixtures, oracle outputs; provenance and licences incorpus/SOURCES.txt.
Licence
Apache-2.0 (LICENSE, NOTICE). corpus/docx/letter.docx is made from a LibreOffice template, MPL-2.0,
test data only (corpus/SOURCES.txt).