Hi,

I have to correct myself. When using an explicit type and referencing it from an 
element definition, the class code for the type is generated correctly but for the 
element, still an int is returned  instead of an Object. So it also doesn't work with 
this approach.

xsd:

    <xsd:element name = "Price">
          <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref = "PriceValue" minOccurs = "0" maxOccurs = 
"unbounded"/>
                <xsd:element name = "PriceUnit" type="PriceUnitType"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>

    <xsd:simpleType name="PriceUnitType">
        <xsd:restriction base = "xsd:int">
           <xsd:enumeration value = "1"/>
           <xsd:enumeration value = "10"/>
           <xsd:enumeration value = "100"/>
           <xsd:enumeration value = "1000"/>
        </xsd:restriction>
    </xsd:simpleType>

java:

    /**
     * Sets the value of field 'priceUnit'.
     * 
     * @param priceUnit the value of field 'priceUnit'.
     */
    public void setPriceUnit(int priceUnit)
    {
        this._priceUnit = priceUnit;
        this._has_priceUnit = true;
    } //-- void setPriceUnit(int) 


Nick

-----Ursprüngliche Nachricht-----
Von: Nick Laqua 
Gesendet: Dienstag, 13. April 2004 10:01
An: [EMAIL PROTECTED]
Betreff: [castor-dev] sourcegenerator bug ??



Hi,

after upgrading to 0.9.5.3 and regenerating our xml classes, it seems that castor 
doesn't generate correct code for type definitions using restrictions for xsd:int. The 
xml fragment looks like this:


                <xsd:element name = "PriceUnit" default="1" >
                  <xsd:simpleType>
                      <xsd:restriction base = "xsd:int">
                          <xsd:enumeration value = "1"/>
                          <xsd:enumeration value = "10"/>
                          <xsd:enumeration value = "100"/>
                          <xsd:enumeration value = "1000"/>
                      </xsd:restriction>
                  </xsd:simpleType>
                </xsd:element>

Obviously, this only fails when using anonymous types (as above), when creating 
explicitly a PriceUnitType based on xsd:int, then it works perfect. In case of the 
example above, castor creates code like this (doesn't compile):

    /**
     * Field _priceUnit
     */
    private int _priceUnit = int.valueOf("1");

    /**
     * Returns the value of field 'priceUnit'.
     * 
     * @return the value of field 'priceUnit'.
     */
    public int getPriceUnit()
    {
        return this._priceUnit;
    } //-- int getPriceUnit() 


Thanx in advance

Nick

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to