The DOCX spec has some pretty convoluted paths to determining the formatting of an object. But this one may be the ultimate in complexity. Take a look at paragraphs 3 & 4 in this document.
How is this set? Well…
First, look at document.xml and the entire paragraph xml. We can see the numPr element with a numId of 7.
Second, knowing the numId, we then look at numbering.xml near the bottom and find the abstractNumId that it maps to.
Third, within the same file, locate the abstractNum definition with that abstractNumId and find the numStyleLink value.
Fourth, and this is the non-obvious part – with the numStyleLink value, go to styles.xml and find the numbering style with that styleId. This style has another numPr element with a numId value.
Fifth, go back to numbering.xml and find the abstractNumId that the numId maps to.
Sixth, find the abstractNum definition that it points to. Take note of the lvlText and color elements.
Key to the above is the referencing in numbering styles:
L.1.10.8 Referencing Numbering Styles
To use a numbering style in a document, the paragraph properties for one or more paragraphs again specify a numPr element, which references a numbering definition instance via the numId element. The numbering definition instance itself again specifies an inherited abstract numbering definition via the abstractNumId element.
At this stage, the abstract numbering definition specifies that it is based on a numbering style via either of the following:
- The abstract numbering style contains no level data, and simply specifies a reference to the numbering style’s styleId attribute via the numStyleLink element.
- The abstract numbering style contains the numbering level information for the numbering style, and specifies that it is the basis for the numbering style by referencing the numbering style’s styleId attribute via the styleLink element.
Major thanks to Tarun Chopra & Josh Curry who helped me find this. And if you’re wondering why Windward is so much work to make everything come out right, the DOCX spec is more than 4,000 pages of rules like this.
Author: David Thielen
Dave, Windward's founder and CEO, is passionate about building superb software teams from scratch and dramatically improving the productivity of existing software teams. He's really proud that he once created a game so compelling (Enemy Nations) that a now-professional World of Warcraft player lost his job for playing it incessantly on company time. You can read more from Dave on his personal blog, and at Huffington Post.
Other posts by David Thielen