Skip navigation.
Downloads | Product Documentation | Support

Concepts Guide

# Liquid Data Standards and Features

This section provides an overview of core BEA Liquid Data for WebLogic features and also some usage information. It contains the following sections:

- Liquid Data Implements the XQuery Standard
- Definitions of Key Terms

For an overview of Liquid Data components, see Liquid Data Architecture.

# Liquid Data Implements the XQuery Standard

This topic describes XQuery and how Liquid Data implements the XQuery standard. It contains the following sections:

- About XQuery
- XQuery Links
- XQuery Example

Liquid Data provides a scalable, highly available platform for building and processing queries written using XQuery. Data Architects can use the Data View Builder tool to create XQuery queries graphically (without needing to hand write queries), as well as create ad hoc XQuery queries by hand. Client applications can use the Liquid Data Query API or generated Liquid Data Web services to invoke stored XQuery queries programmatically.

## About XQuery

XQuery is a standard query language, published by the W3C (World Wide Web Consortium), that uses XML (Extensible Markup Language) notation to define query requests and handle query results. XQuery is designed to be an efficient language in which queries are concise and easily understood. XQuery is flexible enough to query a broad spectrum of data sources, including relational databases, XML documents, Web services, packaged applications, and legacy systems.

Applications of XQuery include filtering a document to produce a table of contents, providing joins across multiple data sources, grouping and aggregates, and queries based on sequential relationships in documents. Joins, in particular, represent a powerful and likely principal use of XQuery in the enterprise. The XQuery language is derived from various sources, including SQL. Developers familiar with SQL will find XQuery very easy to learn.

## XQuery Links

For more information about XQuery, see the following topics on the W3C's Web site:

- XQuery 1.0: An XML Query Language. Liquid Data supports the December 20, 2001 working draft at the following URL:

http://www.w3.org/TR/2001/WD-xquery-20011220/

- XQuery 1.0 and XPath 2.0 Functions and Operators. Liquid Data supports the April 30, 2002 working draft at the following URL:

>     http://www.w3.org/TR/2002/WD-xquery-operators-20020430/

- XML Query Use Cases at the following URL:

`http://www.w3.org/TR/xmlquery-use-cases`

- XML Path Language (XPath) 2.0 at the following URL:

`http://www.w3.org/TR/xpath20/`

- XQuery 1.0 and XPath 2.0 Data Model at the following URL:

`http://www.w3.org/TR/query-datamodel/`

For details of the XQuery functions (both standard and extensions to the standard) implemented in Liquid Data, see Functions Reference in XQuery Reference Guide.

## XQuery Example

This section shows an example of XQuery code and sample query results from the Retail Sample Application. For more information about the Retail Sample Application and other samples included with Liquid Data, see Liquid Data by Example.

### Sample XQuery Query

The following code example shows the use XQuery for the Customer Order query in the sample application. This query retrieves customer information out of several data sources and combines the results to make them available for the application. For details on the sample application shipped with Liquid Data, see Overview of the Avitek Self-Service Sample Application in Liquid Data by Example.

Listing 3-1 XQuery for the Order Query from the Avitek Sample

>     {--	Generated by Data View Builder 8.1	--}

>     namespace ElectOrderService = "http://www.bea.com//examples/ldi/webservice/customerOrder"
>     namespace retailerType = "urn:retailerType"
>     namespace elecOrd = "java:examples.ldi.webservice"
>     namespace retailer = "urn:retailer"

