|
Home > Online Product Documentation > Table of Contents > Using XQuery to Merge Source File Data Using XQuery to Merge Source File Data
As described in
<xHyperlink>order.pipeline Requirements, the data required for our report comes from two files - a text file,
To join data from these different documents we will use an XQuery document created using the XQuery Mapper. Once we have defined that XQuery document, we can add the XQuery node to our XML pipeline. Using Variables to Reference Data Sources
Because we want our XQuery to be easy to parameterize, we will create it using external variables to reference our two data sources,
If you open
To use non-XML as a source document for XQuery Mapper:To specify a non-XML data source as an XML source for the XQuery Mapper, you
1. Click the
Add Source Document button at the top of the XQuery
Mapper tab.
This displays the Open dialog box.
2. You select the file you want to open, and then select the
Convert to XML using adapter check box.
3. When you click
Open, Stylus Studio displays the
Select XML Converter dialog box (see
Figure 399), which you use to select the built-in Stylus Studio adapter you want to use to convert your non-XML file to XML. Note that this is the same procedure we used to identify the data sources for the XML pipeline's two ConvertToXML nodes.
4. When you click OK on the
Select XML Converter dialog box, Stylus Studio adds it as a data source in the
Add Source Document pane of the XQuery Mapper.
Next, we need to create global variables for the two source documents. This way, the XQuery code that Stylus Studio generates will use variable declarations instead of document functions to reference our data sources. To associate the source schema with a global variable:
1. Right click the source document name and select
Associate With > Global Variable.
Stylus Studio displays the Associate Schema with Variable dialog box.
2. Enter the value you want to use for the variable, and click OK.
When a variable is created (
Looking at the XQuery Code
Before moving on with the XML pipeline creation, let's a quick look at the XQuery code in
The first two lines contain the variable declarations for
All of this code was created automatically as a result of mapping nodes from our source documents to nodes in an XML Schema,
See Building an XQuery Using the Mapper for more information on using the XQuery Mapper. |