Closed goodale closed 1 year ago
Hi @goodale
The plugin is still working yes, we also need to update the README section
In fact, it moves from here to another highsource repository jaxb-tools (former maven-jaxb2-plugin
).
You can find wiki section there on how to use the plugin
Feel free to give us feedback if you still fail to make it work and share your configuration of the plugin.
NB : all artifacts are now under same groupId org.jvnet.jaxb
.
Regards. Laurent
You'll find there (in the wiki page of the annotate plugin) many useful informations that were lost due to old website being shutdown (see https://github.com/highsource/jaxb2-annotate-plugin/issues/64) that might help you configure your project.
My apologies if I am overlooking it but I do not see any examples to specify an xjb file to utilize an adapter for formatting dates and datetimes.
for example, i have an XMLGregorianCalendar xs:dateTime and I want to ensure it is formatted when marshalled to XML in YYYY-MM-DDTHH:MM:SS.TTT
I've found examples of manually creating an adapter class but it would require overwriting the auto-generated classes from xjc. My understanding is that this is where an xjb comes into play. But I've not found any examples of how the highsource plugin would work here.
Thanks, Steve
On Tue, Sep 5, 2023 at 11:46 AM Laurent Schoelens @.***> wrote:
You'll find there https://github.com/highsource/jaxb-tools/wiki/JAXB-Annotate-Home (in the wiki page of the annotate plugin) many useful informations that were lost due to old website being shutdown (see #64 https://github.com/highsource/jaxb2-annotate-plugin/issues/64) that might help you configure your project.
— Reply to this email directly, view it on GitHub https://github.com/highsource/jaxb2-annotate-plugin/issues/75#issuecomment-1706873591, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJDHB5MBCYCTKGEYFO23ATXY5CM5ANCNFSM6AAAAAA4L6I23M . You are receiving this because you were mentioned.Message ID: @.***>
My apologies if I am overlooking it but I do not see any examples to specify an xjb file to utilize an adapter for formatting dates and datetimes.
for example, i have an XMLGregorianCalendar xs:dateTime and I want to ensure it is formatted when marshalled to XML in YYYY-MM-DDTHH:MM:SS.TTT
I've found examples of manually creating an adapter class but it would require overwriting the auto-generated classes from xjc. My understanding is that this is where an xjb comes into play. But I've not found any examples of how the highsource plugin would work here.
Thanks, Steve
Thanks for your reply From what I understand, I don't think this is related to the plugin by itself but more a question on binding files. I'll try to send you a binding file that would work for your usecase.
Laurent
@goodale
Here is a simple xjb binding file (for jakartaee version of jaxb, but can be adapted simply for jaxb2)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings version="3.0" xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:xs="http://www.w3.org/2001/XMLSchema"
jaxb:extensionBindingPrefixes="xjc">
<jaxb:globalBindings>
<jaxb:javaType name="java.util.Calendar" xmlType="xs:dateTime"
parseMethod="jakarta.xml.bind.DatatypeConverter.parseDateTime"
printMethod="jakarta.xml.bind.DatatypeConverter.printDateTime" />
</jaxb:globalBindings>
</jaxb:bindings>
In this sample, it will map every xsd:dateTime
to java.util.Calendar
by using the parseMethod
/ printMethod
args (fully qualified method name).
You should be able to change this quick sample to make it point to your printMethod
that will generate the date in the format you wanted.
Feel free to come back if needed.
Laurent
This type of binding can also be done for xsd:date
type
Thank you Laurent! - i appreciate the guidance
On Sun, Sep 17, 2023 at 5:18 AM Laurent Schoelens @.***> wrote:
@goodale https://github.com/goodale
Here is a simple xjb binding file (for jakartaee version of jaxb, but can be adapted simply for jaxb2)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <jaxb:bindings version="3.0" xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:xs="http://www.w3.org/2001/XMLSchema" jaxb:extensionBindingPrefixes="xjc">
<jaxb:globalBindings> <jaxb:javaType name="java.util.Calendar" xmlType="xs:dateTime" parseMethod="jakarta.xml.bind.DatatypeConverter.parseDateTime" printMethod="jakarta.xml.bind.DatatypeConverter.printDateTime" /> </jaxb:globalBindings>
</jaxb:bindings>
In this sample, it will map every xsd:dateTime to java.util.Calendar by using the parseMethod / printMethod args (fully qualified method name). You should be able to change this quick sample to make it point to your printMethod that will generate the date in the format you wanted.
Feel free to come back if needed.
Laurent
— Reply to this email directly, view it on GitHub https://github.com/highsource/jaxb2-annotate-plugin/issues/75#issuecomment-1722433240, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJDHB5DB7VRRJ527WFCBKTX2255LANCNFSM6AAAAAA4L6I23M . You are receiving this because you were mentioned.Message ID: @.***>
No problem
Tell us if that solved your problem 😁
@goodale do you manage to get it working ? If so, please tell us and close the issue :)
Thank you @laurentschoelens !
I attempted to use the plugin but get the following error. I also noticed that http://annox.dev.java.net website is 'closed'
Unsupported binding namespace "http://annox.dev.java.net". Perhaps you meant "http://java.sun.com/xml/ns/jaxb/xjc"?