Skip to main content

'EmptyType' is already defined and external binding file ignored?

6 replies [Last post]
jnljacobso
Offline
Joined: 2007-08-23
Points: 0

Greetings.

I'm fairly new to JAXB so please bear with me. I recently successfully ran the JAXB compiler (2.1.4/20070711) on some pretty complex third-party XSDs. I ended up with a 100 line external binding file that got everything to work. However, I'm now going through the same process on some different XSDs and it seems that the same types of bindings have no affect.

The situation that I have is that there are two XSDs that define the same complexType in the same namespace. Since these are third-party XSDs, I'd rather not change them if I can help it. I have stripped out everything but one of the problematic elements. Here are my two identical XSDs:

poc-capabilities.xsd:
<?xml version="1.0" encoding="UTF-8"?>

poc-transaction.xsd:
<?xml version="1.0" encoding="UTF-8"?>

As you can see, there is a name collision on 'EmptyType' and, sure enough, running the command:
jaxb-ri-20070711/bin/xjc.sh poc-capabilities.xsd poc-transaction.xsd

gives the error:
[ERROR] 'EmptyType' is already defined
line 4 of file poc-capabilities.xsd

[ERROR] (related to above error) the first definition appears here
line 3 of file poc-transaction.xsd

Other than the fact that the line numbers do not match, there are no surprises. In order to resolve the problem, I decided to rename the class in poc-transaction.xsd with the binding file poc.xjb:
<?xml version="1.0" encoding="UTF-8"?>

Unfortunately, running again with the new external binding file does not have any affect:
jaxb-ri-20070711/bin/xjc.sh -b poc.xjb poc-capabilities.xsd poc-transaction.xsd

[ERROR] 'EmptyType' is already defined
line 4 of file poc-capabilities.xsd

[ERROR] (related to above error) the first definition appears here
line 3 of file poc-transaction.xsd

I've noticed that misspelling the XSD name or breaking the node XPath in the binding file produces the expected error so I know that the compiler is reading the file and performing some validation. Unfortunately, nothing that I have tried thus far has solved the problem. Can anyone explain what is going wrong here?

Based on my experience with the other XSDs, it really seems like the binding file is being ignored. As I said, I'm fairly new to JAXB so it's probably something simple that I'm missing. I just don't know what that is.

Thank you.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mshaffer55
Offline
Joined: 2007-02-07
Points: 0

I'm not sure what the problem is here, but I can suggest an alternative. Since these schemas are really defining the same type, you really want the results of xjc compilation to be a single Java class for EmptyType, yes? This can be accomplished by compiling the schemas separately. Compile poc-capabilities.xsd first to generate an episode file (-episode ), and then use this episode file as a binding file for the compilation of poc-transaction.xsd. Note that the second compilation must be done with -extension, since the episode file is really a binding file with vendor extensions.

jnljacobso
Offline
Joined: 2007-08-23
Points: 0

The episode route has problems as well. I get lots of errors like this:
[ERROR] XSD "~tns:" didnt match any schema component

I think these errors are happening because both poc-capabilities.xsd and poc-transaction.xsd reside in the same namespace. There are types declared in poc-capabilities.xsd that are [b]not[/b] in poc-transaction.xsd.

I chose what I thought was the simplest case in order to get something working. There are other types in imported XSDs that have name conflicts but different contents. Like I said, I didn't write these things.

Still, it boggles my mind that I can't tell xjc to create a class with a different name in this case where it has definitely worked before. Am I completely missing the point or is this a bug?

mshaffer55
Offline
Joined: 2007-02-07
Points: 0

I agree that the renaming binding should work.I even tried the scd alternative and that didn't work any better. I'd say it looks like a bug to me.

joserra
Offline
Joined: 2007-11-14
Points: 0

this is the same I said in http://forums.java.net/jive/thread.jspa?threadID=33200

Did you find a solution for this?
Tx.

jnljacobso
Offline
Joined: 2007-08-23
Points: 0

I tried to enter a bug report but never heard back.

In my case, there was no overlap in the included/imported schemas so I processed the two XSDs separately. I have separate XJB files which define the packages differently to avoid any collisions.

poc100.xjb:





poc100t.xjb:





It sucks but works for my needs.

joserra
Offline
Joined: 2007-11-14
Points: 0

Thanks, it´s not enough for us, as the schemas included are repeated.