List of usage examples for org.jdom2 Parent addContent
public Parent addContent(int index, Collection<? extends Content> c);
From source file:org.kdp.word.transformer.FootnodeTransformer.java
License:Apache License
@Override public void transform(Context context) { Map<String, Footnode> footnodes = new LinkedHashMap<>(); Element root = context.getSourceRoot(); for (Element el : root.getChildren()) { findFootnodes(context, el, footnodes); }//from w w w . ja v a 2s . co m JDOMFactory factory = context.getJDOMFactory(); for (Footnode fn : footnodes.values()) { // Footnode Ref Element fnref = fn.fnref; String text = getFootnodeText(fnref); Parent parent = fnref.getParent(); int index = parent.indexOf(fnref); parent.removeContent(index); Element span = factory.element("span"); span.setAttribute("class", "MsoFootnoteReference"); Element a = fnref.clone(); a.removeContent(); a.setText(text); //a.setAttribute("type", "noteref", OPFTransformer.NS_OPF); span.addContent(a); parent.addContent(index, span); /* Footnode Text Element fntxt = fn.fntxt; Element p = findMsoFootnoteText(fntxt); text = getFootnodeText(p); p.getAttributes().clear(); p.removeContent(); p.setText(text); String divid = fn.id.substring(1); Element div = JDOMUtils.findElement(root, "div", "id", divid); IllegalStateAssertion.assertSame(p.getParentElement(), div, "Unexpected parent: " + div); Parent divparent = div.getParent(); Element aside = factory.element("aside"); aside.setAttribute("type", "footnote", OPFTransformer.NS_OPF); aside.setAttribute("id", fn.id); index = divparent.indexOf(div); divparent.removeContent(div); aside.addContent(p.clone()); divparent.addContent(index, aside); */ } }