Re: FW:

Carlos Emanuel Madruga de Sousa <[email protected]>
Newsgroups gmane.text.xml.axis.user
Message-ID <CAHMXucF=wCwk75yGc+JpYLUeySZBbEh3NzH7Ou_1jBeaAdVDTg@mail.gmail.com>
Hi Martin,
    Thanks for your help. Based on your response, if I have the restriction:

<xsd:restriction base="xsd:decimal">
  <xsd:totalDigits value="13" />
  <xsd:fractionDigits value="3" />
</xsd:restriction>

any number between 10^-12 and 10^13, as you said, *should* work.

But, the code generated by axis, only numbers bigger than 99999999999999.0
is valid.
The generated code is:

java.lang.String totalDigitsDecimal =
org.apache.axis2.databinding.utils.ConverterUtil.convertToStandardDecimalNotation("13").toString();
if (org.apache.axis2.databinding.utils.ConverterUtil.compare(param,
totalDigitsDecimal) > 0){
    this.localI_QUANTITY_type0=param;
}
else {
    throw new java.lang.RuntimeException();
}


If I the parameter param is BigDecimal("100.00") the validation will fail
and I'll receive a RuntimeException.
The method ConverterUtil.compare(param, totalDigitsDecimal) is:

public static double compare(BigDecimal binBigDecimal, String value) {
    return binBigDecimal.doubleValue() - Double.parseDouble(value);
}

binBigDecimal = BigDecimal("100.00") and totalDigitsDecimal = "1.0E+13" and
 the return of compare is -9.9999999999E12 witch is minor than zero.

I guess the correct code of the ConverterUtil.compare(BigDecimal
binBigDecimal, String value) should be:

public static double compare(BigDecimal binBigDecimal, String value) {
    return Double.parseDouble(value) - binBigDecimal.doubleValue();
}

With this change, Double.parseDouble(value) - binBigDecimal.doubleValue(),
instead of, binBigDecimal.doubleValue() - Double.parseDouble(value) any
number between 10^-12 and 10^13 is valid.

My understanding is correct ?

Thanks,


2012/11/13 Martin Gainty <[email protected]>

>
>
> --Forwarded Message Attachment--
> From: [email protected]
> To: [email protected]
> Subject: RE: Restriction totalDigits
> Date: Tue, 13 Nov 2012 12:33:10 -0500
>
>  Buenas Tardes / Boa tarde
>
> the restriction of applicable values is based on the upper and lower
> limits of the xsd:decimal datatype..assuming this is your namespace
> declaration
> *xmlns*:*xsd*="http://www.w3.org/2001/XMLSchema"
> 3.2.3 decimal [Definition:]  *decimal* represents a subset of the real
> numbers, which can be represented by decimal numerals. The ·value space·<http://www.w3.org/TR/xmlschema-2/#dt-value-space>of
> *decimal* is the set of numbers that can be obtained by multiplying an
> integer by a non-positive power of ten, i.e., expressible as *i × 10^-n*where
> *i* and *n* are integers and *n >= 0*. Precision is not reflected in this
> value space; the number 2.0 is not distinct from the number 2.00. The ·
> order-relation· <http://www.w3.org/TR/xmlschema-2/#dt-order-relation> on *
> decimal* is the order relation on real numbers, restricted to this
> subset.
>
>
> *Note: * All ·minimally conforming·<http://www.w3.org/TR/xmlschema-2/#dt-minimally-conforming>processors
> ·must· <http://www.w3.org/TR/xmlschema-2/#dt-must> support decimal
> numbers with a minimum of 18 decimal digits (i.e., with a ·totalDigits·<http://www.w3.org/TR/xmlschema-2/#dt-totalDigits>of 18). However,
> ·minimally conforming·<http://www.w3.org/TR/xmlschema-2/#dt-minimally-conforming>processors
> ·may· <http://www.w3.org/TR/xmlschema-2/#dt-may> set an
> application-defined limit on the maximum number of decimal digits they are
> prepared to support, in which case that application-defined maximum number
> ·must· <http://www.w3.org/TR/xmlschema-2/#dt-must> be clearly documented.
>
> so if  your decimal_number is within range 1*10^-8 >= decimal_number <=
> 1*10^+9
>
> *should* work
>
> but you *can* override the length attribute of decimal type by specifying
> totalDigits
> http://www.w3.org/TR/xmlschema-2/#rf-totalDigits
>
> if you are certain the values of your number will always be positive you
> may want to declare the element as positiveInteger
> http://www.w3.org/TR/xmlschema-2/#positiveInteger
>
> Obrigado!
> Martin Gainty
> ______________________________________________
> Porfavor..no altere ni interrumptir esta communicacion..Gracias
>  Por favor, não alterar ou interromper esta transmissão..Obrigado
>
>
>
> ------------------------------
> From: [email protected]
> Date: Tue, 13 Nov 2012 08:49:47 -0300
> Subject: Restriction totalDigits
> To: [email protected]
>
> Hi to all,
>     I'm having problems with restriction totalDigits to type decimal.
> <xsd:restriction base="xsd:decimal">
>   <xsd:totalDigits value="13" />
>   <xsd:fractionDigits value="3" />
> </xsd:restriction>
>
> By this restriction the minor valid number is 99999999999999.0 because the
> code generate by axis. On totalDigits restriction I understand that is
> valid any number between 0 and 10^13. Am I right? Or this restriction is to
> numbers bigger than 99999999999999.0 ?
>
> Thanks,
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.