Skip to content

$Database.ExportToXml

Overview

DataTable $Database.ExportToXml ( options )

Exports the data table content to xml data. For each row in data table a new xml child created on specified xpath.

Arguments

Object options Exporting options. Options contains following properties:

String XPath Specifies the target xpath to export data on.

XmlNode Node Specifies the root xml node. This property is optional and if omitted uses the $Xml instance.

String TargetSchema Name of schema to execute query on.

String TargetTable Name of table to execute query on.

Boolean IncludeAllColumns Set to "True" to returns all columns on table. Optional, please see remarks.

Function Map Mapping callback function is used to change row values on the fly. This property is optional.

Remarks

When IncludeAllColumns parameter is not specified, default behavior is query returns only explicitly specified columns. If not any column specified query returns the all defined columns on table.

Examples

Exporting database content into XML

// For following xml structure
// <Root>
//    <Groups></Groups>
// </Root>


$Database.ExportToXml({
  Parameters : {
        TargetSchema: 'HR',
        TargetTable: 'Groups'
    }
  },
  XPath : 'Groups/Group'
});


// Xml updated as;
// <Root>
//    <Group>
//        <Name>Developers (Junior)</Name>
//    </Group>
// </Root>

Exporting with sub queries

$Database.ExportToXml({
   Parameters : {
   TargetSchema : 'Contract',
   TargetTable : 'Events'
 },
 Where : {
   Criteria : [
     { Name : 'ReminderDate', Value : $Calendar.Today, Comparison : 'LessThan' },
     { Name : 'Durum', Value : 'IPT', Comparison : 'Different' },
     { Name : 'Type', Value : 'R' },
     { Name : 'Status', Value : 'W' }     
   ]
 },
 SubQueries : [
   {
     Name : 'Contract',
     Parameters : {
       IncludeAllColumns : 'True'
     },
     SubQueries : [
       {
         Name : 'Party'
       },
       {
         Name : 'Versions'
       },
       {
         Name : 'Events'
       }
     ]     
   }
 ],
   XPath : 'ContractEvent'
 });

Exporting with XML mappings;

$Database.ExportToXml({
 Parameters : {
   TargetSchema: 'HR',
   TargetTable: 'OrganizationUnitPositionMembers',
   IncludeAllColumns: 'True'
 },
 Columns : [
   {
     Name : 'Employee',
     Properties : {
       XPath : 'Id'
     }
   },
   {
     Name : 'Employee.Person.DisplayName',
     Properties : {
       XPath : 'Name'
     }
   },   
   {
     Name : 'OrganizationUnitPosition.Organization',
     Properties : {
       XPath : 'Department'
     }
   },
   {
     Name : 'OrganizationUnitPosition.Organization.Name',
     Properties : {
       XPath : 'Department/@Name'
     }
      }
 ],
 Where : {
       Criteria: [
         { Name: 'OrganizationUnitPosition.Manager', Value:'D7B70176-C44D-44BB-A8C0-7900BC5DAF2A', Condition : 'And'},
         { Name: 'Employee.User.Disabled', Value: true, Comparison:'Different', Condition : 'And'}
       ]
 },
 XPath : 'EmployeeList/Employee'
 });

See Also