Marco's Web Center

Menu for Development

Site Menu
Object Pascal Handbook
Delphi Handbooks Collection
Mastering Borland Delphi 2005
(Old) White Papers
(Old)Tools
(Old) Conferences

My Other Sites
Italian Site (www.marcocantu.it)
the delphi search

Spirit of delphi

Advertising
Home My Blog Books Object Pascal Marco

Home: Code Repository: Mastering Delphi 6

Chapter 23 - Project XmlMapping

Project Structure

XmlMapping.dpr
program XmlMapping;

uses
  Forms,
  XmlMappingForm in 'XmlMappingForm.pas' {Form1};

{$R *.res}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.
XmlMappingForm.pas
unit XmlMappingForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, xmldom, StdCtrls, ExtCtrls, DBCtrls, Mask, DB, Grids, DBGrids,
  DBClient, Provider, Xmlxform;

type
  TForm1 = class(TForm)
    XMLTransformProvider1: TXMLTransformProvider;
    ClientDataSet1: TClientDataSet;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    ClientDataSet1text: TStringField;
    ClientDataSet1book: TDataSetField;
    ClientDataSet1ebook: TDataSetField;
    Label2: TLabel;
    DBEdit2: TDBEdit;
    Panel1: TPanel;
    DBNavigator1: TDBNavigator;
    Splitter1: TSplitter;
    DBGrid2: TDBGrid;
    ClientDataSet2: TClientDataSet;
    ClientDataSet3: TClientDataSet;
    DataSource2: TDataSource;
    DataSource3: TDataSource;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  ClientDataSet1.ApplyUpdates (-1);
end;

end.
XmlMappingForm.dfm
object Form1: TForm1
  Left = 192
  Top = 107
  Width = 438
  Height = 408
  Caption = 'XmlMapping'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Splitter1: TSplitter
    Left = 0
    Top = 185
    Width = 430
    Height = 5
    Cursor = crVSplit
    Align = alTop
  end
  object DBGrid1: TDBGrid
    Left = 0
    Top = 41
    Width = 430
    Height = 144
    Align = alTop
    DataSource = DataSource2
    TabOrder = 0
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'MS Sans Serif'
    TitleFont.Style = []
  end
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 430
    Height = 41
    Align = alTop
    TabOrder = 1
    object Label2: TLabel
      Left = 288
      Top = 16
      Width = 21
      Height = 13
      Caption = 'Text'
      FocusControl = DBEdit2
    end
    object DBNavigator1: TDBNavigator
      Left = 16
      Top = 8
      Width = 160
      Height = 25
      VisibleButtons = [nbEdit, nbPost, nbCancel, nbRefresh]
      TabOrder = 0
    end
    object DBEdit2: TDBEdit
      Left = 320
      Top = 12
      Width = 69
      Height = 21
      DataField = 'text'
      DataSource = DataSource1
      TabOrder = 1
    end
    object Button1: TButton
      Left = 184
      Top = 8
      Width = 65
      Height = 25
      Caption = 'Save'
      TabOrder = 2
      OnClick = Button1Click
    end
  end
  object DBGrid2: TDBGrid
    Left = 0
    Top = 190
    Width = 430
    Height = 191
    Align = alClient
    DataSource = DataSource3
    TabOrder = 2
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'MS Sans Serif'
    TitleFont.Style = []
  end
  object XMLTransformProvider1: TXMLTransformProvider
    TransformRead.TransformationFile = 'C:\md6code\23\XmlMapping\BooksDefault.xtr'
    TransformWrite.TransformationFile = 'C:\md6code\23\XmlMapping\BooksDefaultToXml.xtr'
    XMLDataFile = 'C:\md6code\23\XmlMapping\Sample.xml'
    Left = 72
    Top = 24
  end
  object ClientDataSet1: TClientDataSet
    Active = True
    Aggregates = <>
    Params = <>
    ProviderName = 'XMLTransformProvider1'
    Left = 72
    Top = 80
    object ClientDataSet1text: TStringField
      FieldName = 'text'
      Size = 5
    end
    object ClientDataSet1book: TDataSetField
      FieldName = 'book'
      UnNamed = True
    end
    object ClientDataSet1ebook: TDataSetField
      FieldName = 'ebook'
      UnNamed = True
    end
  end
  object DataSource1: TDataSource
    DataSet = ClientDataSet1
    Left = 72
    Top = 136
  end
  object ClientDataSet2: TClientDataSet
    Active = True
    Aggregates = <>
    DataSetField = ClientDataSet1book
    Params = <>
    Left = 160
    Top = 128
  end
  object ClientDataSet3: TClientDataSet
    Active = True
    Aggregates = <>
    DataSetField = ClientDataSet1ebook
    Params = <>
    Left = 160
    Top = 216
  end
  object DataSource2: TDataSource
    DataSet = ClientDataSet2
    Left = 232
    Top = 128
  end
  object DataSource3: TDataSource
    DataSet = ClientDataSet3
    Left = 232
    Top = 224
  end
end