The XQuery Expression Editor This page last changed on Nov 28, 2008. .stickable, h1, h2, h3, h4, h5 false true Show Sticky notes Hide Sticky notes Save Cancel Oracle Data Service Integrator Documentation > Data Services Developer's Guide # How To Edit XQuery Expressions This topic describes how to edit XQuery expressions in the expression editor in Workshop for WebLogic. Overview The fn-bea:value Function See Also ## 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 Oracle-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: Add a constant to an unmapped element Cast a constant to an XSD data type, especially to resolve update block elements with no mappings Use an XQuery function available in the Design Palette to cast a value Use a custom XQuery cast function you have written ## 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 Oracle Data Service Integrator 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, Oracle Data Service Integrator throws an exception when you attempt to update the value. ## See Also ##### Concepts Understanding Update Maps ##### How Tos Handle Unmapped Required Values (includes Cast a Constant) Cast Using a Built-In XQuery Function Cast Using a Custom XQuery Function ##### Other Sources W3Schools XQuery Tutorial

Document generated by Confluence on Jan 13, 2009 15:57