[xsd-users] Code generation error when using doubles and attributes (?)

WEBER Stefan stefan.weber at efgfp.com
Mon Feb 2 10:48:09 EST 2009


Hi,
 
I have the following schema:
 
    <xs:element name="foo" type="Foo">
 
    <xs:complexType name="Foo">
        <xs:sequence>
            <xs:element name="bar" type="Bar"/>
        </xs:sequence>
    </xs:complexType>
 
    <xs:complexType name="Bar">
        <xs:simpleContent>
            <xs:extension base="xs:double">
                <xs:attribute name="myAttr" type="xs:string"
use="required"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
 
This all worked fine when I used xs:float rather than xs:double as a
base type of "Bar". However, with xs:double, there seems to be a
problem/bug:
 
When I want to access the value as follows:
 
Foo foo;
//...
cout << foo.bar();
 
I get a completely different number than the one in the XML document. I
tried to trace down the issue and found that
 
double traits<double, C, schema_type::double_>::create
 
returns the correct value when called from fundamental_base constructor
(which is called from the constructor of Bar because Bar derives from
it):
template <typename T, typename C, typename B, schema_type::value ST>
fundamental_base<T, C, B, ST>::fundamental_base (const
xercesc::DOMElement& e, flags f, container* c)
    : B (e, f, c),
      facet_table_ (0),
      x_ (traits<T, C, ST>::create (e, f, c))
{}

However, x_ holds the wrong value (even though traits returns the
correct value, as mentioned above). Returning from this constructor into
the constructor of "Bar", I noticed that Visual Studio shows that Bar
derives from fundamental_base<float, ...> rather than
fundamental_base<double, ...> (e.g. by inspecting the this reference in
the Locals/Auto window of the VS debugger).
In the source, it is correct everywhere, it is just the runtime
information of the visual studio debugger that says it's of type
fundamental_base<float, ...>. Probably, this is the reason why x_ is set
to the wrong value.

When I remove the attribute, i.e. use xs:double as the type of the
element "bar", everything works just fime.

Is this a known bug or can someone reproduce that?

Thanks,

Stefan


==== The EFG Mail Gateway made the following annotation =====
This message is for the addressee only and may contain confidential or
privileged information. You must delete and not use it if you are not
the intended recipient. It may not be secure or error-free. All e-mail
communications to and from the EFG Financial Products Group may be monitored.
Processing of incoming e-mails cannot be guaranteed. Any views expressed
in this message are those of the individual sender. This message is for
information purposes only. All liability of the EFG Financial Products Group
and its entities for any damages resulting from e-mail use is excluded.
US persons are kindly requested to read the important legal information
presented at following URL: http://www.efgfp.com. If you suspect that the
message may have been intercepted or amended, please call the sender.
Should you require any further information, please contact the Compliance
Manager on compliance at efgfp.com.
=============================================================



More information about the xsd-users mailing list