JAXB Bindings for READING ORCID RECORD XML (2.0)

94 views
Skip to first unread message

Lyuben Atanasov

unread,
May 2, 2017, 11:23:05 AM5/2/17
to ORCID API Users
Hi,

I want to use the XSD resources to generate POJOs for my java client, requesting the URL https://pub.sandbox.orcid.org/v2.0/0000-0000-0000-0000/record.
The problem is I get a lot of JAXB errors like this: "... is already in use. Use a class customization to resolve this conflict."
I wanted to ask is there any binding for record_2.0, or I should write it myself?
Please provide a link, if there is any.

Thanks and regards
LA

Will Simpson

unread,
May 2, 2017, 2:26:31 PM5/2/17
to ORCID API Users
Hi Lyuben,

We have the same element name in different namespaces (with different restrictions), but that confuses the JAXB compiler.

There is no binding yet for record_2.0 (we created our 2.0 classes by hand, based on the previous version of the classes).

I've attached a first attempt at a binding file, which puts classes in different namespaces into their own packages.

There are still some conflicts (which I will investigate, and hopefully clean up in the future). However, you can work around them for now, using -XautoNameResolution.

xjc -extension -d src/main/java -b src/main/resources/record_2.0/jaxb-binding-separate-packages.xjb -XautoNameResolution src/main/resources/record_2.0/record-2.0.xsd

Can you try with that binding file, or create your own?

We can maybe add the binding to the ORCID-Source repo, if it works for you. If not, you could fork the repo and submit your binding file as a pull request.

Best regards,

Will
jaxb-binding-separate-packages.xjb

Yuci Gou

unread,
May 11, 2017, 7:20:24 AM5/11/17
to ORCID API Users
In addition to:

xjc -extension -d src/main/java -b src/main/resources/record_2.0/jaxb-binding-separate-packages.xjb -XautoNameResolution src/main/resources/record_2.0/record-2.0.xsd

In order to get bulk individual research works (up to 50), you would consider API endpoint /works, for example:

https://api.sandbox.orcid.org/v2.0/[ORCID iD]/works/230776,230777,230777

And to unmarshal bulk ORCID works, you would need another JAXB class called Bulk.java, which you could generate by using:

xjc -extension -d src/main/java -XautoNameResolution src/main/resources/record_2.0/bulk-2.0.xsd

Not sure this is the right way. However it works fine for me :-)

Cheers,

Yuci
Reply all
Reply to author
Forward
0 new messages