Configuring Data Sources

The source for the information required for the desired report comes from two files:

l A flat file, booksXML.txt, that contains ISBN, title, manufacturer, and release date information for every book in inventory.
l An EDI file, order.edi, that contains title, ISBN, and quantity information for every book currently on order.

Neither of these files provides data in XML format, so they will have to be converted to XML. We will use built-in DataDirect XML Converters for this task.

Ways to Configure Non-XML Data Sources

You use ConvertToXML nodes to specify a non-XML data source in an XML pipeline. There are two ways to do this:

l Convert the source file using a built-in DataDirect XML Converter or a user-defined custom XML conversion, and then drag the resulting document and drop it on the XML pipeline canvas.
l Create the ConvertToXML node in the XML pipeline using the Toolbox, and then specify the source file and the DataDirect XML Converter or user-defined custom XML conversion you want to use to convert it to XML.

While both require a similar number of steps, converting a source file can be more economical as it creates a resource that you can reuse in the XML pipeline, and elswhere in Stylus Studio. Both procedures are described in the following sections.

Convert booksXML.txt Using a Built-in XML Converter

To convert booksXML.txt using a built-in XML Converter:
1. Select File > Open from the menu.
The Open dialog box appears.
2. Navigate to the examples\pipeline\order folder where you installed Stylus Studio.
3. Change the Files of type field to All Files.
4. Select booksXML.txt.
5. Select the Open using XML Converter check box at the bottom of the Open dialog box.
6. Click Open.
Stylus Studio displays the Select XML Converter dialog box.
7. Select the Comma-Separated Values converter.
The booksXML.txt source file happens to use a vertical bar (|) as its separator character.
8. Change the value in the Separator property to a vertical bar (|).
9. Change the value in the First row contains field names to Yes.
10. Click OK.
The booksXML.txt file appears in the Other Documents folder in the Project window. If you hover the mouse pointer over the file name, you will see the full specification of the XML Converter URL used to convert it.
11. Drag booksXML.txt and drop it on the XML pipeline canvas.
Stylus Studio creates a ConvertToXML node with its input port already specified.

Create a ConvertToXML Node for booksXML.txt

To create XML data from a non-XML source in the XML Pipeline Editor:
1. Drag the ConvertToXML icon from the Toolbox pane and drop it on the XML pipeline canvas.
Stylus Studio creates a ConvertToXML node and displays it in the XML pipeline diagram.
2. Display the Properties window (View > Properties) if it is not already open.
3. Display the Project window (View > Project) if it is not already open.
4. Click the input port on the ConvertToXML node.
The properties for the input port are displayed in the Properties window.
5. Click the Default Value field; click the more button ( ) when it appears.
Stylus Studio displays the Default Value dialog box.
6. Click the Read default value from this URL radio button, and then navigate to examples\pipelines\order\ folder where you installed Stylus Studio and select booksXML.txt.
7. Click OK.
The input port on the ConvertToXML Node turns green, indicating that a source document has been specified as the input.
Next, we need to specify which built-in converter to use to convert booksXML.txt to XML.
8. Click the ConvertToXML node in the XML pipeline diagram.
9. Click the XML Converter URL field in the Properties window; click the more button ( ) when it appears.
Stylus Studio displays the Select XML Converter dialog box.
10. Select the Comma-Separated Values converter.
The booksXML.txt source file happens to use a vertical bar (|) as its separator character.
11. Change the value in the Separator property to a vertical bar (|).
12. Change the value in the First row contains field names to Yes.
13. Click OK.

Create a ConvertToXML Node for order.edi

Next, using the procedure described in either Convert booksXML.txt Using a Built-in XML Converter or Create a ConvertToXML Node for booksXML.txt, create a ConvertToXML node for the order.edi file. Note the following changes:

l Use select order.edi as the source document.
l Select Electronic Data Interchange (EDI) from the Select XML Converter dialog box. Accept all default values.

Renaming Nodes

When you add a second node of the same type using the Toolbox, Stylus Studio gives the second node the same name as the first, with a number to make it unique. If you create a node by dragging a document and dropping it on the canvas, Stylus Studio gives the node the same name as the file.

Depending on how you created the ConvertToXML nodes in the XML pipeline, they are named either:

l Convert to XML and Convert to XML #2, or
l booksXML.txt and order.edi

You can reame nodes using the following procedure:

To rename a node:
1. Select the node you want to rename in the XML pipeline diagram.
2. Click the value in the Name field in the Properties window.
3. Type the new name and press Enter.
 
Free Stylus Studio XML Training: