...
DataTable $Database.ImportFromXml(query: QueryWithMappings)
Arguments
...
Code Block | ||
---|---|---|
| ||
<GeneralDefinitions> <Corporations> <Corporation> <Id>9b7383a3-67ae-4fed-a135-1f981b165c43</Id> <Name>Corporation A</Name> <ShortName>CorpA</ShortName> <SubCorporations> <SubCorporation> <Id>309069b4-4274-4063-b7ad-75c5657d7474</Id> <Name>SubCorporation A 1</Name> <ShortName>SubCorpA1</ShortName> </SubCorporation> <SubCorporation> <Id>6ba3cc79-9ff7-4232-8f61-9245a38fd2bb</Id> <Name>SubCorporation A 2</Name> <ShortName>SubCorpA2</ShortName> </SubCorporation> </SubCorporations> </Corporation> <Corporation> <Id>5a900112-a869-41cf-931c-7379c1df518e</Id> <Name>Corporation B</Name> <ShortName>CorpB</ShortName> <SubCorporations> <SubCorporation> <Id>8e7ca6d2-5629-4f87-82ed-73c72cfb171e</Id> <Name>SubCorporation B 1</Name> <ShortName>SubCorpB1</ShortName> </SubCorporation> <SubCorporation> <Id>7c5f330e-68d8-45f0-800e-04e2f7e035e0</Id> <Name>SubCorporation B 2</Name> <ShortName>SubCorpB2</ShortName> </SubCorporation> </SubCorporations> </Corporation> </Corporations> </GeneralDefinitions> |
Types
QueryWithMappings
{ // Array of columns Columns : Array<QueryColumn> Map : (node: XmlNode) => void // Maximum number of rows. If not set all rows are returns. MaxLength : number // Root node of mapping. If not specified $Xml instance is used. Node : XmlNode // Array of order columns Order : Array<QueryOrder> // Additional parameters Parameters : object // Start index of rows. Start : number // Array of sub queries. SubQueries : Array<SubQuery> // Name of schema to execute query on. TargetSchema : string // Name of table to execute query on. TargetTable : string // Criteria of query Where : QueryBlock // Root xpath to be mapped. XPath : string }
QueryColumn
...
{ // Expression of column. Expression : string // Name of column to use in results. If not specified expression is used. Name : string // XPath to be mapped. XPath : string }
QueryOrder
...
{ // Expression to order. Expression : string // Type of ordering. If not specified Ascending is used. Type : ( "Ascending" | "Descending" ) }
SubQuery
{ // Array of columns Columns : Array<QueryColumn> // Maximum number of rows. If not set all rows are returns. MaxLength : number // Name of sub query. Relation name can be used as name. Name : string // Array of order columns Order : Array<QueryOrder> // Additional parameters Parameters : object // Name of relation Relation : string // Start index of rows. Start : number // Array of sub queries. SubQueries : Array<SubQuery> // Name of schema to execute query on. TargetSchema : string // Name of table to execute query on. TargetTable : string // Criteria of query Where : QueryBlock // Specifies the target xpath to export data on. XPath : string }
QueryBlock
{ // Array of criteria blocks Blocks : Array<QueryBlock> // Condition with next block. If not specified And value is used. Condition : ( "And" | "Or" ) // Array of criteria Criteria : Array<QueryCriteria> }
QueryCriteria
...
{ // Comparison operator. Default value is Equals. Comparison : ( "Equals" | "Different" | "LessThan" | "GreaterThan" | "LessThanOrEqualTo" | "GreaterThanOrEqualTo" | "Like" ) // Condition with next criteria. If not specified And value is used. Condition : ( "And" | "Or" ) // Criteria expression. Expression : string // Array of ignored values. IgnoredValues : any // Value or Expression to compare Value : any // Type of value. If not specified Direct value is used. ValueType : ( "Direct" | "Expression" ) }
Examples
Code Block | ||
---|---|---|
| ||
$Database.ImportFromXml({ TargetSchema : 'Edoksis', TargetTable : 'Accounts', XPath : 'Accounts/Account', Map : function (xml) { var pass = xml.Evaluate('Password'); // if not marked as encrypted (means user has edited the password field) encrypt it if (!pass.startsWith('Enc:')) this.Password = $Crypto.Encrypt($EncryptionPassword, this.Id, xml.Evaluate('Password')); else // otherwise just remove the mark this.Password = pass.substr(4); } }); |
...