{*******************************************************************************************************************}
{ }
{
XML-Datenbindung }
{ }
{ }
{*******************************************************************************************************************}
unit bestellung;
interface
uses xmldom, XMLDoc, XMLIntf;
type
{ Forward-Deklarationen }
IXMLBestellungType = interface;
IXMLString_List = interface;
{ IXMLBestellungType }
IXMLBestellungType = interface(IXMLNode)
['{C22F408D-DD5E-4DFA-93C9-40DE9C33353D}']
{ Eigenschaftszugriff }
function Get_Nummer: IXMLString_List;
function Get_Name: IXMLString_List;
function Get_Menge: Integer;
function Get_Preis: WideString;
function Get_Lieferadresse: WideString;
procedure Set_Menge(Value: Integer);
procedure Set_Preis(Value: WideString);
procedure Set_Lieferadresse(Value: WideString);
{ Methoden & Eigenschaften }
property Nummer: IXMLString_List read Get_Nummer;
property Name: IXMLString_List read Get_Name;
property Menge: Integer read Get_Menge write Set_Menge;
property Preis: WideString read Get_Preis write Set_Preis;
property Lieferadresse: WideString read Get_Lieferadresse write Set_Lieferadresse;
end;
{ IXMLString_List }
IXMLString_List = interface(IXMLNodeCollection)
['{D1C92B35-3E8B-4F24-8C39-5D79E6109B00}']
{ Methoden & Eigenschaften }
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-Deklarationen }
TXMLBestellungType = class;
TXMLString_List = class;
{ TXMLBestellungType }
TXMLBestellungType = class(TXMLNode, IXMLBestellungType)
private
FNummer: IXMLString_List;
FName: IXMLString_List;
protected
{ IXMLBestellungType }
function Get_Nummer: IXMLString_List;
function Get_Name: IXMLString_List;
function Get_Menge: Integer;
function Get_Preis: WideString;
function Get_Lieferadresse: WideString;
procedure Set_Menge(Value: Integer);
procedure Set_Preis(Value: WideString);
procedure Set_Lieferadresse(Value: WideString);
public
procedure AfterConstruction; override;
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;
{ Globale Funktionen }
function Getbestellung(Doc: IXMLDocument): IXMLBestellungType;
function Loadbestellung(const FileName: WideString): IXMLBestellungType;
function Newbestellung: IXMLBestellungType;
const
TargetNamespace = '';
implementation
{ Globale Funktionen }
function Getbestellung(Doc: IXMLDocument): IXMLBestellungType;
begin
Result := Doc.GetDocBinding('bestellung', TXMLBestellungType, TargetNamespace) as IXMLBestellungType;
end;
function Loadbestellung(const FileName: WideString): IXMLBestellungType;
begin
Result := LoadXMLDocument(FileName).GetDocBinding('bestellung', TXMLBestellungType, TargetNamespace) as IXMLBestellungType;
end;
function Newbestellung: IXMLBestellungType;
begin
Result := NewXMLDocument.GetDocBinding('bestellung', TXMLBestellungType, TargetNamespace) as IXMLBestellungType;
end;
{ TXMLBestellungType }
procedure TXMLBestellungType.AfterConstruction;
begin
FNummer := CreateCollection(TXMLString_List, IXMLNode, 'nummer') as IXMLString_List;
FName := CreateCollection(TXMLString_List, IXMLNode, 'name') as IXMLString_List;
inherited;
end;
function TXMLBestellungType.Get_Nummer: IXMLString_List;
begin
Result := FNummer;
end;
function TXMLBestellungType.Get_Name: IXMLString_List;
begin
Result := FName;
end;
function TXMLBestellungType.Get_Menge: Integer;
begin
Result := ChildNodes['menge'].NodeValue;
end;
procedure TXMLBestellungType.Set_Menge(Value: Integer);
begin
ChildNodes['menge'].NodeValue := Value;
end;
function TXMLBestellungType.Get_Preis: WideString;
begin
Result := ChildNodes['preis'].Text;
end;
procedure TXMLBestellungType.Set_Preis(Value: WideString);
begin
ChildNodes['preis'].NodeValue := Value;
end;
function TXMLBestellungType.Get_Lieferadresse: WideString;
begin
Result := ChildNodes['lieferadresse'].Text;
end;
procedure TXMLBestellungType.Set_Lieferadresse(Value: WideString);
begin
ChildNodes['lieferadresse'].NodeValue := Value;
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.