Details
Description
When generating ADB code with wsdl2java from using the helper mode (option -Eh) the generated code is in some cases uncompilable. Further the generated code is logically wrong.
The problem with the compiling occurs if either minInclusive or minExclusive and maxInclusive or maxExclusive restrictions are used
Example
<simpleType name="MaxNoOfHits">
<restriction base="int">
<minInclusive value="10"></minInclusive>
<maxInclusive value="50"></maxInclusive>
</restriction>
</simpleType>
is producing following code:
public void setMaxNoOfHits(int param) throws Exception{
if ( 10 <= param >= 50 )
{ this.localMaxNoOfHits=param; }else
{ throw new ADBException(); }}
The line "if ( 10 <= param >= 50 ) {" won't compile due to a syntax error - the correct way to compile succesfully would be "if ( 10 <= param && param >= 50 ) {"
The same line contains the logical bug - the value of the variable should be between 10 and 50 inclusive - but the validation of the max limit is expecting a value
equal or over the value from the schema. Correct would be ( 10 <= param && param <= 50 ) {
Similar length validation exists for string variables where code like if "( (0 < param.length()) && (param.length() => 20) ) {" is produced for a string restricted to have
length between 0 exclusive and 20 inclusive.
A way of fixing the compilation issue and the validation problem:
<xsl:when test="(@maxExFacet) or (@minExFacet) or (@maxInFacet) or (@minInFacet)">
if (<xsl:if test="(@minExFacet)"> <xsl:value-of select="$minExFacet"/> < </xsl:if> <xsl:if test="(@minInFacet)"> <xsl:value-of select="$minInFacet"/> <= </xsl:if>
param <xsl:if test="((@minInFacet) or (@minExFacet)) and ((@minInFacet) or (@maxIntFacet))"> && param </xsl:if>
<xsl:if test="(@maxExFacet)"> < <xsl:value-of select="$maxExFacet"/> </xsl:if> <xsl:if test="(@maxInFacet)"> <= <xsl:value-of select="$maxInFacet"/> </xsl:if> )
else {