+1  A: 

You're reading the value of an XML attribute, and you're trying to assign it to something of type TPartNum_Sku. The compile-time type of the attribute value is OleVariant, but since XML attributes are always strings, the run-time type of the value stored in that OleVariant will always be WideString. It will never hold a value of type TPartNum_Sku, so your goal of defining that class to be compatible with OleVariant is misguided because they don't need to be compatible. (Just because that's what the compiler says the problem is doesn't mean that's how you need to fix it. The compiler sometimes says "semicolon expected," but it rarely means you should add a semicolon right there.)

The entire point of having your Get_PartNum function is so that you can convert the string attribute value into a TPartNum_Sku object. If TPartNum_Sku is a class, you could call its constructor:

Result := TPartNum_Sku.Create(AttributeNodes['partNum'].NodeValue);

Beware, though, that when you do that, the caller of Get_PartNum is responsible for freeing that object.

If your type is an enumeration, then your conversion depends on what the attribute value is. If it's the numeric value of the enumeration, then you could use this:

Result := TPartNum_Sku(StrToInt(AttributeNodes['partNum'].NodeValue));

If it's the string name, then you could try this:

Result := TPartNum_Sku(GetEnumValue(TypeInfo(TPartNum_Sku),
                                    AttributeNodes['partNum'].NodeValue);

GetEnumValue is in the TypInfo unit. You could also try IdentToInt, from the Classes unit.

You'll have to write inverse code for your Set_PartNum function, too.

Rob Kennedy
Thank you for your reply. Next excuse for my bad English :-)What you have proposed is understandable.But I have a somewhat different problem: there is a XSD file on it is generated using XML Data Binding pas-file with the classes and interfaces describing the scheme and would like to take this pas-file, changing the minimum, while having normal classes for work.
Mielofon
While we have simple types like integer, string, etc. everything works. But once you want something strange, you have to enter their types (that allows itself XML Data Binding) and edit the generated code.The result is very unpleasant to work when the scheme changes.
Mielofon