unit template;
interface
uses xmldom, XMLDoc, XMLIntf;
type
{ Forward Decls }
IXMLCustomersType = interface;
IXMLCustomerType = interface;
IXMLConsignmentsType = interface;
IXMLConsignmentType = interface;
IXMLPiecesType = interface;
{ IXMLCustomersType }
IXMLCustomersType = interface(IXMLNodeCollection)
['{F1399E4C-5473-4573-AB0C-A9A4E12172CD}']
{ Property Accessors }
function Get_Customer(Index: Integer): IXMLCustomerType;
{ Methods & Properties }
function Add: IXMLCustomerType;
function Insert(const Index: Integer): IXMLCustomerType;
property Customer[Index: Integer]: IXMLCustomerType read Get_Customer; default;
end;
{ IXMLCustomerType }
IXMLCustomerType = interface(IXMLNode)
['{4AF93DBF-5CFD-4E7F-8407-E408F66C4EB1}']
{ Property Accessors }
function Get_Id: WideString;
function Get_Name: WideString;
function Get_Consignments: IXMLConsignmentsType;
procedure Set_Id(Value: WideString);
procedure Set_Name(Value: WideString);
{ Methods & Properties }
property Id: WideString read Get_Id write Set_Id;
property Name: WideString read Get_Name write Set_Name;
property Consignments: IXMLConsignmentsType read Get_Consignments;
end;
{ IXMLConsignmentsType }
IXMLConsignmentsType = interface(IXMLNodeCollection)
['{2608B7B2-D5C1-4E25-BFDA-5F414D6876FB}']
{ Property Accessors }
function Get_Consignment(Index: Integer): IXMLConsignmentType;
{ Methods & Properties }
function Add: IXMLConsignmentType;
function Insert(const Index: Integer): IXMLConsignmentType;
property Consignment[Index: Integer]: IXMLConsignmentType read Get_Consignment; default;
end;
{ IXMLConsignmentType }
IXMLConsignmentType = interface(IXMLNode)
['{38A478D2-7D16-42AA-9A36-A416774FF44A}']
{ Property Accessors }
function Get_Id: WideString;
function Get_Pieces: IXMLPiecesType;
procedure Set_Id(Value: WideString);
{ Methods & Properties }
property Id: WideString read Get_Id write Set_Id;
property Pieces: IXMLPiecesType read Get_Pieces;
end;
{ IXMLPiecesType }
IXMLPiecesType = interface(IXMLNodeCollection)
['{691D0D4F-7F7B-4951-83AF-4C60C10127BA}']
{ Property Accessors }
function Get_Piece(Index: Integer): WideString;
{ Methods & Properties }
function Add(const Piece: WideString): IXMLNode;
function Insert(const Index: Integer; const Piece: WideString): IXMLNode;
property Piece[Index: Integer]: WideString read Get_Piece; default;
end;
{ Forward Decls }
TXMLCustomersType = class;
TXMLCustomerType = class;
TXMLConsignmentsType = class;
TXMLConsignmentType = class;
TXMLPiecesType = class;
{ TXMLCustomersType }
TXMLCustomersType = class(TXMLNodeCollection, IXMLCustomersType)
protected
{ IXMLCustomersType }
function Get_Customer(Index: Integer): IXMLCustomerType;
function Add: IXMLCustomerType;
function Insert(const Index: Integer): IXMLCustomerType;
public
procedure AfterConstruction; override;
end;
{ TXMLCustomerType }
TXMLCustomerType = class(TXMLNode, IXMLCustomerType)
protected
{ IXMLCustomerType }
function Get_Id: WideString;
function Get_Name: WideString;
function Get_Consignments: IXMLConsignmentsType;
procedure Set_Id(Value: WideString);
procedure Set_Name(Value: WideString);
public
procedure AfterConstruction; override;
end;
{ TXMLConsignmentsType }
TXMLConsignmentsType = class(TXMLNodeCollection, IXMLConsignmentsType)
protected
{ IXMLConsignmentsType }
function Get_Consignment(Index: Integer): IXMLConsignmentType;
function Add: IXMLConsignmentType;
function Insert(const Index: Integer): IXMLConsignmentType;
public
procedure AfterConstruction; override;
end;
{ TXMLConsignmentType }
TXMLConsignmentType = class(TXMLNode, IXMLConsignmentType)
protected
{ IXMLConsignmentType }
function Get_Id: WideString;
function Get_Pieces: IXMLPiecesType;
procedure Set_Id(Value: WideString);
public
procedure AfterConstruction; override;
end;
{ TXMLPiecesType }
TXMLPiecesType = class(TXMLNodeCollection, IXMLPiecesType)
protected
{ IXMLPiecesType }
function Get_Piece(Index: Integer): WideString;
function Add(const Piece: WideString): IXMLNode;
function Insert(const Index: Integer; const Piece: WideString): IXMLNode;
public
procedure AfterConstruction; override;
end;
{ Global Functions }
function Getcustomers(Doc: IXMLDocument): IXMLCustomersType;
function Loadcustomers(const FileName: WideString): IXMLCustomersType;
function Newcustomers: IXMLCustomersType;
const
TargetNamespace = '';
implementation
{ Global Functions }
function Getcustomers(Doc: IXMLDocument): IXMLCustomersType;
begin
Result := Doc.GetDocBinding('customers', TXMLCustomersType, TargetNamespace) as IXMLCustomersType;
end;
function Loadcustomers(const FileName: WideString): IXMLCustomersType;
begin
Result := LoadXMLDocument(FileName).GetDocBinding('customers', TXMLCustomersType, TargetNamespace) as IXMLCustomersType;
end;
function Newcustomers: IXMLCustomersType;
begin
Result := NewXMLDocument.GetDocBinding('customers', TXMLCustomersType, TargetNamespace) as IXMLCustomersType;
end;
{ TXMLCustomersType }
procedure TXMLCustomersType.AfterConstruction;
begin
RegisterChildNode('customer', TXMLCustomerType);
ItemTag := 'customer';
ItemInterface := IXMLCustomerType;
inherited;
end;
function TXMLCustomersType.Get_Customer(Index: Integer): IXMLCustomerType;
begin
Result := List[Index] as IXMLCustomerType;
end;
function TXMLCustomersType.Add: IXMLCustomerType;
begin
Result := AddItem(-1) as IXMLCustomerType;
end;
function TXMLCustomersType.Insert(const Index: Integer): IXMLCustomerType;
begin
Result := AddItem(Index) as IXMLCustomerType;
end;
{ TXMLCustomerType }
procedure TXMLCustomerType.AfterConstruction;
begin
RegisterChildNode('consignments', TXMLConsignmentsType);
inherited;
end;
function TXMLCustomerType.Get_Id: WideString;
begin
Result := AttributeNodes['id'].Text;
end;
procedure TXMLCustomerType.Set_Id(Value: WideString);
begin
SetAttribute('id', Value);
end;
function TXMLCustomerType.Get_Name: WideString;
begin
Result := AttributeNodes['name'].Text;
end;
procedure TXMLCustomerType.Set_Name(Value: WideString);
begin
SetAttribute('name', Value);
end;
function TXMLCustomerType.Get_Consignments: IXMLConsignmentsType;
begin
Result := ChildNodes['consignments'] as IXMLConsignmentsType;
end;
{ TXMLConsignmentsType }
procedure TXMLConsignmentsType.AfterConstruction;
begin
RegisterChildNode('consignment', TXMLConsignmentType);
ItemTag := 'consignment';
ItemInterface := IXMLConsignmentType;
inherited;
end;
function TXMLConsignmentsType.Get_Consignment(Index: Integer): IXMLConsignmentType;
begin
Result := List[Index] as IXMLConsignmentType;
end;
function TXMLConsignmentsType.Add: IXMLConsignmentType;
begin
Result := AddItem(-1) as IXMLConsignmentType;
end;
function TXMLConsignmentsType.Insert(const Index: Integer): IXMLConsignmentType;
begin
Result := AddItem(Index) as IXMLConsignmentType;
end;
{ TXMLConsignmentType }
procedure TXMLConsignmentType.AfterConstruction;
begin
RegisterChildNode('pieces', TXMLPiecesType);
inherited;
end;
function TXMLConsignmentType.Get_Id: WideString;
begin
Result := AttributeNodes['id'].Text;
end;
procedure TXMLConsignmentType.Set_Id(Value: WideString);
begin
SetAttribute('id', Value);
end;
function TXMLConsignmentType.Get_Pieces: IXMLPiecesType;
begin
Result := ChildNodes['pieces'] as IXMLPiecesType;
end;
{ TXMLPiecesType }
procedure TXMLPiecesType.AfterConstruction;
begin
ItemTag := 'piece';
ItemInterface := IXMLNode;
inherited;
end;
function TXMLPiecesType.Get_Piece(Index: Integer): WideString;
begin
Result := List[Index].Text;
end;
function TXMLPiecesType.Add(const Piece: WideString): IXMLNode;
begin
Result := AddItem(-1);
Result.NodeValue := Piece;
end;
function TXMLPiecesType.Insert(const Index: Integer; const Piece: WideString): IXMLNode;
begin
Result := AddItem(Index);
Result.NodeValue := Piece;
end;
end.