use of biblemulticonverter.schema.usfx.ObjectFactory in project BibleMultiConverter by schierlm.
the class USFX method doExportBooks.
@Override
public void doExportBooks(List<ParatextBook> books, String... exportArgs) throws Exception {
ObjectFactory of = new ObjectFactory();
File file = new File(exportArgs[0]);
Usfx usfx = of.createUsfx();
for (ParatextBook book : books) {
usfx.getContent().add(of.createUsfxBook(createBook(book)));
}
final Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
JAXBContext ctx = JAXBContext.newInstance(ObjectFactory.class.getPackage().getName());
Marshaller m = ctx.createMarshaller();
if (!Boolean.getBoolean("biblemulticonverter.skipxmlvalidation"))
m.setSchema(getSchema());
m.marshal(usfx, doc);
doc.getDocumentElement().setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
doc.getDocumentElement().setAttribute("xsi:noNamespaceSchemaLocation", "usfx.xsd");
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
transformer.transform(new DOMSource(doc), new StreamResult(file));
}
Aggregations