Sign in

    ooxml

    Shared OPC packaging and XML support for office.mbt

    ooxml
    opc
    office
    Download zip
    Version
    0.1.0
    License
    Apache-2.0
    Last updated
    10 days ago
    Downloads
    4K

    #Office OOXML foundations

    moonbitlang/ooxml is a peer module in the root moon.work. It owns format-independent OPC packaging and XML support, below the document engines.

    • opc: named parts, content types, relationships, cloning, and ZIP input/output through moonbit-community/flate@0.9.0.
    • uri: logical/physical part-name conversion, conflict detection, and relationship URI rules extracted from DOCX. Percent encoding and Unicode decoding use moonbitlang/core/encoding/percent, with OPC-specific escape handling retained. docx2html/opc re-exports its existing public entry points; PPTX package relationship paths use the same implementation.
    • xml: QName, extension-tree storage, reader events, and XML writing. Reading uses Milky2018/xml@0.5.0's namespace-aware pull parser. The adapter expands empty elements and coalesces entity-split text to keep document readers stable.

    PPTX uses opc and xml directly. DOCX retains its document validation and budget-aware XML layer. XLSX retains its cancellable, budget-aware scanner and part-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 preserve comments, processing instructions, namespace declaration spelling, or prefixes inside attribute values. It buffers the document; it is not an incremental byte-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 be emitted. The backend owns escaping, XML output, and document validation; errors map 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 attributes are 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 package resource limits. Unchanged part payloads survive a package round trip; ZIP compression 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. See provenance and the retained Apache-2.0 license.

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io