I'm building a DocX document essentially from scratch with XML. I have a very simple goal: create a bullet-point list, like a ul
in HTML. Reading the WordProcessingML specification for numbered lists (section 2.9), I created what I thought would satisfy this. Here's what my numbering.xml
looks like:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:numbering xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:mo="http://schemas.microsoft.com/office/mac/office/2008/main" xmlns:mv="urn:schemas-microsoft-com:mac:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing">
<w:abstractNum w:abstractNumId="1">
<w:multiLevelType w:val="singleLevel"/>
<w:lvl w:ilvl="0">
<w:start w:val="1"/>
<w:numFmt w:val="bullet"/>
<w:lvlText w:val="•"/>
<w:lvlJc w:val="left"/>
<w:pPr>
<w:tabs>
<w:tab w:pos="360" w:val="num"/>
</w:tabs>
<w:ind w:hanging="360" w:left="360"/>
</w:pPr>
<w:rPr>
<w:rFonts w:ascii="Symbol" w:hAnsi="Symbol" w:hint="default"/>
</w:rPr>
</w:lvl>
</w:abstractNum>
<w:num w:numId="1">
<w:abstractNumId w:val="1"/>
</w:num>
</w:numbering>
So I have an abstract numbering with id 1, defined with a single level with some indentation and a bullet as the lvlText (the symbol •
renders as •
). The abstract numbering of 1 is referenced by the "actual" numbering of 1.
And here's what my document.xml
looks like:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:mo="http://schemas.microsoft.com/office/mac/office/2008/main" xmlns:mv="urn:schemas-microsoft-com:mac:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing">
<w:body>
<w:p w:rsidR="00851CFD" w:rsidRDefault="00851CFD">
<w:r>
<w:t>This is a test</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:numPr>
<w:ilvl w:val="0"/>
<w:numId w:val="1"/>
</w:numPr>
</w:pPr>
<w:r>
<w:t>foo</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:numPr>
<w:ilvl w:val="0"/>
<w:numId w:val="1"/>
</w:numPr>
</w:pPr>
<w:r>
<w:t>bar</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:numPr>
<w:ilvl w:val="0"/>
<w:numId w:val="1"/>
</w:numPr>
</w:pPr>
<w:r>
<w:t>baz</w:t>
</w:r>
</w:p>
<w:sectPr w:rsidR="008E365B" w:rsidSect="008E365B">
<w:pgSz w:h="15840" w:w="12240"/>
<w:pgMar w:bottom="1440" w:gutter="0" w:left="1800" w:right="1800" w:top="1440"/>
</w:sectPr>
</w:body>
</w:document>
There's an initial paragraph, and then three lines that specify a numId
of 1
(pointing at the numbering we defined earlier), and an indentation level of 0. So what we should get is something like:
This is a test
- foo
- bar
- baz
But when I open this in microsoft word, it instead renders (roughly) as
This is a test
- foo
- bar
- baz
And when I open it in Google Docs, it simply renders the text:
This is a test
foo
bar
baz
It really seems like I'm following the specification laid out in the standard. I don't know what piece I'm missing. Why do the bullets not get rendered? What can I do here?
Override
element to[Content_Types].xml
or else it would complain at me:<Override PartName="/word/numbering.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml"/>
– Bevel