Content starts here The XQuery Expression Editor
This page last changed on Mar 11, 2008.

eDocs Home > BEA AquaLogic Data Services Platform Documentation > Data Services Developer's Guide > Contents

How To Edit XQuery Expressions

This topic describes how to edit XQuery expressions in the expression editor in Studio.

Overview

You can edit the generated XQuery expressions in an update map using the expression editor.

The Expression Editor in an Update Map

The update map expression language is a subset of XQuery syntax. In an update map, you can use any of the following XQuery constructs.

Type Description Example
Variable A variable already defined in a For Each or Update block in the update map.
$$root is a special predefined variable that refers to the root of the service's XML type.
$ORDER_WITH_LINE_ITEM
$CUSTOMER
Constant A numeric, string, or other constant. "a"
"12345"
Constant Cast A constant cast to another XSD data type using the parentheses operator. xsd:date("2007-01-01") 
Function A call to any XQuery function. You can see the built-in and BEA-provided functions in the Design Palette. You can use a variable, path, or constant as an argument to a function.
fn-bea:value($CUSTOMER/FIRST_NAME)
Path An expression that locates an XML element in a tree using variables, elements, and attributes. The syntax is:
$VARIABLE_NAME
/elementName
@attributeName
$ORDER_WITH_LINE_ITEM/CUSTOMER_ORDER/ORDER_ID

Namespace prefixes are declared in the data service's XQuery source, which you can see in the Source tab. If a namespace is only used in the update map, and not in the logical data service, you must declare it. If a namespace cannot be resolved, it is shown with the prefix ns?.

The most common ways you use the expression editor are to:

The fn-bea:value Function

A mapping between an element in a return type and an element in an update block uses the fn-bea:value function with a path name, for example:

fn-bea:value($CUSTOMER/CUSTOMER_ID)

An update mapping should always use fn-bea:value, whether ALDSP auto-generates the mapping or you draw it. If you remove the fn:bea:value function from the expression and simply use an XQuery path expression ($CUSTOMER/CUSTOMER_ID), the element becomes disabled in the update map and you see this error message:

    The expression does not match the expected type for this element
    The expression assigned to this element is not valid
    Hint: did you forget to use the value function?

The fn-bea:value function is required, because an update map updates a Service Data Object (SDO) and requires a special XML structure called a datagraph that includes a change summary showing both the old and new values. The fn-bea:value function handles the update to the SDO correctly.

If you do not use fn-bea:value, ALDSP throws an exception when you attempt to update the value.

See Also

Concepts
How Tos
Other Sources
Document generated by Confluence on Apr 28, 2008 15:54