You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by "Leszczynski, Leszek" <le...@hp.com> on 2007/08/21 15:24:16 UTC

Field types from XML types with restrictions

Hi,
 
I am starting with XMLBeans and just hit the wall. I have a XSD schema with an element defined:
 
<xs:element name="year" nillable="true">
    <xs:simpleType>
        <xs:restriction base="xs:integer">
            <xs:totalDigits value="4"/>
        </xs:restriction>
    </xs:simpleType>
</xs:element>

The resulting "year" property in the generated bean gets "int" type - because of the totalDigits restriction (if I understand correctly) - without the restriction it becomes a BigInteger. Now, if I want to have an empty "year" element, I have to call setNilYear(), which is less comfortable than just calling setYear(null). Moreover, because the data for the bean comes from a webform, I am forced to explicitly check if the data is null. Can I somehow influence the code generator to generate BigInteger regardless of the restriction?

Help?

Regards,
LL
 
Leszek Leszczyński
Hewlett - Packard
Global Delivery Application Services
Poland Center
Phone: +48 22 565 3096
E-mail: leszek.leszczynski@hp.com <ma...@hp.com> 

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


Re: Field types from XML types with restrictions

Posted by Jacob Danner <ja...@gmail.com>.
Hi Leszek,
I don't remeber the rules off the top of my head but I thought it was
outlined in the one of the getting started docs. I'll try to skim a
more detailed answer for you tommorow.

I do have one question for you regarding this type. Since you are
using it to represent a year, why not use the xsd:gYear type? I'm
guessing it would save you a lot of time trying to validate things,
etc.

-Jacob Danner



On 8/21/07, Leszczynski, Leszek <le...@hp.com> wrote:
> Hi,
>
> I am starting with XMLBeans and just hit the wall. I have a XSD schema with
> an element defined:
>
> <xs:element name="year" nillable="true">
>     <xs:simpleType>
>         <xs:restriction base="xs:integer">
>             <xs:totalDigits value="4"/>
>         </xs:restriction>
>     </xs:simpleType>
> </xs:element>
>
> The resulting "year" property in the generated bean gets "int" type -
> because of the totalDigits restriction (if I understand correctly) - without
> the restriction it becomes a BigInteger. Now, if I want to have an empty
> "year" element, I have to call setNilYear(), which is less comfortable than
> just calling setYear(null). Moreover, because the data for the bean comes
> from a webform, I am forced to explicitly check if the data is null. Can I
> somehow influence the code generator to generate BigInteger regardless of
> the restriction?
>
> Help?
>
> Regards,
> LL
>
> Leszek Leszczyński
> Hewlett - Packard
> Global Delivery Application Services
> Poland Center
> Phone: +48 22 565 3096
> E-mail: leszek.leszczynski@hp.com <ma...@hp.com>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>