Keith,
  Thanks for the reply.  My problem is that I thought that the
SourceGenerator would check the restrictions in the schema and generate
the appropriate code to make sure that data set to the bean is valid. 
So when it is actually marshalled (and validated), there would be no
problems.  For instance, if I have a java variable (double javaPrice)
set to 478.123456789, and then use the set method of the bean, it will
be mapped to a BigDecimal, and it will keep the precision.  So when it
gets marshalled, it will be invalid since it's too long.
  But I was under the assumption that the restriction base in the schema
would signal to the SourceGenerator to create code to truncate (or
round) it to 2 decimal places, thus avoiding any future validation
errors.  Otherwise, it seems to me that you can't use the xsd:decimal
type when generating the code unless it's mapped to String types, or if
you write all the type checking yourself and check the value before you
set the bean.  I'm still learning Castor, so I'm just not sure what to
expect out of the SourceGenerator.

Thanks
Tony

On Thu, 2004-06-10 at 22:08, Keith Visco wrote:
> Tony,
> 
> I'm not sure what the problem is here. Castor is reporting that you have
> set an incorrect value for the field. Castor validates before
> marshalling and reports the error to you. It doesn't modify values to
> make the valid, it just reports that the value is invalid.
> 
> --Keith
> 
> Tony Vann wrote:
> > 
> > Hi,
> >   Can someone tell me what I'm doing wrong with the following...
> > 
> > xsd snippet:
> > 
> > <xsd:element name="price">
> >   <xsd:simpleType>
> >     <xsd:restriction base="xsd:decimal">
> >       <xsd:totalDigits value="8"/>
> >       <xsd:fractionDigits value="2"/>
> >     </xsd:restriction>
> >   </xsd:simpleType>
> > </xsd:element>
> > 
> > Beans and descriptors are generated using SourceGenerator.  The price
> > element is mapped as a BigDecimal (inside the descriptor).  Inside my
> > code, I set the bean (price) to a double value that I extract from a
> > database... no problems there.  Well if the value is something like
> > 478.123456789, during marshalling, it does not validate, saying the
> > totalDigits should not exceed 8.
> > 
> > OK, that makes sense. But I was under the assumption that code would be
> > generated by SourceGenerator to take care of this, given the schema is
> > used to generate the code.  Am I wrong?  It says on the website that
> > castor supports decimals with totalDigits and fractionDigits, but is
> > that only for unmarshalling?
> > 
> > Thanks
> > Tony Vann
> > 
> > -----------------------------------------------------------
> > If you wish to unsubscribe from this mailing, send mail to
> > [EMAIL PROTECTED] with a subject of:
> >         unsubscribe castor-user
> 
> 
> 
> ----------------------------------------------------------- 
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-user
-- 
______________________________________
     Tony Vann
     Software Engineer 
     Planning Systems Inc.
     MSAAP Bldg 9121
     Stennis Space Center, MS  39529

     phone: 228-689-8443
     fax: 228-689-8499
     email: [EMAIL PROTECTED]
______________________________________



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

Reply via email to