IDtXmlProvider.FormatType

Syntax

FormatType: DtXmlFormatType;

Description

The FormatType property determines file structure format, according to which data is imported. By default format with fields as child nodes is used.

Example

Executing the example requires that the repository contains an ETL task with the Etl identifier, and the XML file Data.xml in the disk C root directory.

Suppose that the file has the following structure:

<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>

Sub Main;

Var

MB: IMetabase;

MObj: IMetabaseObject;

EtlTask: IEtlTask;

EtlProvider: IEtlPlainDataProvider;

XMLProvider: IDtXMLProvider;

WxProvider: IWxRectangle;

WxETLProvider: 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 the provider creation

//The Import From XML object creation

EtlProvider := EtlTask.Create(EtlObjectType.PlainDataXMLProvider) As IEtlPlainDataProvider;

EtlProvider := EtlProvider.Edit;

EtlProvider.Id := "XML_Provider";

EtlProvider.Name := "Import from XML";

EtlProvider.Description := "Import from XML";

//Set up data provider

XMLProvider := EtlProvider.Provider As IDtXMLProvider;

XMLProvider.File := "c:\Data.xml";

XMLProvider.FormatType := DtXmlFormatType.FieldsAsAttributes;

XMLProvider.XPath := "Data/Row[@Year > ""1991"" and @Year < ""1993""]";

XMLProvider.FieldsFromFile;

EtlProvider.FillDefault;

//Save provider

EtlProvider.Save;

//End of provider creation

//Start of visual object creation

WxProvider := EtlTask.Workspace.CreateRectangle;

WxETLProvider := New WxETLObject.Create;

WxETLProvider.ETLObject := EtlProvider;

WxProvider.Style.TextPosition := WxTextPosition.Bottom;

WxProvider.Style.PictureMarginTop := -10;

WxProvider.PinPosition := New GxPointF.Create(50, 50);

WxProvider.Extension := WxETLProvider As IWxShapeExtension;

//End of visual object creation

//Save Etl task

MObj.Save;

End Sub Main;

After executing the example the Import from XML object is created in the ETL task. The provider imports data from the Data.xml XML file. Field values are taken from attribute values of the Row node. Only entries with the Year attribute value in the range (1991;1993) are imported.

See also:

IDtXmlProvider