History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: CASTOR-2206
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Blocker Blocker
Assignee: Werner Guttmann
Reporter: Mitesh Soni
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
castor

java.lang.IllegalArgumentException: Duplicate name found as a class member

Created: 24/Oct/07 12:52 AM   Updated: 14/Mar/08 06:41 AM
Component/s: XML code generator
Affects Version/s: 1.1.2.1
Fix Version/s: 1.2

Time Tracking:
Original Estimate: Not Specified
Remaining Estimate: 3 days, 22 hours, 35 minutes
Time Spent - 2 hours, 25 minutes Remaining Estimate - 3 days, 22 hours, 35 minutes
Time Spent: 2 hours, 25 minutes
Time Spent - 2 hours, 25 minutes Remaining Estimate - 3 days, 22 hours, 35 minutes

File Attachments: 1. Text File CommonTypesTaxonomy.xsd (16 kb)
2. Java Source File ContactInformation.java (12 kb)
3. Java Source File ContactInformation.java (8 kb)
4. Java Source File ContactInformation.java (4 kb)
5. Text File patch.c2206.20071127.txt (2 kb)
6. Text File patch.c2206.20071204.txt (5 kb)
7. Text File patch.c2206.20071205.txt (14 kb)
8. Text File patch.c2206.sgen.20071127.txt (3 kb)
9. File XBRL_Taxonomies.rar (15 kb)

Environment: latest configuration.


 Description  « Hide
I have xsd file which contains following portion and which is creating problem while generating source.

<element id="idp-idprod_Party" name="Party" substitutionGroup="xbrli:tuple" nillable="true">
<complexType>
<complexContent>
<restriction base="anyType">
<choice>
<element ref="idp-ctctUS:ContactInformation" minOccurs="0" maxOccurs="1" />
<element ref="idp-ctctIntl:ContactInformation" minOccurs="0" maxOccurs="1" />
<element ref="idp-enumtype:ContactInformation" minOccurs="0" maxOccurs="1" />
</choice>
<attribute name="id" type="ID" use="optional" />
</restriction>
</complexContent>
</complexType>
</element>

I cannot change in xsd file.

here 3 elements have same name ContactInformation with different namespace but while creating class file it is giving java.lang.IllegalArgumentException: Duplicate name found as a class member for obvious reason bcoz it will try to create _contactInformation 3 times and its not legal though it is having different namespaces. Binding.xml was looking like a solution but still no success with that. I have tried to use automaticConflictResolution but no joy. Is there any way??

I am attchaing all the necessary files required for the source generation.

Problem occures when the XBRL_Taxonomies->product->identity->IdentityProductTaxonomy.xsd is used to generate the source java files.

the above code is copied from that file.

All imported schemas mentioned in IdentityProductTaxonomy.xsd are attched and hoping that all required files are attached.

All 3 ContactInformation elements have diff namespace but while creating the java file it uses just element name to create a reference variable of ContactInformation class.

Thus bcoz there are 3 ContactInformation element(even though with different namespace)...it will try to create 3 objects with name "_contactInformation" and that gives an error of "Duplicate name found as a class member " if somehow it takes namespace in consideration or can resolve the name conflicts then it may solve problem.

I have tried to use automaticConflictResolution property in caastor.buildor but not working.

I have tried to use binding.xml but not having much idea how to solve this error bcoz Same name exists foe 3 different elements.

Most IMP thing is "I CANNOT CHANGE THE SCHEMA FILES".



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Werner Guttmann - 26/Oct/07 02:59 PM
I am willing to help you if - and only if - you provide me with something more meaningful than a set of XML schema files. I mean, you've got working code on your side to trigger code generation, etc. Can you please have a look at

http://castor.org/how-to-submit-an-xml-bug.html

