Showing posts with label Oracle. Show all posts
Showing posts with label Oracle. Show all posts

Saturday, July 2, 2011

Accessing preconfigured Oracle Software Images

If you want to avoid the hassles of installing the software on your system but play with the software then use the preconfigured images avaiable to download from Oracle Technetwork. These images have preinstalled OS and software but make sure you install the Virtual Box software before opening the images.

BPEL XPath function to retrieve values from a list

In BPEL, if you would like to look through a list of XML elements and check certain condition in each element then follow the steps below:

Sample XML:
<employees>
<employee>
<name>NAME1</name>
<age>25</age>
</employee>
<employee>
<name>NAME2</name>
<age>30</age>
</employee>
<employee>
<name>NAME3</name>
<age>35</age>
</employee>
</employees>

We can use "While" Activity for looping through multiple elements but the real task is to access the data within each dynamically:

1. Initialize a simple int "counter" variable and set the value = 0

2. Count the number of employee nodes in employees root node using,
ora:countNodes("employees/employee")
[Note: Use BPEL Expression builder to get the XPath Expression but remember to delete bpws:getVariableData from the expression because we are not looking for data but only number of nodes]

3. Loop through each of the employee node and check if the <age> is greater than 26 as:

bpws:getVariableData('employees','part',"employee[position()=bpws:getVariableData('counter')]")

4. Increment the counter and you will be able to a access all the employee data dynamically.

Things to remember:

1. In BPEL, the index starts with 1 and not 0 so make sure the "counter" value starts from 1 and not 0.
2. Whereever in the XPath you are accessing a variable inside a variable such as, { "employee[position()=bpws:getVariableData('counter')]" } use double quotes for outside variable and single quotes for inside variable
3. Use position() function as shown above

Search This Blog