https://bugs.documentfoundation.org/show_bug.cgi?id=174364
Bug ID: 174364
Summary: FILEOPEN OOXML: package fails to load when
[Content_Types].xml or _rels/.rels uses a namespace
prefix
Product: LibreOffice
Version: 26.8.2.2 release
Hardware: ARM
OS: macOS (All)
Status: UNCONFIRMED
Severity: normal
Priority: medium
Component: filters and storage
Assignee: [email protected]
Reporter: [email protected]
Created attachment 209575
--> https://bugs.documentfoundation.org/attachment.cgi?id=209575&action=edit
zip holding the three test files
(disclaimer: this report was generated by Claude Opus 5.5, triggered by me
diagnosing an LLM-generated file not opening properly in Libreoffice)
LibreOffice cannot open OOXML files (DOCX, PPTX, ...) when the OPC package
parts [Content_Types].xml or _rels/.rels use a namespace prefix instead of the
default namespace. For example:
<ns0:Types
xmlns:ns0="http://schemas.openxmlformats.org/package/2006/content-types">
<ns0:Default Extension="rels" ContentType="..."/>
...
</ns0:Types>
This is valid XML and valid OPC: element identity depends on the namespace URI,
not the prefix. Python's xml.etree.ElementTree writes this form by default, so
files from tools that rewrite these parts with ElementTree are affected
(python-pptx/python-docx post-processing, LLM-generated documents, ...).
Microsoft PowerPoint (web) and Google Slides open such files without problems.
LibreOffice and Collabora Office fail.
Steps to reproduce:
1. Unzip the attached prefixed-content-types.docx and prefixed-rels.docx. They
are identical to ok.docx, except that one part uses an "ns0:" prefix.
2. Open each file in LibreOffice, or run:
soffice --headless --convert-to pdf <file>
Actual results:
- ok.docx: opens and converts.
- prefixed-content-types.docx: "Error: source file could not be loaded".
- prefixed-rels.docx: same error.
Expected results:
All three files open, because they are equivalent in terms of XML namespaces.
Likely cause:
comphelper/source/xml/ofopxmlhelper.cxx (OFOPXMLHelper_Impl::startElement)
uses a SAX handler that does not resolve namespaces. It compares the raw
qualified name with the literal strings "Types", "Default", "Override",
"Relationships" and "Relationship", and throws a SAXException for any other
name. The parser should resolve namespaces and compare
(namespace URI, local name) pairs instead. A FastParser with registered
namespace tokens would do this.
Prefixes in other parts, such as ppt/presentation.xml or
ppt/_rels/presentation.xml.rels, are handled correctly, because oox parses
those parts with a namespace-aware parser.
Related: an external workaround for the same problem with python-docx output:
https://github.com/NVIDIA-NeMo/Gym/pull/1270
--
You are receiving this mail because:
You are the assignee for the bug.