请问如何创建XML Data Binding封装的XML文档的实例(0分)

  • 主题发起人 失败者
  • 开始时间

失败者

Unregistered / Unconfirmed
GUEST, unregistred user!
{******************************************************************}
{ }
{ Delphi XML Data Binding }
{ }
{ Generated on: 01-12-19 23:04:50 }
{ Generated from: D:/working/axletree/doc/20011125_now.xml }
{ Settings stored in: D:/working/axletree/doc/20011125_now.xdb }
{ }
{******************************************************************}
unit xml;
interface
uses xmldom, XMLDoc, XMLIntf;
type
{ Forward Decls }
IXMLBonusFormulaType = interface;
IXMLDepartmentType = interface;
IXMLDepartmentTypeList = interface;
IXMLBonusType = interface;
IXMLBonusTypeList = interface;
IXMLString_List = interface;
{ IXMLBonusFormulaType }
IXMLBonusFormulaType = interface(IXMLNode)
['{CBCAB041-F4D4-11D5-8583-BBB6C2BA6175}']
{ Property Accessors }
function Get_MainHour: WideString;
function Get_Department: IXMLDepartmentTypeList;
procedure Set_MainHour(Value: WideString);
{ Methods &
Properties }
property MainHour: WideString read Get_MainHour write Set_MainHour;
property Department: IXMLDepartmentTypeList read Get_Department;
end;

{ IXMLDepartmentType }
IXMLDepartmentType = interface(IXMLNode)
['{CBCAB042-F4D4-11D5-8583-BBB6C2BA6175}']
{ Property Accessors }
function Get_Designation: WideString;
function Get_Bonus: IXMLBonusTypeList;
procedure Set_Designation(Value: WideString);
{ Methods &
Properties }
property Designation: WideString read Get_Designation write Set_Designation;
property Bonus: IXMLBonusTypeList read Get_Bonus;
end;

{ IXMLDepartmentTypeList }
IXMLDepartmentTypeList = interface(IXMLNodeCollection)
['{CBCAB043-F4D4-11D5-8583-BBB6C2BA6175}']
{ Methods &
Properties }
function Add: IXMLDepartmentType;
function Insert(const Index: Integer): IXMLDepartmentType;
function Get_Item(Index: Integer): IXMLDepartmentType;
property Items[Index: Integer]: IXMLDepartmentType read Get_Item;
default;
end;

{ IXMLBonusType }
IXMLBonusType = interface(IXMLNode)
['{CBCAB044-F4D4-11D5-8583-BBB6C2BA6175}']
{ Property Accessors }
function Get_ManHour: Integer;
function Get_HourBouns: WideString;
function Get_Formula: IXMLString_List;
procedure Set_ManHour(Value: Integer);
procedure Set_HourBouns(Value: WideString);
{ Methods &
Properties }
property ManHour: Integer read Get_ManHour write Set_ManHour;
property HourBouns: WideString read Get_HourBouns write Set_HourBouns;
property Formula: IXMLString_List read Get_Formula;
end;

{ IXMLBonusTypeList }
IXMLBonusTypeList = interface(IXMLNodeCollection)
['{CBCAB045-F4D4-11D5-8583-BBB6C2BA6175}']
{ Methods &
Properties }
function Add: IXMLBonusType;
function Insert(const Index: Integer): IXMLBonusType;
function Get_Item(Index: Integer): IXMLBonusType;
property Items[Index: Integer]: IXMLBonusType read Get_Item;
default;
end;

{ IXMLString_List }
IXMLString_List = interface(IXMLNodeCollection)
['{CBCAB046-F4D4-11D5-8583-BBB6C2BA6175}']
{ Methods &
Properties }
function Add(const Value: WideString): IXMLNode;
function Insert(const Index: Integer;
const Value: WideString): IXMLNode;
function Get_Item(Index: Integer): WideString;
property Items[Index: Integer]: WideString read Get_Item;
default;
end;

{ Forward Decls }
TXMLBonusFormulaType = class;
TXMLDepartmentType = class;
TXMLDepartmentTypeList = class;
TXMLBonusType = class;
TXMLBonusTypeList = class;
TXMLString_List = class;
{ TXMLBonusFormulaType }
TXMLBonusFormulaType = class(TXMLNode, IXMLBonusFormulaType)
private
FDepartment: IXMLDepartmentTypeList;
protected
{ IXMLBonusFormulaType }
function Get_MainHour: WideString;
function Get_Department: IXMLDepartmentTypeList;
procedure Set_MainHour(Value: WideString);
public
procedure AfterConstruction;
override;
property MainHour: WideString read Get_MainHour write Set_MainHour;
property Department: IXMLDepartmentTypeList read Get_Department;
end;

{ TXMLDepartmentType }
TXMLDepartmentType = class(TXMLNode, IXMLDepartmentType)
private
FBonus: IXMLBonusTypeList;
protected
{ IXMLDepartmentType }
function Get_Designation: WideString;
function Get_Bonus: IXMLBonusTypeList;
procedure Set_Designation(Value: WideString);
public
procedure AfterConstruction;
override;
end;

{ TXMLDepartmentTypeList }
TXMLDepartmentTypeList = class(TXMLNodeCollection, IXMLDepartmentTypeList)
protected
{ IXMLDepartmentTypeList }
function Add: IXMLDepartmentType;
function Insert(const Index: Integer): IXMLDepartmentType;
function Get_Item(Index: Integer): IXMLDepartmentType;
end;

