Chris Tavares
Chris Tavares

Reputation: 30401

Set up maven build for xjc for multiple schemas in the same xml namespace?

I'm working on a project where we have Jersey/JaxB based serialization system to talk to a web service. The service in question returns data wrapped inside an Atom feed.

An older part of the system wrote a one-off specific to their service XSD for Atom that was hard wired with only their particular elements. I now need to add support for a new service, which is doing a similar thing (using Atom as a "envelope"), but using significantly different elements and content schema.

I don't want to disturb the existing code, so ideally I'd like to do the same thing the previous project did: define my own schema for the parts of Atom that the new service is using.

I'm running into:

org.xml.sax.SAXParseException: 'feed' is already defined

I'm apparently hitting the limitation described in the XJC release notes: It is not legal to have more than one <jaxb:schemaBindings> per namespace.

Is there a way to set things up in our build so that if I have separate xjb files, I can run xjc independently over the two distinct schemas and generate code for each of them into separate packages? How do I work around this limitation?

We're using the maven jaxb plugin.

Upvotes: 3

Views: 766

Answers (1)

Chris Tavares
Chris Tavares

Reputation: 30401

Just for the record, what we ended up doing was generating the code from the schema separately, and checking in the generated code. Since the ATOM schema's not changing, it was reasonably safe. Annoying to have to do it that way though.

Upvotes: 1

Related Questions