FormatType: DtXmlFormatType;
The FormatType property determines file structure format, according to which data is exported.
By default format with fields as child nodes is used.
Executing the example requires that the repository contains an ETL task with the ETL identifier.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObject;
EtlTask: IEtlTask;
EtlConsumer: IEtlPlainDataConsumer;
XMLConsumer: IDtXmlConsumer;
WxConsumer: IWxRectangle;
WxETLConsumer: IWxETLObject;
Begin
MB := MetabaseClass.Active;
// ETL task search. Repository object with the ETL identifier
MObj := MB.ItemById("ETL").Edit;
EtlTask := MObj As IEtlTask;
// Start of creating a data consumer
// Create the "Export to XML" object
EtlConsumer := EtlTask.Create(EtlObjectType.PlainDataXmlConsumer) As IEtlPlainDataConsumer;
EtlConsumer := EtlConsumer.Edit;
EtlConsumer.Id := "XML_Consumer";
EtlConsumer.Name := "Export to XML";
EtlConsumer.Description := "Export to XML";
// Set up data consumer
XMLConsumer := EtlConsumer.Consumer As IDtXmlConsumer;
XMLConsumer.DataNodeName := "Row";
XMLConsumer.File := "c:\Data_out.Xml";
XMLConsumer.FormatType := DtXmlFormatType.FieldsAsAttributes;
XMLConsumer.RootNodeName := "Data";
// Save data consumer
EtlConsumer.Save;
// End of creating a data consumer
// Start of visual object creation
WxConsumer := EtlTask.Workspace.CreateRectangle;
WxETLConsumer := New WxETLObject.Create;
WxETLConsumer.ETLObject := EtlConsumer;
WxConsumer.Style.TextPosition := WxTextPosition.Bottom;
WxConsumer.Style.PictureMarginTop := -10;
WxConsumer.PinPosition := New GxPointF.Create(50, 50);
WxConsumer.Extension := WxETLConsumer As IWxShapeExtension;
// End of visual object creation
// Save ETL task
MObj.Save;
End Sub UserProc;
After executing the example the Export to XML object is created in the ETL task. This data consumer exports data to the Data_out.xml file. If the file does not exist, it will be created.
During export the file turns into:
<Data>
<Row Code="10" Country="Russia" Year="1990" Value="100.5" />
<Row Code="10" Country="Russia" Year="1991" Value="104.1" />
<Row Code="10" Country="Russia" Year="1992" Value="107.2" />
<Row Code="10" Country="Russia" Year="1993" Value="106.7" />
<Row Code="20" Country="France" Year="1990" Value="90.3" />
<Row Code="20" Country="France" Year="1991" Value="104.5" />
<Row Code="20" Country="France" Year="1992" Value="102.3" />
<Row Code="20" Country="France" Year="1993" Value="100.5" />
...
</Data>
See also: