-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] JAXB2 Namespace Prefix Plugin creating duplicated package info namespace #577
Comments
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 ? |
Hey there, I just downloaded it in french and remove the unwanted files so that it fits the 25mo Github limit. You'll find |
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 //
// 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 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 |
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 !
The text was updated successfully, but these errors were encountered: