public static void marshal(InvoiceType invoiceType, OutputStream outputStream,
String encoding) throws FailedToMarshalException {
try {
JAXBContext jc = JAXBContext.newInstance(UBL_INV_PKG);
ObjectFactory of = new ObjectFactory();
javax.xml.bind.Marshaller m = jc.createMarshaller();
m.setProperty(javax.xml.bind.Marshaller.JAXB_ENCODING, encoding);
m.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
Schema schema = getInvoiceTypeSchema();
if (schema != null) {
m.setSchema(schema);
}
m.marshal(of.createInvoice(invoiceType), outputStream);
} catch (Exception e) {
throw new FailedToMarshalException(e);
}
}