/** * Writes resulting iTT document to output file. * * @throws JAXBException */ public void writeToFile() throws JAXBException { if (mergedItt == null) { System.out.println("Resulting iTT is empty. No data to write."); return; } Marshaller jaxbMarshaller = TtmlUtils.createTtmlJaxbContext().createMarshaller(); jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); jaxbMarshaller.marshal(new ObjectFactory().createTt(mergedItt), outputFile); }
/** * Does TTML document transformation to another TTML document. * * @param tt source TTML document root element * @param transformer transformer * @return TTML document after transformation */ public static TtEltype transformTtmlDocument(TtEltype tt, Transformer transformer) { JAXBElement<TtEltype> ttJaxb = new ObjectFactory().createTt(tt); try { JAXBContext jaxbc = createTtmlJaxbContext(); JAXBSource source = new JAXBSource(jaxbc, ttJaxb); JAXBResult result = new JAXBResult(jaxbc); // transform transformer.transform(source, result); return (TtEltype) ((JAXBElement<TtEltype>) result.getResult()).getValue(); } catch (JAXBException | TransformerException e) { throw new ConvertException(e); } }