and follow the instructions provided there to provide me with a full test case incl. JUnit test case to start code generation, a minimal XML schema that exposes the error at discussion, castor.properties (if used), binding file (if used), etc. Castor is an open source project, and I am spending my private time here without being made. I think I can expect that you provide me with as much information as possible so that I can easily replay your problem without having to wonder which XML schema file I shall be using as starting point, etc.

Alternatively, please consider taking up professional services as explained at http://castor.org/professional-services.html.


Mitesh Soni - 26/Oct/07 10:51 PM
Hello sir,

I am a just starter and i was given the work to generate classes from the given xsd files.

So i have no test cases, No code.

I have generated classes from slmost all xsd files with the use of commands like...

java org.exolab.castor.builder.SourceGeneratorMain -i IdentityProductTaxonomy.xsd -package com.dnb.IDP.Product.Identity.Vers1

My only problem is the contactInformation element which i have specifically highlighited in the last post. I have only label.xml or presentation.xml extra. else i am having nothing.

"All 3 ContactInformation elements have diff namespace but while creating the java file it uses just element name to create a reference variable of ContactInformation class.

Thus bcoz there are 3 ContactInformation element(even though with different namespace)...it will try to create 3 objects with name "_contactInformation" and that gives an error of "Duplicate name found as a class member " if somehow it takes namespace in consideration or can resolve the name conflicts then it may solve problem."

I can understand that you are giving your precious time to help me and I am thankful to u for that but I donot have much more things than this and the problem i am facing doesnt require anything else except schema files.

I have tried with binding.xml but problem I am facing is the same how to seprate different element Here.

SO this is what i am having. If i remove 2 elements then it creates all classes ...problem comes when 3 elements with same elements are there because at the time of source creartion it creates member variable according to the name of the element and thus it will try to create 3 elements having name _contactInformation(according to naming conventions) od ContactInformation classesNow until I specifically mention the different packages somehow, I am not going to get the desired result.

Still I am attaching 3 contactInformation classes which are generated and and whose object this source needs to use.


Mitesh Soni - 26/Oct/07 10:56 PM
All ContactInformation classes are different

Werner Guttmann - 29/Oct/07 06:15 AM
Well, apparently, there's an XML schema missing: CommonTypesTaxonomy.xsd.

Here's my suggestion: how about attaching a set of XML schema files where you (and not me) limit the set of XML schema artefacts to what's really necessary to reproduce your problem. Then, and only then, I will look into this again.

The alternative is to consider looking into professional services where you'll pay us for doing this.


Mitesh Soni - 29/Oct/07 06:19 AM
Here i have attached it.

Werner Guttmann - 30/Oct/07 12:10 PM
Alright, I finally managed to reproduce your problem, and I do acknowledge that Castor's code generator currently does not have support for more than one element reference with the same (local) name. I had a quick look at the existing source code, and I think it should be possible to add support for namespace qualification in a binding file (something currently is not supported). But .... this is not going to be an easy task. I'd estimate that it would take me (or any other committer) a few days to introduce this new feature. And this is beyond my personal capacity .. as I would be doing this in my spare time.

However, if you'd be willing to pay for this (professional support), I could provide you with an estimate etc.


Werner Guttmann - 27/Nov/07 04:19 PM
Attached two patch files that together form an initial (very early) patch for review. With these two patched applied I can get things to work fully. Please note that I have not tested against the CTF yet.

Werner Guttmann - 04/Dec/07 04:40 AM
Updated and improved patch, tested against the XML CTF as well (with no errors).

Werner Guttmann - 04/Dec/07 04:40 AM
I'd appreciate any feedback from the reporter or anybody listening in as well .. .

Mitesh Soni - 04/Dec/07 09:11 PM
Hi,

Thanks For ur kind reply.

I have completed that work in castor and now no longer working in that but still u have helped in lot many ways and inspired me to reply to ppl who are in need.

Thank you very much.


Werner Guttmann - 05/Dec/07 03:46 AM
Final patch for review (incl. CTF test case).