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:
  2. PriceQuoteDocument convertPriceListToXML
    (QuoteRequestDocument _quoteRequestDoc, XmlObjectList _XmlObjectListDoc) 
    

    image

  3. 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.
  4. image

  5. Rename the node from convertPriceListToXML to Convert PriceList To PriceQuote XML.
  6. Double-click the Convert PriceList To PriceQuote XML node to open its node builder.
  7. Verify that the priceAvailTransformations control and the following method are selected on the General Settings tab:
  8. PriceQuoteDocument convertPriceListToXML
    (org.example.request.QuoteRequestDocument _quoteRequestDoc, com.bae.xml.XmlObjectList _XmlObjectListDoc) 
    
  9. Click Send Data to open the second tab in the node builder.
  10. The Control Expects field is populated with the data type expected by the convertPriceListToXML() method on the priceAvailTransformations control:

    image

    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.

  11. On the Send Data tab, under Select variables to assign, assign the variables that hold the data required by the priceAvailTransformations control as follows:
  12. Click Receive Data to open the third tab in the node builder.
  13. The Control Returns field is populated with PriceQuoteDocument, which is the data type returned by the convertPriceListToXML() method on the priceAvailTransformations control.

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

  16. In the Variable Name field, enter priceQuote.
  17. In the Select Variable Type field, select priceQuote in the XML Types list. The Variable Type field is populated with org.example.price.PriceQuoteDocument.
  18. Click OK to close the Create Variable dialog box.
  19. To close the node builder, click the X in the top right-hand corner.
  20. 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:

image

Related Topics

Guide to Data Transformation

Tutorial: Building Your First Data Transformation

Previous Document Next Document