{ TXMLBonusType }
TXMLBonusType = class(TXMLNode, IXMLBonusType)
private
FFormula: IXMLString_List;
protected
{ IXMLBonusType }
function Get_ManHour: Integer;
function Get_HourBouns: WideString;
function Get_Formula: IXMLString_List;
procedure Set_ManHour(Value: Integer);
procedure Set_HourBouns(Value: WideString);
public
procedure AfterConstruction;
override;
end;

{ TXMLBonusTypeList }
TXMLBonusTypeList = class(TXMLNodeCollection, IXMLBonusTypeList)
protected
{ IXMLBonusTypeList }
function Add: IXMLBonusType;
function Insert(const Index: Integer): IXMLBonusType;
function Get_Item(Index: Integer): IXMLBonusType;
end;

{ TXMLString_List }
TXMLString_List = class(TXMLNodeCollection, IXMLString_List)
protected
{ IXMLString_List }
function Add(const Value: WideString): IXMLNode;
function Insert(const Index: Integer;
const Value: WideString): IXMLNode;
function Get_Item(Index: Integer): WideString;
end;

{ Global Functions }
function GetbonusFormula(Doc: IXMLDocument): IXMLBonusFormulaType;
function LoadbonusFormula(const FileName: WideString): IXMLBonusFormulaType;
function NewbonusFormula: IXMLBonusFormulaType;
implementation
{ Global Functions }
function GetbonusFormula(Doc: IXMLDocument): IXMLBonusFormulaType;
begin
Result :=do
c.GetDocBinding('bonusFormula', TXMLBonusFormulaType) as IXMLBonusFormulaType;
end;
function LoadbonusFormula(const FileName: WideString): IXMLBonusFormulaType;
begin
Result := LoadXMLDocument(FileName).GetDocBinding('bonusFormula', TXMLBonusFormulaType) as IXMLBonusFormulaType;
end;

function NewbonusFormula: IXMLBonusFormulaType;
begin
Result := NewXMLDocument.GetDocBinding('bonusFormula', TXMLBonusFormulaType) as IXMLBonusFormulaType;
end;

{ TXMLBonusFormulaType }
procedure TXMLBonusFormulaType.AfterConstruction;
begin
RegisterChildNode('department', TXMLDepartmentType);
FDepartment := CreateCollection(TXMLDepartmentTypeList, IXMLDepartmentType, 'department') as IXMLDepartmentTypeList;
inherited;
end;

function TXMLBonusFormulaType.Get_MainHour: WideString;
begin
Result := ChildNodes['mainHour'].Text;
end;

procedure TXMLBonusFormulaType.Set_MainHour(Value: WideString);
begin
ChildNodes['mainHour'].NodeValue := Value;
end;

function TXMLBonusFormulaType.Get_Department: IXMLDepartmentTypeList;
begin
Result := FDepartment;
end;

{ TXMLDepartmentType }
procedure TXMLDepartmentType.AfterConstruction;
begin
RegisterChildNode('Bonus', TXMLBonusType);
FBonus := CreateCollection(TXMLBonusTypeList, IXMLBonusType, 'Bonus') as IXMLBonusTypeList;
inherited;
end;

function TXMLDepartmentType.Get_Designation: WideString;
begin
Result := ChildNodes['designation'].Text;
end;

procedure TXMLDepartmentType.Set_Designation(Value: WideString);
begin
ChildNodes['designation'].NodeValue := Value;
end;

function TXMLDepartmentType.Get_Bonus: IXMLBonusTypeList;
begin
Result := FBonus;
end;

{ TXMLDepartmentTypeList }
function TXMLDepartmentTypeList.Add: IXMLDepartmentType;
begin
Result := AddItem(-1) as IXMLDepartmentType;
end;

function TXMLDepartmentTypeList.Insert(const Index: Integer): IXMLDepartmentType;
begin
Result := AddItem(Index) as IXMLDepartmentType;
end;

function TXMLDepartmentTypeList.Get_Item(Index: Integer): IXMLDepartmentType;
begin
Result := List[Index] as IXMLDepartmentType;
end;

{ TXMLBonusType }
procedure TXMLBonusType.AfterConstruction;
begin
FFormula := CreateCollection(TXMLString_List, IXMLNode, 'formula') as IXMLString_List;
inherited;
end;

function TXMLBonusType.Get_ManHour: Integer;
begin
Result := ChildNodes['manHour'].NodeValue;
end;

procedure TXMLBonusType.Set_ManHour(Value: Integer);
begin
ChildNodes['manHour'].NodeValue := Value;
end;

function TXMLBonusType.Get_HourBouns: WideString;
begin
Result := ChildNodes['hourBouns'].Text;
end;

procedure TXMLBonusType.Set_HourBouns(Value: WideString);
begin
ChildNodes['hourBouns'].NodeValue := Value;
end;

function TXMLBonusType.Get_Formula: IXMLString_List;
begin
Result := FFormula;
end;

{ TXMLBonusTypeList }
function TXMLBonusTypeList.Add: IXMLBonusType;
begin
Result := AddItem(-1) as IXMLBonusType;
end;

function TXMLBonusTypeList.Insert(const Index: Integer): IXMLBonusType;
begin
Result := AddItem(Index) as IXMLBonusType;
end;

function TXMLBonusTypeList.Get_Item(Index: Integer): IXMLBonusType;
begin
Result := List[Index] as IXMLBonusType;
end;

{ TXMLString_List }
function TXMLString_List.Add(const Value: WideString): IXMLNode;
begin
Result := AddItem(-1);
Result.NodeValue := Value;
end;

function TXMLString_List.Insert(const Index: Integer;
const Value: WideString): IXMLNode;
begin
Result := AddItem(Index);
Result.NodeValue := Value;
end;

function TXMLString_List.Get_Item(Index: Integer): WideString;
begin
Result := List[Index].NodeValue;
end;

end.
 
顶部