Java Object to UBL XML
kurbhatt opened this issue · comments
I have a Java object which has been parsed from JSON(In my existing REST-based spring boot application). I want to convert this Java object to XML so currently, I am converting the Java object to related UBL Invoice/Credit/Debit/Self Billed Invoice.
I am writing code to manually transform my Java object to a related UBL document.
How can I convert that UBL document to XML without writing it into the file?
Do I need to convert it into a Document or is there any other way?
Is it possible to convert Documents to XML structure directly?
I need XML because I have to generate a hash of the document XML for further crypto processing.
Currently, I have added/converted data into the:
InvoiceType invoice = new InvoiceType();
Now I want to proceed further to generate standard UBL XML.
Hi, what you are looking for the is the org.w3c.Document
type - that this the "in-memory" XML representation. That should be the basis for signature creation etc.
Thanks for the quick reply.
I want InvoiceType to be converted into the XML like https://docs.oasis-open.org/ubl/os-UBL-2.1/xml/UBL-Invoice-2.1-Example.xml
I have set all the details manually to the InvoiceType object.
I want to generate XML of that object.
Any suggestion?
So you want to have the byte[]
or String
representation.
By using UBL21Writer.invoice ().getAsString (invoice)
or UBL21Writer.invoice ().getAsBytes (invoice)
you can reach this.
See further methods of UBL21Writer.invoice ()
for different output formats.
Wonderful.. That's what I am looking for. Tried it and working fine.
Many many thanks.
You can close the issue.