You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by Jose Luis Huertas Fernández <jo...@gmail.com> on 2007/07/10 14:31:02 UTC

Problem with primitive types and optional elements

Hi everybody!

We are having problems with some elements defined as optional in the XSD
(minOccurs="0"). Those elements are defined of type xs:double and Jaxme is
creating attributes of type double (primitive) in the Java beans.

The problem is that I cannot see the difference between:

a) the element is not present in the XML
b) the element is present with value 0.0

any idea? is it possible to setup jaxme to use Double (object) type instead
of double (primitive)?

Best regards,

José Luis.

Re: Problem with primitive types and optional elements

Posted by Jose Luis Huertas Fernández <jo...@gmail.com>.
Thanks Jochen, it works like a charm!

Just a curiosity... I had to rewrite my XSDs for this solution to work from
something like this:

              <xs:element name="FH_SN" nillable="true" minOccurs="0"
type="xs:double">
                <xs:simpleType>
                  <xs:restriction base="xs:double">
                    <xs:annotation>
                      <xs:appinfo>
                        <jxb:property>
                          <jxb:baseType>
                            <jxb:javaType name="java.lang.Double"/>
                          </jxb:baseType>
                        </jxb:property>
                      </xs:appinfo>
                    </xs:annotation>
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>

to this:

              <xs:element name="FH_SN" nillable="true" minOccurs="0"
type="xs:double">
                    <xs:annotation>
                      <xs:appinfo>
                        <jxb:property>
                          <jxb:baseType>
                            <jxb:javaType name="java.lang.Double"/>
                          </jxb:baseType>
                        </jxb:property>
                      </xs:appinfo>
                    </xs:annotation>
              </xs:element>

which BTW seems a more concise and elegant notation but... are you aware of
any significant difference between both ways? why first one didn't work?

Thanks for your help,

Jose Luis.

2007/7/10, Jochen Wiedmann <jo...@gmail.com>:
>
> On 7/10/07, Jose Luis Huertas Fernández
> <jo...@gmail.com> wrote:
>
> > any idea? is it possible to setup jaxme to use Double (object) type
> instead
> > of double (primitive)?
>
> Yes, that's possible. See for example this mail:
>
>     http://www.mail-archive.com/jaxme-dev@ws.apache.org/msg01553.html
>
> Jochen
>
> --
> "Besides, manipulating elections is under penalty of law, resulting in
> a preventative effect against manipulating elections.
>
> The german government justifying the use of electronic voting machines
> and obviously  believing that we don't need a police, because all
> illegal actions are forbidden.
>
> http://dip.bundestag.de/btd/16/051/1605194.pdf
>

Re: Problem with primitive types and optional elements

Posted by Jochen Wiedmann <jo...@gmail.com>.
On 7/10/07, Jose Luis Huertas Fernández
<jo...@gmail.com> wrote:

> any idea? is it possible to setup jaxme to use Double (object) type instead
> of double (primitive)?

Yes, that's possible. See for example this mail:

    http://www.mail-archive.com/jaxme-dev@ws.apache.org/msg01553.html

Jochen

-- 
"Besides, manipulating elections is under penalty of law, resulting in
a preventative effect against manipulating elections.

The german government justifying the use of electronic voting machines
and obviously  believing that we don't need a police, because all
illegal actions are forbidden.

http://dip.bundestag.de/btd/16/051/1605194.pdf

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