>     <retailer:CustomerView>
>       {
>       for $RTL_CUSTOMER.CUSTOMER_1 in document("RTL-CUSTOMER")/db/CUSTOMER
>       where ($#custid of type xs:string  eq  $RTL_CUSTOMER.CUSTOMER_1/CUSTOMER_ID)
>       return
>       <CUSTOMER_VIEW>
>         <CUSTOMER_ID>{ xf:data($RTL_CUSTOMER.CUSTOMER_1/CUSTOMER_ID)}
>         </CUSTOMER_ID>
>         <FIRST_NAME>{ xf:data($RTL_CUSTOMER.CUSTOMER_1/FIRST_NAME) }</FIRST_NAME>
>         <LAST_NAME>{ xf:data($RTL_CUSTOMER.CUSTOMER_1/LAST_NAME) }</LAST_NAME>
>         <ORDERS>
>           {
>           for $RTL_APPL_OMS.CUSTOMER_ORDER_2 in document
>             ("RTL-APPL-OMS")/db/CUSTOMER_ORDER
>           where ($RTL_CUSTOMER.CUSTOMER_1/CUSTOMER_ID  eq
>             $RTL_APPL_OMS.CUSTOMER_ORDER_2/CUSTOMER_ID)
>               and ($RTL_APPL_OMS.CUSTOMER_ORDER_2/STATUS  eq  "OPEN")
>           return
>           <retailerType:ORDER_SUMMARY TYPE={"APPL"}>
>             <ORDER_ID>{ xf:data($RTL_APPL_OMS.CUSTOMER_ORDER_2/ORDER_ID) }</ORDER_ID>
>             <ORDER_DATE>{ xf:data($RTL_APPL_OMS.CUSTOMER_ORDER_2/ORDER_DATE) }</ORDER_DATE>
>             <TOTAL_ORDER_AMOUNT>{ xf:data($RTL_APPL_OMS.CUSTOMER_ORDER_2/TOTAL_ORDER_AMOUNT) }
>             </TOTAL_ORDER_AMOUNT>
>             <SHIP_TO_NAME>{ xf:data($RTL_APPL_OMS.CUSTOMER_ORDER_2/SHIP_TO_NAME) }
>             </SHIP_TO_NAME>
>             <ESTIMATED_SHIP_DATE>{ xf:data($RTL_APPL_OMS.CUSTOMER_ORDER_2/ESTIMATED_SHIP_DATE) }
>             </ESTIMATED_SHIP_DATE>
>             <TRACKING_NUMBER>{ xf:data($RTL_APPL_OMS.CUSTOMER_ORDER_2/TRACKING_NUMBER) }
>             </TRACKING_NUMBER>
>             {
>             for $RTL_APPL_OMS.CUSTOMER_ORDER_LINE_ITEM_3 in document("RTL-APPL-OMS")
>               /db/CUSTOMER_ORDER_LINE_ITEM
>             where ($RTL_APPL_OMS.CUSTOMER_ORDER_2/ORDER_ID  eq
>               $RTL_APPL_OMS.CUSTOMER_ORDER_LINE_ITEM_3/ORDER_ID)
>             return
>             <LINE_ITEM>
>               <PRODUCT_DESC>{ xf:data($RTL_APPL_OMS.CUSTOMER_ORDER_LINE_ITEM_3/PRODUCT_DESC) }
>               </PRODUCT_DESC>
>           <QUANTITY>{ cast as xs:int(xf:data($RTL_APPL_OMS.CUSTOMER_ORDER_LINE_ITEM_3/QUANTITY)}
>         </QUANTITY>
>             </LINE_ITEM>
>             }
>           </retailerType:ORDER_SUMMARY>
>           }
>           {
>           for $ElectOrderService:getOrderSummaryByStatus.__5 in
>           ElectOrderService:getOrderSummaryByStatus($#custid of type xs:string, "OPEN")/result/*
>           let $xfext:date_from_dateTime2_7 :=
>      xfext:date-from-dateTime($ElectOrderService:getOrderSummaryByStatus.__5/elecOrd:orderDate)
>           let $xfext:date_to_string_with_format2_8 :=
>             xfext:date-to-string-with-format("yyyy-MM-dd",  treat as
>               xs:date($xfext:date_from_dateTime2_7))
>           let $xfext:date_from_dateTime_11 :=
>             xfext:date-from-dateTime
>               ($ElectOrderService:getOrderSummaryByStatus.__5/elecOrd:estimatedShipDate)
>           let $xfext:date_to_string_with_format_12 :=
>             xfext:date-to-string-with-format("yyyy-MM-dd",  treat as
>               xs:date($xfext:date_from_dateTime_11))
>           return
>           <retailerType:ORDER_SUMMARY TYPE={"ELEC"}>
>             <ORDER_ID>{ xf:data($ElectOrderService:getOrderSummaryByStatus.__5/elecOrd:orderID)
>                       }
>             </ORDER_ID>
>             <ORDER_DATE>{  treat as xs:date(xfext:date-from-string-with-format("yyyy-MM-dd",
>                 $xfext:date_to_string_with_format2_8)) }
>             </ORDER_DATE>
>             <TOTAL_ORDER_AMOUNT>{ xf:data
>                 ($ElectOrderService:getOrderSummaryByStatus.__5/elecOrd:totalOrderAmount) }
>             </TOTAL_ORDER_AMOUNT>
>             <SHIP_TO_NAME>{ xf:data
>               ($ElectOrderService:getOrderSummaryByStatus.__5/elecOrd:shipToName) }
>             </SHIP_TO_NAME>
>             <ESTIMATED_SHIP_DATE>{  treat as xs:date(xfext:date-from-string-with-format
>               ("yyyy-MM-dd", $xfext:date_to_string_with_format_12)) }
>             </ESTIMATED_SHIP_DATE>
>             <TRACKING_NUMBER>{ xf:data
>               ($ElectOrderService:getOrderSummaryByStatus.__5/elecOrd:trackingNumber) }
>             </TRACKING_NUMBER>
>             {
>             for $ElectOrderService:getOrderSummaryByStatus.__15 in
>                 $ElectOrderService:getOrderSummaryByStatus.__5/elecOrd:items/*
>             return
>             <LINE_ITEM>
>               <PRODUCT_DESC>{
>                 xf:data($ElectOrderService:getOrderSummaryByStatus.__15/elecOrd:productDesc) }
>               </PRODUCT_DESC>
>               <QUANTITY>{
>                 xf:data($ElectOrderService:getOrderSummaryByStatus.__15/elecOrd:quantity) }
>               </QUANTITY>
>             </LINE_ITEM>
>             }
>           </retailerType:ORDER_SUMMARY>
>           }
>         </ORDERS>
>     		<CASES>
>           {
>           for $RTL_SERVICE.SERVICE_CASE_16 in document("RTL-SERVICE")/db/SERVICE_CASE
>           where ($RTL_SERVICE.SERVICE_CASE_16/CUSTOMER_ID  eq
>                   $RTL_CUSTOMER.CUSTOMER_1/CUSTOMER_ID)
>             and ($RTL_SERVICE.SERVICE_CASE_16/STATUS  eq  "OPEN")
>           return
>           <CASE>
>             <CASE_ID>{ xf:data($RTL_SERVICE.SERVICE_CASE_16/CASE_ID) }</CASE_ID>
>             <CASE_TYPE>{ xf:data($RTL_SERVICE.SERVICE_CASE_16/CASE_TYPE) }</CASE_TYPE>
>             <PRODUCT_ID>{ xf:data($RTL_SERVICE.SERVICE_CASE_16/PRODUCT_ID) }</PRODUCT_ID>
>             <STATUS>{ xf:data($RTL_SERVICE.SERVICE_CASE_16/STATUS) }</STATUS>
>             <STATUS_DATE>{ xf:data($RTL_SERVICE.SERVICE_CASE_16/STATUS_DATE) }</STATUS_DATE>
>           </CASE>
>           }
>         </CASES>
>       </CUSTOMER_VIEW>
>       }
>     </retailer:CustomerView>

### Sample Query Results

The following listing shows the results returned in XML format from the Customer View query where the customer ID parameter is Homer.

Listing 3-2 Results for the Order Query from the Avitek Sample

>     <prefix1:CustomerView xmlns:prefix1="urn:retailer">
>       <CUSTOMER_VIEW>
>         <CUSTOMER_ID>Homer</CUSTOMER_ID>
>         <FIRST_NAME>Homer</FIRST_NAME>
>         <LAST_NAME>Simpson</LAST_NAME>
>         <ORDERS>
>           <prefix2:ORDER_SUMMARY TYPE="APPL" xmlns:prefix2="urn:retailerType">
>             <ORDER_ID>ORDER_9_2</ORDER_ID>
>             <ORDER_DATE>2001-12-17</ORDER_DATE>
>             <TOTAL_ORDER_AMOUNT>134.55</TOTAL_ORDER_AMOUNT>
>             <SHIP_TO_NAME>Marge Simpson</SHIP_TO_NAME>
>             <ESTIMATED_SHIP_DATE>2001-12-20</ESTIMATED_SHIP_DATE>
>             <TRACKING_NUMBER>ORDER_9_28925737231</TRACKING_NUMBER>
>             <LINE_ITEM>
>               <PRODUCT_DESC>Osh Kosh Lt Lilac Poplin Jumper Dress</PRODUCT_DESC>
>               <QUANTITY>3</QUANTITY>
>             </LINE_ITEM>
>             <LINE_ITEM>
>               <PRODUCT_DESC>Guess Garden Denim Skirt</PRODUCT_DESC>
>               <QUANTITY>1</QUANTITY>
>             </LINE_ITEM>
>             <LINE_ITEM>
>               <PRODUCT_DESC>Gap denim front-slit skirt</PRODUCT_DESC>
>               <QUANTITY>1</QUANTITY>
>             </LINE_ITEM>
>           </prefix2:ORDER_SUMMARY>
>           <prefix2:ORDER_SUMMARY TYPE="APPL" xmlns:prefix2="urn:retailerType">
>             <ORDER_ID>ORDER_9_7</ORDER_ID>
>             <ORDER_DATE>2002-06-29</ORDER_DATE>
>             <TOTAL_ORDER_AMOUNT>221.55</TOTAL_ORDER_AMOUNT>
>             <SHIP_TO_NAME>Homer Simpson</SHIP_TO_NAME>
>             <ESTIMATED_SHIP_DATE>2002-07-06</ESTIMATED_SHIP_DATE>
>             <TRACKING_NUMBER>ORDER_9_77132565448</TRACKING_NUMBER>
>             <LINE_ITEM>
>               <PRODUCT_DESC>Kenneth Cole Reaction Broadcloth Fancy Dress Shirt
>               </PRODUCT_DESC>
>               <QUANTITY>3</QUANTITY>
>             </LINE_ITEM>
>             <LINE_ITEM>
>               <PRODUCT_DESC>Gap personal jean</PRODUCT_DESC>
>               <QUANTITY>1</QUANTITY>
>             </LINE_ITEM>
>             <LINE_ITEM>
>               <PRODUCT_DESC>Hooded Pullover Fleece Sweatshirt</PRODUCT_DESC>
>               <QUANTITY>1</QUANTITY>
>             </LINE_ITEM>
>           </prefix2:ORDER_SUMMARY>
>           <prefix2:ORDER_SUMMARY TYPE="APPL" xmlns:prefix2="urn:retailerType">
>             <ORDER_ID>ORDER_9_12</ORDER_ID>
>             <ORDER_DATE>2003-01-09</ORDER_DATE>
>             <TOTAL_ORDER_AMOUNT>476.55</TOTAL_ORDER_AMOUNT>
>             <SHIP_TO_NAME>Marge Simpson</SHIP_TO_NAME>
>             <ESTIMATED_SHIP_DATE>2003-01-12</ESTIMATED_SHIP_DATE>
>             <TRACKING_NUMBER>ORDER_9_127771190162</TRACKING_NUMBER>
>             <LINE_ITEM>
>               <PRODUCT_DESC>Lands End Athelic Slides</PRODUCT_DESC>
>               <QUANTITY>3</QUANTITY>
>             </LINE_ITEM>
>             <LINE_ITEM>
>               <PRODUCT_DESC>Hush Poppies Angella II</PRODUCT_DESC>
>               <QUANTITY>1</QUANTITY>
>             </LINE_ITEM>
>             <LINE_ITEM>
>               <PRODUCT_DESC>Debra Sandal at Nodstrom</PRODUCT_DESC>
>               <QUANTITY>1</QUANTITY>
>             </LINE_ITEM>
>           </prefix2:ORDER_SUMMARY>
>           <prefix2:ORDER_SUMMARY TYPE="APPL" xmlns:prefix2="urn:retailerType">
>             <ORDER_ID>ORDER_9_17</ORDER_ID>
>             <ORDER_DATE>2003-07-22</ORDER_DATE>
>             <TOTAL_ORDER_AMOUNT>2331.55</TOTAL_ORDER_AMOUNT>
>             <SHIP_TO_NAME>Homer Simpson</SHIP_TO_NAME>
>             <ESTIMATED_SHIP_DATE>2003-07-29</ESTIMATED_SHIP_DATE>
>             <TRACKING_NUMBER>ORDER_9_175524055754</TRACKING_NUMBER>
>             <LINE_ITEM>
>               <PRODUCT_DESC>Burberry Nova Check Hobo</PRODUCT_DESC>
>               <QUANTITY>3</QUANTITY>
>             </LINE_ITEM>
>             <LINE_ITEM>
>               <PRODUCT_DESC>Prada Patent Leather Handbag</PRODUCT_DESC>
>               <QUANTITY>1</QUANTITY>
>             </LINE_ITEM>
>             <LINE_ITEM>
>               <PRODUCT_DESC>Prada tote</PRODUCT_DESC>
>               <QUANTITY>1</QUANTITY>
>             </LINE_ITEM>
>           </prefix2:ORDER_SUMMARY>
>           <prefix2:ORDER_SUMMARY TYPE="ELEC" xmlns:prefix2="urn:retailerType">
>             <ORDER_ID>ORDER_9_4</ORDER_ID>
>             <ORDER_DATE>2003-01-09</ORDER_DATE>
>             <TOTAL_ORDER_AMOUNT>429.55</TOTAL_ORDER_AMOUNT>
>             <SHIP_TO_NAME>Marge Simpson</SHIP_TO_NAME>
>             <ESTIMATED_SHIP_DATE>2003-01-11</ESTIMATED_SHIP_DATE>
>             <TRACKING_NUMBER>ORDER_9_42871564731</TRACKING_NUMBER>
>             <LINE_ITEM>
>               <PRODUCT_DESC>Samsung SS8</PRODUCT_DESC>
>               <QUANTITY>3</QUANTITY>
>             </LINE_ITEM>
>             <LINE_ITEM>
>               <PRODUCT_DESC>D-Link Wireless 22 Mbps Broadband Router
>               </PRODUCT_DESC>
>               <QUANTITY>1</QUANTITY>
>             </LINE_ITEM>
>             <LINE_ITEM>
>               <PRODUCT_DESC>Samsung DVD-V2000 DVD/VCR Combo</PRODUCT_DESC>
>               <QUANTITY>1</QUANTITY>
>             </LINE_ITEM>
>           </prefix2:ORDER_SUMMARY>
>         </ORDERS>
>         <CASES/>
>       </CUSTOMER_VIEW>
>     </prefix1:CustomerView>

# Definitions of Key Terms

This topic introduces the following key Liquid Data concepts:

- Data Sources
- Queries, Results, and Schemas
- Data Views
- Caching
- Custom Functions

For a description of Liquid Data components, see Liquid Data Architecture Components.

## Data Sources

In Liquid Data, a data source is a source of information that can be queried. Liquid Data supports querying the following types of data sources:

- Relational databases (RDBMSs), including stored procedures, via JDBC
- Web services
- Application views, which are business-level interfaces to data in packaged application such as Siebel, PeopleSoft, or SAP. Application views are used in conjunction with the WebLogic Adapters.
- XML files, delimited files
- Data views, which are the dynamic results of queries stored along with the queries that produce them

You use the WebLogic Administration Console to configure access to data sources. For more information, see the following topics in the Liquid Data Administration Guide:

- Configuring Access to Relational Databases Configuring Access to XML Files
- Configuring Access to Delimited Files
- Configuring Access to Web Services
- Configuring Access to Application Views
- Configuring Access to Data Views

You can use the Data View Builder to design and build queries that query the data sources you have configured. Alternatively, you can use a text editor to create the queries. Queries are built based on source and target schemas that describe the structure of the data queried (source) and returned (target). For more information about creating queries, see Building Queries and Data Views.

## Queries, Results, and Schemas

A query is a request for information based on explicit criteria. In Liquid Data, queries are created and used in compliance with the XQuery language specification. With the Data View Builder, you can create queries using a drag-and-drop paradigm between source and target schemas.

Users can create and access two types of queries:

- Stored queries are XQuery queries that have been saved in the Liquid Data repository.
- Ad hoc queries are queries that have not been stored in the Liquid Data repository but rather are passed to the Liquid Data server on the fly. An ad-hoc query is any hand-coded query or Data View Builder-generated query that is not a stored query.

A result is the information that a query yields. In Liquid Data, the query result is generated in XML format. The target schema is an XML schema that describes the shape (structure and legal elements) of the output data—that is, the result of a query. The Liquid Data server runs queries against source data and returns the result of a query in the form in which you define for target data.

For more information about queries, results, and target schemas, see Overview and Key Concepts in Building Queries and Data Views.

## Data Views

A data view is a query that can be used as a data source for other queries. Data views provide a logical view of the data, abstracting all of the details of the underlying data sources from the application developer. Developers can then easily create queries for their applications without requiring any knowledge about the specific underlying systems. In this way, application developers, not just data architects, can directly access distributed, heterogeneous data sources. For more information about data views, see Overview and Key Concepts and Using Data Views as Data Sources in Building Queries and Data Views.

## Caching

Liquid Data caches information about commonly executed queries for subsequent, efficient retrieval, thereby enhancing overall system performance. Liquid Data supports two types of caching:

- The query plan cache is a memory-based cache that stores the query plans of commonly executed queries.
- The result set cache is a database-based cache that stores the results of commonly executed queries. For more information, see Configuring the Query Results Cache in the Liquid Data Administration Guide.

## Custom Functions

Custom functions are user-defined functions that perform specialized tasks. The Liquid Data provides a set of standard functions for use in creating data views and queries. In addition, users can create custom functions, which are implemented in Java code, declared in a custom functions library definition (CFLD) file (in XML format), and then configured in the Administration Console. Custom functions can be used for a wide range of requirements including implementing customized data manipulation, accessing external or custom legacy systems, and so on. Once configured, custom functions display as functions available for use in the Data View Builder. For more information about custom functions, see Using Custom Functions in the Application Developer's Guide and Configuring Access to Custom Functions in the Liquid Data Administration Guide.