You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by VeeR Six <ve...@gmail.com> on 2008/12/24 12:30:47 UTC

Axis2 Java code generation question.

Hi,

I have the following definition in an XSD:

<xsd:simpleType name="tariffID">
    <xsd:annotation>
        <xsd:documentation>Standard tariff ID</xsd:documentation>
    </xsd:annotation>
    <xsd:restriction base="xsd:decimal">
        <xsd:totalDigits value="7"/>
    </xsd:restriction>
 </xsd:simpleType>

When I generate the Java code I get the TariffID type as expected, but in
the generated setTariffID(int) method, there is no code that captures the
<xsd:totalDigits> restriction:

/**
 * Auto generated setter method
 * @param param TariffID
 */
  public void setTariffID(int param){
    this.localTariffID=param;
  }

If I then add either <xsd:pattern> or <xsd:minInclusive> and
<xsd:maxInclusive> to the XSD then these restrictions are captured in the
generated code.  For example, this:

<xsd:simpleType name="tariffID">
    <xsd:annotation>
        <xsd:documentation>Standard tariff ID</xsd:documentation>
    </xsd:annotation>
    <xsd:restriction base="xsd:int">
        <xsd:totalDigits value="7"/>
        <xsd:minInclusive value="0"/>
        <xsd:maxInclusive value="9999999"/>
    </xsd:restriction>
</xsd:simpleType>

results in the following Java code being generated:

/**
 * Auto generated setter method
 * @param param TariffID
 */
public void setTariffID(int param){
  if (org.apache.axis2.databinding.utils.ConverterUtil.compare(param,
"9999999") <= 0){
    this.localTariffID=param;
  }
  else {
    throw new java.lang.RuntimeException();
  }
  if (org.apache.axis2.databinding.utils.ConverterUtil.compare(param, "0")
>= 0){
    this.localTariffID=param;
  }
  else {
    throw new java.lang.RuntimeException();
  }
}

My question then is this, why is the <xsd:totalDigits> restriction not
captured in the code  generated by Axis2? Is this expected behaviour or is
it a bug?

This is using v1.3, but I am seeing the same behaviour in v1.4.1 as well.

Thanks,
Colin.

Re: Axis2 Java code generation question.

Posted by Amila Suriarachchi <am...@gmail.com>.
On 12/24/08, VeeR Six <ve...@gmail.com> wrote:
> Hi,
>
> I have the following definition in an XSD:
>
> <xsd:simpleType name="tariffID">
>     <xsd:annotation>
>         <xsd:documentation>Standard tariff ID</xsd:documentation>
>     </xsd:annotation>
>     <xsd:restriction base="xsd:decimal">
>         <xsd:totalDigits value="7"/>
>     </xsd:restriction>
>  </xsd:simpleType>
>
> When I generate the Java code I get the TariffID type as expected, but in
> the generated setTariffID(int) method, there is no code that captures the
> <xsd:totalDigits> restriction:
>
> /**
>  * Auto generated setter method
>  * @param param TariffID
>  */
>   public void setTariffID(int param){
>     this.localTariffID=param;
>   }
>
> If I then add either <xsd:pattern> or <xsd:minInclusive> and
> <xsd:maxInclusive> to the XSD then these restrictions are captured in the
> generated code.  For example, this:
>
> <xsd:simpleType name="tariffID">
>     <xsd:annotation>
>         <xsd:documentation>Standard tariff ID</xsd:documentation>
>     </xsd:annotation>
>     <xsd:restriction base="xsd:int">
>         <xsd:totalDigits value="7"/>
>         <xsd:minInclusive value="0"/>
>         <xsd:maxInclusive value="9999999"/>
>     </xsd:restriction>
> </xsd:simpleType>
>
> results in the following Java code being generated:
>
> /**
>  * Auto generated setter method
>  * @param param TariffID
>  */
> public void setTariffID(int param){
>   if (org.apache.axis2.databinding.utils.ConverterUtil.compare(param,
> "9999999") <= 0){
>     this.localTariffID=param;
>   }
>   else {
>     throw new java.lang.RuntimeException();
>   }
>   if (org.apache.axis2.databinding.utils.ConverterUtil.compare(param, "0")
>>= 0){
>     this.localTariffID=param;
>   }
>   else {
>     throw new java.lang.RuntimeException();
>   }
> }
>
> My question then is this, why is the <xsd:totalDigits> restriction not
> captured in the code  generated by Axis2? Is this expected behaviour or is
> it a bug?

Bug. This is still not supported by ADB. please log a jira.
Try to generate a code with other databiding framework like jaxbri or xmlbeans.

thanks,
Amila
>
> This is using v1.3, but I am seeing the same behaviour in v1.4.1 as well.
>
> Thanks,
> Colin.
>


-- 
Amila Suriarachchi
WSO2 Inc.
blog: http://amilachinthaka.blogspot.com/