Hi, Paul and Lastric,

Thanks for your help. I can't modify the schema itself to make the duplication of elements disappear in the schema.

I think the binding file will need to be generated for each of the schema and can only deal with a specific schema instance, do I understand it correctly? For my case, I need to automatically parse any kind of schema which may or may not contain duplicated elements. And the duplicated element' names may be different from schema to schema. Also, I can't generate a different binding file for each schema since this is part of the automatic parsing process.

I'm not sure how this generic problem about duplicate elements can be resolved by just ONE generic binding file? Please advice.

Thank you very much again.

Best Regards,
Joanna

----- Original Message ----- From: "Paul Grillo" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, June 30, 2005 5:17 AM
Subject: RE: [castor-user] How to resolve java file name confliction when use SourceGenerator to generate java files for schema with same-name elements?


You'll probably want to use a binding file when generating the java source. use the -binding-file [filename] in your sourcegenerator statement.



The  binding file indicates how you want to handle these and other issues.

an example might look like the following, but I can't guarantee its accuracy. essentially you are indicating that you want to create a class called AccountPayableRow when you encounter the element you refer to.

The only thing I'm not sure of is if you will need a mapping file when you unmarshal at runtime. that is you may then have to indicate in a mapping file the mapping from the xml data back. At any rate this or a combination of both of these will solve your problem. We had the exact same issue where we were not at liberty to change the XSD, and overcame it in this way.



<?xml version="1.0"?>

<binding xmlns:cbf="http://www.castor.org/SourceGenerator/Binding"; defaultBindingType="element">

       <cbf:elementBinding name="/AccountPayble /row">

          <cbf:java-class name=" AccountPaybleROW"/>

      </cbf:elementBinding>

</binding>


________________________________________
From: Juan Wu [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 30, 2005 4:10 AM
To: [email protected]
Cc: [EMAIL PROTECTED]
Subject: [castor-user] How to resolve java file name confliction when use SourceGenerator to generate java files for schema with same-name elements?

Hi,
I try to use SourceGenerator to generate java files for the following schema. It has two top level elements AccountPayble and PaymentMethods. However, they all have a sub-element which is called the same as "row". And, these two "row" elements contain different sub-elements. The SourceGenerator will generate a java file for each of the elements - however, I only get one "row `.java" file related with the 2nd element (PaymentMethods), since it overwrites the "row.java" generated for the 1st element (AccountPayble). Is there a way that can let it generate two different row.java files that won't overwrite each other in an non-interactive way (with -f option)? Since this process doesn't run on a command window, I can't manually type "y|n" when it asks for overwriting. In another word, would it be possible to generate java files for the 2 "row" elements named like "AccountPayble_row.java" and "PaymentMethods_row.java" instead of just "row.java" when there is such element name conflict? I have set "org.exolab.castor.builder.javaclassmapping=type" in the castorbuilder.properties.
Your any suggestions or answers will be highly appreciated.
Thanks a lot!
Joanna
...... part of the schema which has elements' name conflict......
<element maxOccurs="1" minOccurs="0" name="AccountPayble">
<complexType>
<sequence>
<element maxOccurs="unbounded" minOccurs="0" name="row">
<complexType>
<all>
<element maxOccurs="1" minOccurs="0" name="AccountType" type="string"/>
<element maxOccurs="1" minOccurs="0" name="AccountCode" type="string"/>
</all>
</complexType>
</element>
</sequence>
</complexType>
</element>
<element maxOccurs="1" minOccurs="0" name="PaymentMethods">
<complexType>
<sequence>
<element maxOccurs="unbounded" minOccurs="0" name="row">
<complexType>
<all>
<element maxOccurs="1" minOccurs="0" name="PaymentMethodCode" type="string"/>
</all>
</complexType>
</element>
</sequence>
</complexType>
</element>

-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------





-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to