XML Database Query

Fetches data from XML database and loads into the related control.

Query

Query

Write your XQuery script here. See XPath and XQuery for more details.

Scratch Query

You can use this query area for testing purposes.

Results Section

This section lets you test your query with the actual data from the XML repository.

Results

There is a list named Parameter Values under this tab. The parameters added in the Parameters tab are also listed here with their Value box empty. Enter values for the listed parameters to trigger and test your query.

Table View

This table view section displays the test query result in a table view, just like it is displayed on the form.


Parameters

Options of which database to query and parameter assignments.

Repository
Select the location of data to query, either Domain or Process repository.

Parameters
Create parameters with name and value XPath pairs to use data from form XML in the query.

  • Name: Parameter name to be used in the XQuery.
  • Value XPath: XPath for parameter data to be gathered and used in the query.

Formatting

Options to format the result data.

List Item Formatting

Customizes the format of the query result.

Display Text Format
Specify the format to display the result text. You can use XPath inside curly braces. Ex: {{name}} - {{id}}

Value Format
Specify the format of the value. You can use XPath inside curly braces. Ex:  {{id}} - {{type}}

Table View Columns

Columns added in this section will be displayed in the result pane of the query. 

Caption
Title of a column.

Value
Value of a column.

Item XPath
Specifies item that will be listed in control. If it is left empty, which is the same as the * value, all resulting items are listed.

Hierarchy XPath

In a nested XML node structure, for example, if your XML looks like the excerpt below, you may specify the starting node of the recurrence. In this example, Hierarchy XPath is "Folders".

<Folders>
    <Folder>
        <Name>text1</Name>
    </Folder>
    <Folder>
        <Name>text2</Name>
        <Folders>
            <Folder>
                <Name>text2a</Name>
            </Folder>
            <Folder>
                <Name>text2b</Name>
            </Folder>
        </Folders>
    </Folder>
</Folders>

Mappings

Options to map the result data.

Selection Mappings

In order to map the selected data from the XQuery result into a node of the form, create a mapping by pressing Add New button.

Source  
Node name to map its data.

Target
XPath to map data into.

Examples

The query below basically gathers data from forms, instances and work items associatively and returns them in the desired format.

XQuery Example
for $i in /Instance

let $formNo := ($i/Number)
let $instance := unordered($i[Number=$formNo])[last()]
let $workItemId := unordered($instance/WorkItems/WorkItem/Id)[last()]
let $formDataId:= $i/WorkItems/WorkItem[last()]/DataId
let $form := form[data(@Id)=$formDataId]/PoolRoot

where 
($fNo = '' or ($formNo/text() = $fNo))
and ($startDate = '' or  ($i/Start >= $startDate))
and ($endDate = '' or  ($i/End <= $endDate)) 
and ($state = '' or ($i/State/text() = $state))
and ($department = '' or ($form/Departman/Id = $department))

order by $i/Start/text() descending

return 
<Result>
	<FormNo>{$i/Number/text()}</FormNo>
	<DocId>{$workItemId/text()}</DocId>
	<State>{$i/State/text()}</State>
	<StartDate>{$i/Start/text()}</StartDate>
	<EndDate>{$i/End/text()}</EndDate>
	<InitiatedBy>{$i/WorkItems/WorkItem[1]/CompletedBy/@Caption/string()}</InitiatedBy>
	<Subject>{$form/Konu/text()}</Subject>
	<File>{$form/Dosyalar/Dosya/Id/text()}</File>
</Result>

This example demonstrates the general FLWOR structure in XQuery, so we can read the query as the following:

  • For expression loops over Instance nodes that are located on root level and assign them to parameter $i.
  • Let expression gathers several pieces of information depending on the instance, workitem and form data.
  • Where expression applies criteria to the data. Control parameters used in this section are declared in the Parameters section on the same window.
  • Order expression orders the result according to the given value.
  • The result expression returns the result data in the specified XML format.

See Also



Copyright © 2010 - 2023 Emakin. All rights reserved.