phax / ph-ubl

Java library for reading and writing UBL 2.0, 2.1, 2.2, 2.3 and 2.4 documents
Apache License 2.0
110 stars 40 forks source link

XML cut off on write #60

Closed azyu1011 closed 1 year ago

azyu1011 commented 1 year ago

Hello, I have a question,

When I use the UBL Marshaller, the XML is not generated completely; it always gets cut off at line 74. Does anyone know where my mistake is? Here is the code snippet:

private static InputStream invoiceToXmlAsInputStream(InvoiceType invoice) throws ReformException {
        InputStream inputStream;
        try {
            UBL21Marshaller.UBL21JAXBMarshaller<InvoiceType> marshaller = UBL21Marshaller.invoice();
            ByteBufferOutputStream byteBufferOutputStream = new ByteBufferOutputStream();
            marshaller.setCharset(StandardCharsets.UTF_8);
            marshaller.setFormattedOutput(true);
            marshaller.write(invoice, byteBufferOutputStream);
            inputStream = new ByteArrayInputStream(byteBufferOutputStream.getAsByteArray());
        }
        catch (Exception ex) {
            LOGGER.error("UBL/XRechnung konnte nicht erstellt werden", ex);
            throw new ReformException(
                    Translator.tr("UBL/XRechnung konnte nicht erstellt werden, bitte kontaktieren Sie den Support.", ReformHttpSession.getLocale()));
        }
        return inputStream;
    }
azyu1011 commented 1 year ago

It can be closed. I created some incorrect data, but the exceptions are not displayed. I added ExceptionCallbacks, and now everything is fine.