Open mathisgauthey opened 4 days ago
Hi @mathisgauthey
Thanks for your detailed issue.
We'll check soon if it is a bug or a configuration problem.
Regards
Hi @mathisgauthey : you're mentionning "fnfe-mpe.org zip" but I can't find the mentionned zip file above. Could you share it please as MRE ? Thanks š
Hi @mathisgauthey : you're mentionning "fnfe-mpe.org zip" but I can't find the mentionned zip file above. Could you share it please as MRE ? Thanks š
Hey there, I just downloaded it in french and remove the unwanted files so that it fits the 25mo Github limit.
You'll find xsd
files along with factur-x PDF examples.
I happened to find a workaround that could help locate the problem.
Removing this part from the binding files :
<jxb:globalBindings>
<xjc:simple/>
</jxb:globalBindings>
It allows me to use CrossIndustryInvoiceType.java
instead of CrossIndustryInvoice.java
and it removed the unusual duplicated package-info :
//
// This file was generated by the Eclipse Implementation of JAXB, v4.0.5
// See https://eclipse-ee4j.github.io/jaxb-ri
// Any modifications to this file will be lost upon recompilation of the source schema.
//
@jakarta.xml.bind.annotation.XmlSchema(namespace = "urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100", elementFormDefault = jakarta.xml.bind.annotation.XmlNsForm.QUALIFIED, xmlns = {
@jakarta.xml.bind.annotation.XmlNs(namespaceURI = "urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100", prefix = "ram"),
@jakarta.xml.bind.annotation.XmlNs(namespaceURI = "urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100", prefix = "udt"),
@jakarta.xml.bind.annotation.XmlNs(namespaceURI = "urn:un:unece:uncefact:data:standard:QualifiedDataType:100", prefix = "qdt"),
@jakarta.xml.bind.annotation.XmlNs(namespaceURI = "urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100", prefix = "rsm")
})
package REDACTED.entity.generated.extended;
And then, the only issue I had left was related to using an Object of CrossIndustryInvoiceType
: There was an error with a missing @XmlRootElement
which I solved by marshalling differently :
Old :
private static String getXmlString(Object invoice) throws JsonProcessingException {
try {
JAXBContext jaxbContext = JAXBContext.newInstance(invoice.getClass());
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
StringWriter stringWriter = new StringWriter();
marshaller.marshal(invoice, stringWriter);
return stringWriter.toString();
} catch (JAXBException e) {
throw new RuntimeException(e);
}
New :
private static <T> String getXmlString(T invoice) throws JsonProcessingException {
try {
JAXBContext jaxbContext = JAXBContext.newInstance(invoice.getClass());
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
StringWriter stringWriter = new StringWriter();
marshaller.marshal(new JAXBElement<>(new QName("urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100", "CrossIndustryInvoice", "rsm"), (Class<T>) invoice.getClass(), invoice), stringWriter);
return stringWriter.toString();
} catch (JAXBException e) {
throw new RuntimeException(e);
}
It now works fine, I needed to modify some of my jsons input files because removing the part from the bindings file renamed some attributes from plural to strictly singular. But it now works fine !
That's good news š
You can manually add the @XmlRootElement
to the CrossIndustryInvoiceType
by using the jaxb-annotate-plugin
with appropriate binding file.
Hey there.
My usage of jaxb-tools
I'm using jaxb-tools in a factur-x API for :
xsd
files usingxjc
and your maven pluginxml
stringContext
Basically, my process involves :
json
file with the appropriate serialized object along with a pdfjson
is mapped into an object from the jaxb-generated classesxml
file with the correct namespacesxml
into thepdf
to create a factur-x fileMy issue
My issue is related to namespaces associations in the
package-info
file.I don't understand why my generated
package-info
would be different if my executions in thepom.xml
file are identical, same thing for thebindings.xjb
files. But here they are :Hence, the minimal profile is working fine with proper generation of factur-x compliant file.
The 4 other profiles don't work well at all.
Reproducible example
Here is my plugin config inside my
pom.xml
:Here you can find the approporiate filestructure using the
xsd
files from fnfe-mpe.org zip :And finally, here is a
bindings.xjb
file example, only theschemaLocation
is changing :Note that the globalBindings part is used for defining the XmlRootElement that would otherwise be missing when marshalling to
xml
:Questions
Thanks in advance and have a great day !