/** Marshal to a String */ public static String marshaltoString(Object o, boolean suppressDeclaration, boolean prettyprint ) { JAXBContext jc = Context.jc; return marshaltoString(o, suppressDeclaration, prettyprint, jc ); }
/** * Use the specified JAXBContext to marshal this object to a String, pretty printed, and without an XML declaration. * Useful for debugging. * * @param o * @return * @since 3.0.1 */ public static String marshaltoString(Object o, JAXBContext jc ) { return marshaltoString(o, true, true, jc ); }
/** * Marshal this object to a String, pretty printed, and without an XML declaration. * Useful for debugging. * * @param o * @return * @since 3.0.1 */ public static String marshaltoString(Object o ) { JAXBContext jc = Context.jc; return marshaltoString(o, true, true, jc ); }
/** Marshal to a String */ @Deprecated public static String marshaltoString(Object o, boolean suppressDeclaration, JAXBContext jc ) { return marshaltoString(o, suppressDeclaration, false, jc ); }
/** Marshal to a String */ @Deprecated public static String marshaltoString(Object o, boolean suppressDeclaration ) { JAXBContext jc = Context.jc; return marshaltoString(o, suppressDeclaration, false, jc ); }
private void addUnsafe(Object o, String uri, String local, Class declaredType) { // For now, we'll use marshalled content unsafeObjects.add(XmlUtils.marshaltoString(o, true, true, Context.jc, uri, local, declaredType)); }
private static void debug(WordXmlPictureE20 converter) { if (converter.inline!=null) log.error(XmlUtils.marshaltoString(converter.inline, true, true, Context.jc, "foo", "bar", Inline.class )); else log.error(XmlUtils.marshaltoString(converter.anchor, true, true, Context.jc, "foo", "bar", Anchor.class )); }
/** * See your content as XML. An easy way to invoke XmlUtils.marshaltoString * * @return * @since 3.0.0 */ public String getXML() { return XmlUtils.marshaltoString( getJaxbElement(), true, true, jc ); }
public String toString() { CTTypes types = buildTypes(); return XmlUtils.marshaltoString(types, true, true, Context.jcContentTypes); }
public boolean LevelExists(String level) { if (this.levels==null) { log.info("No levels present in abstractNumId"); if (getAbstractListDefinition()==null) { log.info("[missing]"); } else { log.info(XmlUtils.marshaltoString(getAbstractListDefinition())); } log.debug("referenced from "); log.debug(XmlUtils.marshaltoString(numNode)); return false; } return this.levels.containsKey(level); }
@Override protected List<Object> apply(Object child, Object parent, List siblings) { if (visitorClass==null) { log.warn("visitorClass==null for some element with parent " + parent.getClass().getName() ); //log.warn(XmlUtils.marshaltoString(parent)); } else if (child==null) { if(log.isWarnEnabled()) { log.warn("child==null for some element with parent " + parent.getClass().getName()); // eg <w:t/> log.warn(XmlUtils.marshaltoString(parent)); } } else if (visitorClass.isAssignableFrom(child.getClass())) { visitor.apply(child, parent, siblings); } return null; }
public void build(CTSimpleField fldSimple, Node content) throws TransformerException { this.fldSimple = fldSimple; if(log.isDebugEnabled()) { log.debug("\n" + XmlUtils.marshaltoString(fldSimple, true, true)); } this.content = content; setupNameParameterString(fldSimple.getInstr()); }
/** Combine complex fields to w:fldSimple * */ public static void process(WordprocessingMLPackage wmlPackage) { log.info("starting"); TraversalUtil.visit(wmlPackage, false, COMBINE_VISITOR); if (log.isDebugEnabled()) { log.debug(XmlUtils.marshaltoString(wmlPackage.getMainDocumentPart().getJaxbElement(), true, true)); } }
public static Templates generateLayoutTreeXSLT(CTDiagramDefinition pictureLayout) throws Exception { System.out.println(XmlUtils.marshaltoString(pictureLayout, true)); // System.out.println("Generating xslt.."); Source xsltSource = new StreamSource( org.docx4j.utils.ResourceUtils.getResource( "org/docx4j/openpackaging/parts/DrawingML/DiagramLayoutMeta.xslt")); Templates xsltMeta = XmlUtils.getTransformerTemplate(xsltSource); Document source = XmlUtils.marshaltoW3CDomDocument(pictureLayout, Context.jc); ByteArrayOutputStream intermediate = new ByteArrayOutputStream(); Result intermediateResult = new StreamResult(intermediate); XmlUtils.transform(source, xsltMeta, null, intermediateResult); String tmpXslStr = intermediate.toString("UTF-8"); System.out.println(tmpXslStr); return XmlUtils.getTransformerTemplate( new StreamSource(new StringReader(tmpXslStr))); }
public static void main(String[] args) throws Exception { boolean save=true; String inputfilepath = System.getProperty("user.dir") + "/sample-docs/word/unmarshallFromTemplateDirtyExample.docx"; WordprocessingMLPackage wmlPackage = WordprocessingMLPackage.load(new java.io.File(inputfilepath)); // Before .. note attributes w:rsidRDefault="00D15781" w:rsidR="00D15781" System.out.println(XmlUtils.marshaltoString(wmlPackage.getMainDocumentPart().getJaxbElement(), true, true)); prepare(wmlPackage); System.out.println(XmlUtils.marshaltoString(wmlPackage.getMainDocumentPart().getJaxbElement(), true, true)); // Save it if (save) { SaveToZipFile saver = new SaveToZipFile(wmlPackage); saver.save(System.getProperty("user.dir") + "/OUT_VariablePrepare.docx"); System.out.println("Saved"); } }
/** * @param args * @throws Docx4JException */ public static void main(String[] args) throws Docx4JException { WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load( new java.io.File( System.getProperty("user.dir") + "/aq1.docx")); FieldUpdater fu = new FieldUpdater(wordMLPackage); fu.update(true); System.out.println(XmlUtils.marshaltoString(wordMLPackage.getMainDocumentPart().getJaxbElement(), true, true)); }
protected int calcTableWidth() { int ret = -1; List<TblGridCol> gridCols = (getTblGrid() != null ? getTblGrid().getGridCol() : null); //The calculation is done the way it was done in the TableWriter. This isn't necesarily correct, //as cell-widths may override column widths. if ((gridCols != null) && (!gridCols.isEmpty())) { ret = 0; for(int i=0; i<gridCols.size(); i++) { if (gridCols.get(i).getW()==null) { log.warn("Missing width " + XmlUtils.marshaltoString(getTblGrid())); continue; } ret += gridCols.get(i).getW().intValue(); } } return ret; }
public Ind getInd(NumPr numPr) { //, StyleDefinitionsPart sdp, String styleId) { String ilvlString = "0"; if (numPr.getIlvl()!=null) ilvlString = numPr.getIlvl().getVal().toString(); if (numPr.getNumId()==null) { if(log.isWarnEnabled()) { log.warn("numPr without numId: " + XmlUtils.marshaltoString(numPr, true, true)); } return null; } else { return getInd(numPr.getNumId().getVal().toString(), ilvlString ); } }
private static void handleTxBody(CTTextBody sp, CTTextBody layoutShape) { // a slide layout p:sp/p:txBody can override, with a <a:lstStyle> element // so copy a:lstStyle over if (sp.getLstStyle()!=null) { log.warn("Slide shape contains lstStyle! (Not expected at that level)"); log.debug(XmlUtils.marshaltoString(sp.getLstStyle(), false, true, Context.jcPML, "FIXME", "lstStyle", CTTextListStyle.class)); } if (layoutShape.getLstStyle()!=null) { sp.setLstStyle( XmlUtils.deepCopy(layoutShape.getLstStyle(), Context.jcPML )); } }
private P canonicaliseInstance(P p) { P newP = Context.getWmlObjectFactory().createP(); newP.setPPr(p.getPPr()); newR = Context.getWmlObjectFactory().createR(); // fieldRPr = null; stack = new LinkedList<FieldRef>(); if(log.isDebugEnabled()) { log.debug(XmlUtils.marshaltoString(p)); } handleContent(p.getContent(), newP); // log.debug(XmlUtils.marshaltoString(newP, true)); return newP; }