Samples Tutorial

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Reusing XQuery Code through Vertical View Unfolding

ALDSP enables powerful data service code reusability.

 


Objectives

After completing this lesson, you will be able to:

 


Overview

ALDSP enables powerful data service code reusability. You can develop your logic once, and then re-use it later when building other data services. This feature is called view unfolding.

In addition to code reuse, ALDSP is smart enough to optimize your output and only query sources and elements that you request in your data service (vertical view unfolding).

 


27.1 Unfolding Vertical View

You will reuse the CustomerProfile data service previously built to retrieve Customer Order information. The CustomerProfile data service is built from three different tables in the underlying PointBase database: CUSTOMER, CUSTOMER_ORDER and CUSTOMER_ORDER_LINE_ITEM.

Objectives

In this exercise, you will:

Instructions

  1. Import CustomerOrder.ds into DataServices\CustomerManagement. The file is located in <beahome>\weblogic81\samples\LiquidData\EvalGuide.
  2. Import CustomerOrder.xsd into DataServices\CustomerManagement\schemas. The file is also located in <beahome>\weblogic81\samples\LiquidData\EvalGuide.
  3. Implement the getCustomerOrder() function in the CustomerOrder data service, by completing the following steps:
    1. Open CustomerOrder.ds in XQuery Editor View.
    2. In Data Services Palette, drag and drop getAllCustomers() into XQuery Editor View. The method call is located in the folder:
    3. DataServices\CustomerManagement\CustomerProfile
  4. Set the conditions for the function, by completing the following steps:
    1. Select the Customer* element. This will activate the Expression Editor and make visible the ns2:getAllCustomers()/customer expression. You will use the Expression Editor to scope the data returned in the getAllCustomers() function.
    2. Figure 27-1 Default Expression


      Default Expression

    3. Triple-click the Expression field.
    4. Modify the expression by adding the following code:
    5. ns2:getAllCustomers()/customer/orders/order
    6. Click the green checkmark icon to accept the changes. The CustomerProfile* element changes to the order* element, and the For:$CustomerProfile schema now includes the order elements.
    7. Figure 27-2 Modified Expression


       Modified Expression

  5. Create a simple mapping: Drag and drop all order* elements (source node) to the corresponding CUSTOMER_ORDER elements in the Return type.
  6. Figure 27-3 XQuery Editor View—Mappings


    XQuery Editor View—Mappings

  7. Save the data service file.
  8. Open CustomerOrders.ds in Source View and notice that the function is using the CustomerProfile file as its data source.
  9. Figure 27-4 Source View of Vertical File Unfolding Function


     Source View of Vertical File Unfolding Function

 


27.2 Testing a Vertical File Unfolding

Testing a vertical file unfolding is similar to testing any other data service function.

Objectives

In this exercise, you will:

Instructions

  1. Open CustomerOrders.ds in Test View.
  2. Select getCustomerOrder() from the function drop-down list.
  3. Click Execute.
  4. Confirm that you can retrieve customer order information.
  5. Figure 27-5 Vertical File Unfolding Test Results


    Vertical File Unfolding Test Results

 


Lesson Summary

In this lesson, you learned how to:


  Back to Top       Previous  Next