This is my first question, so please be careful;)
I am stuck with a strange problem. Essentially, I get three XSD definitions, for example:
PartA.xsd targetNameSpace="PartA" include="PartB.xsd" PartB.xsd PartC.xsd targetNameSpace="PartC" inlude="PartB.xsd" import="PartA.xsd"
Error popping up when binding PartC through JAXB classes to Java:
- A class / interface with the same name "b.exampleType" is already in use. Use class customization to resolve this conflict.
- This confusing error occurred most likely because the scheme uses a technique called the "chameleon scheme", which forces one definition to load several times into different namespaces. See http://forums.java.net/jive/thread.jspa?threadID=18631 for details.
Following the link, I found out that the actual error lies in PartB, which does not have a namespace declaration! This method is called Chameleon Schema . Certain types in PartB will use the importing XSD namespace.
So, in my case, there are two namespaces for the same type:
And this is where JAXB breaks down. I did not find a way to properly bind PartC. And (to make things complicated) I have a chance to change the original XSD definitions!
Has anyone come across this phenomenon or something like that and has a valid workaround?
java xml xsd jaxb
Gruber
source share