# Convert Price List to XML Quote Document

Complete the following steps to design a node to transform the price list (created as a result of iteration through the For Each loop) to a variable whose data type is typed-XML. To do so, you use methods on the priceAvailTransformations control.

To Design the Interaction With the Transformation Control

1. With the priceAvailTransformations control instance expanded in the Data Palette, click the following method:

    PriceQuoteDocument convertPriceListToXML
    (QuoteRequestDocument _quoteRequestDoc, XmlObjectList _XmlObjectListDoc)

2. Drag the method from the Data Palette and drop it on your RequestQuote business process in the Design View, placing it immediately after, and outside, the For Each block.

3. Rename the node from convertPriceListToXML to Convert PriceList To PriceQuote XML.
4. Double-click the Convert PriceList To PriceQuote XML node to open its node builder.
5. Verify that the priceAvailTransformations control and the following method are selected on the General Settings tab:

    PriceQuoteDocument convertPriceListToXML
    (org.example.request.QuoteRequestDocument _quoteRequestDoc, com.bae.xml.XmlObjectList _XmlObjectListDoc)

6. Click Send Data to open the second tab in the node builder.

The Control Expects field is populated with the data type expected by the convertPriceListToXML() method on the priceAvailTransformations control:

Note: The convertPriceListToXML()method on the priceAvailTransformations control is designed to achieve two goals: First, to transform the XmlObjectList price data to typed XML, and then to combine the customer name, the shipping address, and the price quote data (the price list) in a single variable. The convertPriceListToXML() method receives the price list in a parameter of type XmlObjectList, and the customer name and shipping address in a parameter of type QuoteRequestDocument. To learn more about the priceAvailTransformations control, see Note About the Transformation on This Node.

7. On the Send Data tab, under Select variables to assign, assign the variables that hold the data required by the priceAvailTransformations control as follows:

- Click the arrow in the variable assignment field associated with QuoteRequestDocument, and select requestXML (QuoteRequestDocument). (The requestXML variable holds the customer name and shipping address).
- Click the arrow in the variable assignment field associated with XmlObjectList, and select priceList (XmlObjectList).

8. Click Receive Data to open the third tab in the node builder.

The Control Returns field is populated with PriceQuoteDocument, which is the data type returned by the convertPriceListToXML() method on the priceAvailTransformations control.

9. Click the arrow associated with the Select variables to assign field, and click Create new variable .... The Create Variable dialog box is displayed.

10. In the Variable Name field, enter priceQuote.
11. In the Select Variable Type field, select priceQuote in the XML Types list. The Variable Type field is populated with org.example.price.PriceQuoteDocument.
12. Click OK to close the Create Variable dialog box.
13. To close the node builder, click the X in the top right-hand corner.

This step completes the design of the Convert PriceList to PriceQuote XML node. At run time, the price quote data (in typed-XML format), and the customer name and shipping address are assigned to the priceQuote variable.

Note About the Transformation on This Node

The convertPriceListToXML() method on the priceAvailTransformations control does the work of creating the price quote XML data in the preceding step.

In brief, the input to the Transformation method includes the original data sent by the client (in the requestXML variable), and the price data returned by the priceProcessor control (in the priceList variable) after the iterations in the For Each node complete.

The convertPriceListToXML() method extracts the customer name and shipping address from the requestXML variable, and a list of widget IDs and prices from the priceList variable, and maps the data to the new variable (priceQuote).

It is left as an exercise to the reader to view this and other transformation methods on the priceAvailTransformations control. For example, you can double-click PriceAvailTransformations.dtf in the Application pane to display the Transformation control in the Design View. Right-click on the convertPriceListToXML method, and select Goto XQuery Document to open the Transformation tool. Use the Design View and Source View tabs in the transformation tool to see the data map that represents the transformation and the corresponding XQuery. Use the Test View tab to test the XQuery. For example the following figure shows the map for the convertPriceListToXML() method:

Related Topics

Guide to Data Transformation

Tutorial: Building Your First Data Transformation