- Code: Select all
public static void main(String[] args) throws Exception {
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
MainDocumentPart mdp = wordMLPackage.getMainDocumentPart();
StyleDefinitionsPart sdp = new StyleDefinitionsPart();
sdp.unmarshalDefaultStyles();
mdp.addTargetPart(sdp);
Styles styles = sdp.getJaxbElement();
java.util.List<Object> nodeList = mdp.getJAXBNodesViaXPath("//styles/style",styles,false);
for (int i = 0; i < nodeList.size(); i++) {
Style style = (Style) nodeList.get(i);
String styleId = style.getStyleId();
System.out.println(styleId);
}
}
What the code is suppose to do is create a StylesDefinitionsPart, ...