Skip to main content

Multiple elements with same name appear in the same particle

3 replies [Last post]
Joined: 2005-10-19


I have a schema containing two elements with the same name but different types.

When I execute "xjc -p cre -d cre xsd/test.xsd"

The result I get is:

Warning: JAVA_HOME environment variable is not set.
If build fails because sun.* classes could not be found
you will need to set the JAVA_HOME environment variable
to the installation directory of java.

parsing a schema...
[ERROR] cos-element-consistent: Error for type 'cristal_Type'. Multiple elements
with name 'cre', with different types, appear in the model group.
line 6 of test.xsd

Failed to parse a schema.

If i execute the same command with the option -nv. The files are generated correctly but i get an exception when unmarshalling.

To solve this problem i tried to inline customize my schema like this:

But the result is the same, it hasn't solved my problem.

Could you tell me if I'm searching in the good direction or not?

Thanks by advance for your precious time.


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-06-09

Your schema is incorrect, and the "cos-element-consistent" error message is correct.

Use a schema authoring tool or consult some books on why it's an error.

Joined: 2005-10-19

I know the schema is incorrect (for strict validation), but I write the schema for existing flows so there are things I cannot change.
Indeed I receive flows containing elements that have the same name but different type and content :-X

For example something like:

In my schema, I managed to modelize this configuration and to validate it with XMLSPY (I know this validation is not a strict one). But it is not sufficient.

When I generate java classes with -nv
->Classes are generated but do not support different types of cre element

When I generate java classes without -nv
->Classes are not generated because of the problem I described in my previous post

Can customization help me solving this problem?


Joined: 2003-06-09

You'd have to relax your schema so that it becomes a correct one. Specifically, you should be able to change both types to, say, xs:string.