Hi Mike, This is something that will need to be added to the binding-file, but it's currently not available.
It's actually listed on the to-do section of the binding file information on the website: http://castor.exolab.org/sourcegen.html#Binding-File Arnaud Blandin is working on the enumeration support for the binding-file, however I am not sure what his timeframe will be for that. For a quick work-around you might just want to modify the SourceFactory#processEnumerationAsNewObject method to use an "_" if it sees a space instead of defaulting to VALUE_1....n. In SourceFactory you'll see the following: 1539: if (useValuesAsName) objName = value.toUpperCase(); 1560: else objName = "VALUE_" + count; You might want to change that to something like: objName = value.toUpperCase(); if (!useValuesAsName) { objName = objName.replace(' ', '_'); if (!JavaNaming.isValidJavaIdentifier(objName)) { objName = "VALUE_" + count; } } --Keith "Michael J. Carlin" wrote: > > I am a new user of Castor, as opposed to a developer of Castor, so I am not > sure if this is the appropriate place to send my question. I did not see a > mailing list specifically targeted towards users. If there is one, I would > appreciate it if someone would point me to it. > > I have a schema that includes the following type definition: > > <xsd:simpleType name="ColorType"> > <xsd:restriction base="xsd:string"> > <xsd:enumeration value="Black"/> > <xsd:enumeration value="Gray"/> > <xsd:enumeration value="Light Gray"/> > <xsd:enumeration value="White"/> > </xsd:restriction> > </xsd:simpleType> > > Running the source generator tool results in the creation of the file > ColorType.java with the following lines: > > public static final ColorType VALUE_1 = new ColorType(VALUE_1_TYPE, > "Gray"); > > public static final int VALUE_2_TYPE = 2; > > public static final ColorType VALUE_2 = new ColorType(VALUE_2_TYPE, > "Light Gray"); > > It appears that if there is a space present in any of the enumeration > values, in this case "Light Gray", the source generator will generate class > constants with "VALUE" names. > > Instead of class constants with names like VALUE_1, VALUE_2, and > VALUE_2_TYPE, I want them to be named GRAY, LIGHT_GRAY, and LIGHT_GRAY_TYPE. > Is there a way to do this without changing the schema? > > I am using Castor 0.9.4.3. > > Thanks for any help. > > Mike Carlin
