moonbitlang/ooxml is a peer module in the root moon.work. It ownsformat-independent OPC packaging and XML support, below the document engines.
opc: named parts, content types, relationships, cloning, and ZIP input/outputthrough moonbit-community/flate@0.9.0.
uri: logical/physical part-name conversion, conflict detection, and relationshipURI rules extracted from DOCX. Percent encoding and Unicode decoding usemoonbitlang/core/encoding/percent, with OPC-specific escape handling retained. docx2html/opc re-exports its existing publicentry points; PPTX package relationship paths use the same implementation.
xml: QName, extension-tree storage, reader events, and XML writing. Readinguses Milky2018/xml@0.5.0's namespace-aware pull parser. The adapter expandsempty elements and coalesces entity-split text to keep document readers stable.
PPTX uses opc and xml directly. DOCX retains its document validation andbudget-aware XML layer. XLSX retains its cancellable, budget-aware scanner andpart-name registry; those contracts are not replaced by the PPTX adapter.
The reader rejects malformed XML, empty documents, and DOCTYPE declarations.It retains attribute order, expanded names, and CDATA, but does not preservecomments, processing instructions, namespace declaration spelling, or prefixesinside attribute values. It buffers the document; it is not an incrementalbyte-stream parser.
XmlWriter is a thin adapter over Milky2018/xml@0.5.0's checked writer.It resolves QNames and buffers incremental attributes until an element can beemitted. The backend owns escaping, XML output, and document validation; errorsmap to XmlError::WriterMisuse. Attribute whitespace survives round trips.xml_declaration() now raises XmlError for repeated or misplaced declarations.Missing roots, multiple roots, invalid XML characters, and duplicate attributesare rejected; pending attributes are validated when their start tag is emitted.
Package::to_bytes() raises OpcError for ZIP write failures. Package::open()currently uses flate's default read policy; this alone does not introduce packageresource limits. Unchanged part payloads survive a package round trip; ZIPcompression bytes and metadata are not promised to remain identical.
Run from the repository root:
moon test ooxml/opc ooxml/xml ooxml/uri --target native --deny-warn
The OPC container and XML model/writer originated in the PPTX import. Seeprovenance and the retained Apache-2.0 license.