Skip to content

DOCX export serializes w:numPr children in schema-invalid order #3871

Description

@StephanMeijer

What happened?

After importing a nested Markdown list and exporting it as DOCX, SuperDoc writes w:numPr children as:

<w:numPr>
  <w:numId w:val="3"/>
  <w:ilvl w:val="0"/>
</w:numPr>

ECMA-376 requires w:ilvl before w:numId. Part 1 §17.3.1.19 shows that order. CT_NumPr is defined identically in Part 1 Annex A.1 (Strict) and in the Transitional wml.xsd shipped with Part 4:

<xsd:complexType name="CT_NumPr">
  <xsd:sequence>
    <xsd:element name="ilvl" type="CT_DecimalNumber" minOccurs="0"/>
    <xsd:element name="numId" type="CT_DecimalNumber" minOccurs="0"/>
    <xsd:element name="numberingChange" type="CT_TrackChangeNumbering" minOccurs="0"/>
    <xsd:element name="ins" type="CT_TrackChange" minOccurs="0"/>
  </xsd:sequence>
</xsd:complexType>

Because this is an xsd:sequence, the exported order is schema-invalid. The use of different numId values for nested levels is a separate concern and is not the subject of this report.

Steps to reproduce

  1. Import Markdown containing a nested list, for example:
    - Fruits
      - Apples
  2. Export the document as DOCX.
  3. Inspect the result:
    unzip -p exported.docx word/document.xml | xmllint --format -
  4. Observe that each w:numPr contains w:numId before w:ilvl.

Expected behavior

SuperDoc should serialize w:numPr in schema order:

<w:numPr>
  <w:ilvl w:val="0"/>
  <w:numId w:val="3"/>
</w:numPr>

SuperDoc version

1.45.2

Additional context

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions