[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlbeans-dev
Subject:    [jira] Commented: (XMLBEANS-175) Validation of decimal in
From:       "Ian Jones (JIRA)" <xmlbeans-dev () xml ! apache ! org>
Date:       2006-06-13 7:19:30
Message-ID: 9706576.1150183170624.JavaMail.jira () brutus
[Download RAW message or body]

    [ http://issues.apache.org/jira/browse/XMLBEANS-175?page=comments#action_12415962 \
] 

Ian Jones commented on XMLBEANS-175:
------------------------------------

I've been experiencing the same issue, and agree the exponents 1.5 BigDecimal spits \
out are not valid in xs:decimal.

However the above workaround does not always work:

java.lang.System.out.println(new java.math.BigDecimal("0.00000001").toString());
java.lang.System.out.println(new java.math.BigDecimal(new \
java.math.BigDecimal("1E-8").toPlainString()).toString());

Prints out:

1E-8
1E-8

I agree with Johannes that the long term solution is to use \
BigDecimal.toPlainString() when creating an xml document within the xml beans code \
(JavaDecimalHolder.compute_text). However, this would make xmlbeans incompatible with \
Java 1.4. Perhaps an 'is 1.5' option could be used when generating code and use \
toString and toPlainString when appropriate.

I also agree using XmlDecimal is a possible solution, but that rather bloats my code \
(3 lines for every 'set' that used to be 1 line). My current work around is to use a \
PlainBigDecimal class which extends BigDecimal and overrides toString to call \
toPlainString.

Ian

> Validation of decimal in exponential representation fails
> ---------------------------------------------------------
> 
> Key: XMLBEANS-175
> URL: http://issues.apache.org/jira/browse/XMLBEANS-175
> Project: XMLBeans
> Type: Bug

> Components: Validator
> Versions: Version 2
> Reporter: Johannes Stamminger
> Assignee: Radu Preotiuc-Pietro
> Attachments: TestExponent.jar, TestExponent.xsd, XMLBeansExponentTest.java
> 
> Having an attribute of type xsd:decimal. Validating a document having set the \
> attribute to "4.2E1" fails with error message "unexpected char '69'" (char '69' is \
> the E). Value "42" works fine. Other XML parsers validate "4.2E1" successfully.
> Parsing fails in org.apache.xmlbeans.impl.values.JavaDecimalHolder#validateLexical(String, \
>                 ValidationContext).
> BTW: according to my XML documentation, type xsd:decimal is "same as \
> java.math.BigDecimal". If this info is correct: IMHO it would be better to rely the \
> BigDecimal-parsing capability ... ?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic