Create an abstract list. Easiest to do this by defining a list in Word, then using the docx4j webapp to generate corresponding code. (Navigate to the numbering definitions part)
Once you have your abstract list, you can create a simple concrete list (ie one which just points at the abstract list):
Using java Syntax Highlighting
concreteList
= ndp.
addAbstractListNumberingDefinition(abstractList
)
Parsed in 0.014 seconds, using
GeSHi 1.0.8.4
Here is that method:
Using java Syntax Highlighting
/**
* Add the specified definition, allocating it a new w:abstractNumId.
*
* Also create and add an associated ListNumberingDefinition, and return
* this associated ListNumberingDefinition (since that is
* what you are likely to use in the document).
*
* @param abstractNum
* @return
*/
public Numbering.
Num addAbstractListNumberingDefinition
(Numbering.
AbstractNum abstractNum
) {
//////////////////////////////////////////////
// Numbering.AbstractNum abstractNum
// Generate a unique w:abstractNumId for it
int nextId
= getAbstractListDefinitions
().
size();
do {
nextId
++;
} while (getAbstractListDefinitions
().
containsKey( "" + nextId
));
abstractNum.
setAbstractNumId( BigInteger.
valueOf(nextId
) );
// Add it to our JAXB object
this.
getJaxbElement().
getAbstractNum().
add(abstractNum
);
// Add it to our hashmap
AbstractListNumberingDefinition absNumDef
= new AbstractListNumberingDefinition
(abstractNum
);
abstractListDefinitions.
put(absNumDef.
getID(), absNumDef
);
//////////////////////////////////////////////
// Numbering.Num num
// Now make an associated ListNumberingDefinition
// <w:num w:numId="1">
// <w:abstractNumId w:val="1"/>
// </w:num>"
Numbering.
Num num
= Context.
getWmlObjectFactory().
createNumberingNum();
Numbering.
Num.
AbstractNumId abstractNumId
= Context.
getWmlObjectFactory().
createNumberingNumAbstractNumId();
abstractNumId.
setVal(BigInteger.
valueOf(nextId
) );
num.
setAbstractNumId(abstractNumId
);
nextId
= getInstanceListDefinitions
().
size();
do {
nextId
++;
} while (getInstanceListDefinitions
().
containsKey( "" + nextId
));
num.
setNumId( BigInteger.
valueOf(nextId
) );
// Add it to our JAXB object
this.
getJaxbElement().
getNum().
add(num
);
// Add it to our hashmap
ListNumberingDefinition listDef
= new ListNumberingDefinition
(num, abstractListDefinitions
);
instanceListDefinitions.
put(listDef.
getListNumberId(), listDef
);
//
return num
;
}
Parsed in 0.017 seconds, using
GeSHi 1.0.8.4
Notice it returns Numbering.Num. That gives you the num id you need to add in your w:p/w:pPr/w:numPr