Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Internet/XML/Data Binding    [ Add a report in this area ]  
Report #:  8273   Status: Open
Add basic support for enumerated types when binding to an XML Schema
Project:  Delphi Build #:  8.1
Version:    7.0 Submitted By:   Joe McCurdy
Report Type:  New Feature Request Date Reported:  5/26/2004 2:55:52 PM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   209517
Resolution: Deferred to Next Rel (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
5.00 out of 5
Total Votes: 20
Description
Automate the generation of the code to support enumeration restrictions, as shown in example in "Steps" tab.

Steps to Reproduce:
unit MyXMLBinding;

interface

uses ..., TypInfo, ...;

type TMyEnumeratedType = (etNone, etOne, etTwo, etThree);

  IXMLMyEnumNode = interface(IXMLNode)
    ['{guid}']
    { Property Accessors }
    function Get_MyET: TMyEnumeratedType;
    procedure Set_MyET(value: TMyEnumeratedType);
    { Methods & Properties }
    property MyET: TMyEnumeratedType read Get_...
...
implementation
...

function Get_MyET: TMyEnumeratedType;
begin
  if AttributeNodes['MyEnum'].Text <> '' then
    Result := TMyEnumeratedType(GetEnumValue(TypeInfo(TMyEnumeratedType)AttributeNodes['MyEnum'].Text))
  else
    Result := etNone;
end;

procedure Set_MyET(value: TMyEnumeratedType);
begin
  SetAttribute('MyEnum', GetEnumName(TypeInfo(TMyEnumeratedType), Ord(Value)));
end;

end.


Where the source XSD has a definition as follows:

<xs:complexType name="MyEnumNode">
<xs:attribute name="MyEnum">
  <xs:simpleType>
   <xs:restriction base="xs:string">
    <xs:enumeration value="etNone" />
    <xs:enumeration value="etOne" />
    <xs:enumeration value="etTwo" />
    <xs:enumeration value="etThree" />
   </xs:restriction>
  </xs:simpleType>
</xs:attribute>
</xs:complexType>


Or, instead of creating a new enumerated type, the binding wizard could offer to make use of any existing enumeration, such as TFontStyles, etc., in the "DataType" combobox.
Workarounds
None
Attachment
None
Comments

None

Server Response from: ETNACODE01