Windward OhanaReport Designer Office Edition User Manual FAQsHow Do I Create a Select Statement With the XPath Wizard?

How Do I Create a Select Statement With the XPath Wizard?

In this article, we'll go step by step through an example of using the XPath Wizard to create a select statement for a ForEach Tag. If you aren't familiar with the ForEach Tag, please review our ForEach Tag Reference before continuing.

In this example we'll create a table of products whose unit price is greater than $50, sorted by the number of units in stock. You can begin with a blank Word document, or follow along with the attached example template and data source.

Six Steps to Using the XPath Wizard

Although this example is specific to a ForEach Tag, this procedure can be followed to create an XPath select statement for any Tag returning data from an XML data source.

  1. Create the Tag where the select statement will be applied
  2. Bring up the XPath Wizard
  3. Select the node you wish to display data about in your output
  4. Create a condition the data must satisfy to be displayed
  5. Sort the data satisfying the condition (optional)
  6. Generate output

Create the Tag Where the Select Statement Will Be Applied

We've opened a Word document and connected to our example Southwind XML data source (located in the C:\Users\<username>\Documents\AutoTag\data directory). We create a table displaying product ID, product name, unit price and units in stock by dragging the "Product" node from the Data Bin and dropping it onto the report template.

This creates a table containing a ForEach Tag and some Out Tags. We'll use the XPath Wizard to modify the select statement in the ForEach Tag. You can format the Out Tags' output as desired (e.g. set the UnitPrice Out Tag output format to Currency).

Bring Up the XPath Wizard

To bring up the XPath Wizard on the ForEach Tag, select the ForEach Tag, then click on the Wizard button on the AutoTag tab of the Word ribbon.

Select the Node You Wish to Display Data About in Your Output

Since we created the ForEach Tag by dragging and dropping from the Data Bin, the node we wish to query is already selected. If we had inserted the ForEach Tag manually, we would click on "click here to add a node", then use the popup window to select the node we wish to query.

Create a Condition the Data Must Satisfy to Be Displayed

We want to display those products whose unit price is greater than $50. To do so we must create a condition. A condition is a node, a comparison and a value, such as "unit price > 50."

First, click on "click here to add a group":

Then click on "click here to enter a condition":

Next, click on "click here to select a node", then select the UnitPrice node in the popup window:

Click on "equal to", and change it to "greater than":

Then click on "click here to set the value", and enter "50":

Sort the Data Satisfying the Condition (Optional)

Now we have a select statement which will return the ID for each product with a unit price greater than $50. To sort those product IDs by units in stock, click on "Click here to add an order by":

Click on "ascending", change it to "descending", then click on "OK":

Now double-click on the ForEach Tag to bring up the Tag Editor, and in the Query Pane you'll see the select statement we just built using the Wizard.

Generate Output

Finally, let's generate output, and we'll see our table of products whose unit price is greater than $50, sorted by units in stock.