ExportToXml¶
Exports the data table content to xml data. For each row in data table a new xml child created on specified xpath.
1 |
|
Parameters¶
QueryWithMappings query
Query of data to export.
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.
The design of your XML data model and SQL table columns are the key point for the ease of use. When XML node and table column names identical, this method maps them automatically.
Info
$Database.ExportToXml
, and ,$Database.ImportFromXml
, methods requires a unique primary key field on database table and data model.
Map Function¶
Map function is used to transform values before saving. For example; encrypting a password before saving to database. See $Database.ImportFromXml
for more details.
Example¶
1 2 3 4 5 6 7 8 9 10 |
|
Exporting database content into XML¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
Exporting with sub queries¶
1 2 3 4 5 6 7 8 9 10 11 |
|
Info
Assume you have two SQL tables Corporations and SubCorporations and a One-To-Many relation from Corporations table to SubCorporations table which is also named SubCorporations. Also don't forget to set this relation's update rule to "Cascade".
Having defined the table columns with identical names to the XML fields, this code lets you export each corporation from SQL table into XML fields, exporting also its related SubCorporations into the SubCorporations XML nodes and resulting in the following XML data.
Exported XML Data¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
Exporting with nested sub queries¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
Exporting with XML mappings¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
Types¶
QueryWithMappings¶
Columns
: Array<QueryColumn>
Array of columns
Map
: (node: Xml) => void
MaxLength
: number
Maximum number of rows. If not set all rows are returns.
Node
: Xml
Root node of mapping. If not specified $Xml instance is used.
Order
: Array<QueryOrder>
Array of order columns
Parameters
: object
Additional parameters
Start
: number
Start index of rows.
SubQueries
: Array<SubQuery>
Array of sub queries.
TargetSchema
: string
Name of schema to execute query on.
TargetTable
: string
Name of table to execute query on.
Where
: QueryBlock
Criteria of query
XPath
: string
Root xpath to be mapped.
QueryColumn¶
Defines a query column to included in result
Expression
: string
Expression of column.
Name
: string
Name of column to use in results. If not specified expression is used.
XPath
: string
XPath to be mapped.
QueryOrder¶
Defines order expression of query result
Expression
: string
Expression to order.
Type
: ( "Ascending"
| "Descending"
)
Type of ordering. If not specified Ascending is used.
SubQuery¶
Columns
: Array<QueryColumn>
Array of columns
MaxLength
: number
Maximum number of rows. If not set all rows are returns.
Name
: string
Name of sub query. Relation name can be used as name.
Order
: Array<QueryOrder>
Array of order columns
Parameters
: object
Additional parameters
Relation
: string
Name of relation
Start
: number
Start index of rows.
SubQueries
: Array<SubQuery>
Array of sub queries.
TargetSchema
: string
Name of schema to execute query on.
TargetTable
: string
Name of table to execute query on.
Where
: QueryBlock
Criteria of query
XPath
: string
Specifies the target xpath to export data on.
QueryBlock¶
Blocks
: Array<QueryBlock>
Array of criteria blocks
Condition
: ( "And"
| "Or"
)
Condition with next block. If not specified And value is used.
Criteria
: Array<QueryCriteria>
Array of criteria
QueryCriteria¶
Defines a criteria to be used to filter results
Comparison
: ( "Equals"
| "Different"
| "LessThan"
| "GreaterThan"
| "LessThanOrEqualTo"
| "GreaterThanOrEqualTo"
| "Like"
)
Comparison operator. Default value is Equals.
Condition
: ( "And"
| "Or"
)
Condition with next criteria. If not specified And value is used.
Expression
: string
Criteria expression.
IgnoredValues
: any
Array of ignored values.
Value
: any
Value or Expression to compare
ValueType
: ( "Direct"
| "Expression"
)
Type of value. If not specified Direct value is used.