I am having trouble figuring out how enumBinding in a custom bindings file is 
supposed to work with Castor 1.1.  I am working with a schema developed by 
another organization and am evaluating whether or not I can effectively use 
Castor with it.  Given how they formatted their schema and using my example, 
the typesafe objects created by Castor by default are named VALUE_5810 and 
VALUE_5820.  Ideally, I would like to have them named something more like 
COMMUNITY_NON_PROFIT and PRIVATE.  From the documentation, it would seem I 
should be able to accomplish this using a bindings file.  Below are examples of 
the schema, a bindings file I tried to use (which only tries to rename the 
first enumerated value), along with examples of the generated code I got versus 
the code I was actually expecting.  The code generator runs without any errors, 
but the bindings file has no effect.  I am quite sure it is reading the 
bindings file because if I add something invalid to it, it will cause an 
exception.  Any idea what is going on here?

Thank you,

Scott Arnold
Analyst
BJCHealthCare


Example of schema layout:


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://www.boone.org"; 
xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
targetNamespace="http://www.boone.org"; elementFormDefault="qualified" 
attributeFormDefault="unqualified">
        <xs:simpleType name="OrganizationalType">
                <xs:restriction base="xs:integer">
                        <xs:enumeration value="5810">
                                <xs:annotation>
                                        <xs:documentation>Community, 
Non-Profit</xs:documentation>
                                </xs:annotation>
                        </xs:enumeration>
                        <xs:enumeration value="5820">
                                <xs:annotation>
                                        
<xs:documentation>Private</xs:documentation>
                                </xs:annotation>
                        </xs:enumeration>
                </xs:restriction>
        </xs:simpleType> 
    <xs:element name="OrganizationalInfo">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="FirstOrgType" type="OrganizationalType"/>     
    
                <xs:element name="SecondOrgType" type="OrganizationalType"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>


Example of bindings file:


<binding xmlns="http://www.boone.org";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xsi:schemaLocation="http://www.boone.org 
E:\\java\\schematest\\enumBindingTest.xsd" 
        defaultBinding="element">
<enumBinding name="/enumType:OrganizationalType">
        <enum-def>
                <enumMember>
                        <value>5810</value>
                        <javaName>COMMUNITY_NON_PROFIT</javaName>
                </enumMember>
        </enum-def>
</enumBinding>
</binding>


Executed from command line:


java org.exolab.castor.builder.SourceGeneratorMain -i 
schematest\enumBindingTest.xsd -package org.boone.btest -binding-file 
testbinding.xml


What I got in the OrganizationalType class:


    /**
     * The 5810 type
     */
    public static final int VALUE_5810_TYPE = 0;

    /**
     * The instance of the 5810 type
     */
    public static final OrganizationalType VALUE_5810 = new 
OrganizationalType(VALUE_5810_TYPE, "5810");


What I was expecting:


    /**
     * The 5810 type
     */
    public static final int COMMUNITY_NON_PROFIT_TYPE = 0;

    /**
     * The instance of the 5810 type
     */
    public static final OrganizationalType COMMUNITY_NON_PROFIT = new 
OrganizationalType(COMMUNITY_NON_PROFIT_TYPE, "5810");




---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to