Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Encounter "Could not convert variant of type (Null) into type (boolean)" when using default constraints for attribute of type "xs:boolean"

582 views
Skip to first unread message

Chau Chee Yang

unread,
Oct 5, 2005, 9:50:04 PM10/5/05
to
Hi,

I am using XML Data Binding to generate the Delphi XML class from XSD
file. I found the Attribute's default value isn't implemented in the
wizard or is there any other alternative way to make it work?

For example, if I have the following attribute:

<xs:complexType name="Control">
<xs:attribute name="Caption" type="xs:string"/>
<xs:attribute name="Visible" type="xs:boolean" default="True"/>
</xs:compleType>

If my XML content is as follow:

<Control Caption="Test"/>

Later if I use the XML class:

Control.Caption will return "Test" but Control.Visible will always
return "Could not convert variant of type (Null) into type (boolean)"
error. If the insert the Visible attribute into XML:

<Control Caption="Test" Visible="True" />

then it works fine.

Please advice. Thank you.

--
Best regards,
Chau Chee Yang

E Stream Software Sdn Bhd
URL: www.sql.com.my
SQL Financial Accounting

Khari Villela

unread,
Oct 7, 2005, 2:17:41 AM10/7/05
to
I think I ran into a similar issue. You have to include the unit Variants
and Delphi will be able to do the conversions correctly.

khariV

khariv

unread,
Oct 7, 2005, 8:08:57 PM10/7/05
to
I had this same problem with Delphi 2005, but mine said cannot convert
Integer to variant. If you add Variants to the uses clause, the unit
should compile correctly.

--- posted by geoForum on http://delphi.newswhat.com

0 new messages