Skip navigation.
Downloads | Product Documentation | Support

Data Services Developer's Guide

# Working with XQuery Source

This chapter describes BEA Aqualogic Data Services Platform (DSP) Source View. It includes the following topics:

- What is Source View?
- Using Source View

# What is Source View?

The underlying XQuery source of a data service typically:

- References a schema as the data service's XML type
- Defines one or several read functions and, optionally, one or several relationship functions
- Declares namespaces for referenced services
- Contains various pragma directives to the XQuery engine

In addition, data services created from physical data sources contain metadata related to the physical sources. For example, data services based on relational data describe the XML field type (such as xs:string), the xpath, native size, native type, null-ability setting and so forth.

In developing data services there are many occasions when it is more convenient or necessary to modifying source.

There are times when it may be preferable to develop or troubleshoot data services by working directly in source. The Source View tab allows you to directly edit data service source code, as well as schemas. Changes to source are immediately reflected in other data service modes such as the XQuery Editor; similarly, source is immediately updated when changes are made through the XQuery Editor View or Design View.

## XQuery Support

Data Services Platform supports the XQuery language as specified in XQuery 1.0: An XML Query Language, W3C Working Draft of July, 23, 2004. You can use any feature of the language described by the specification.

DSP supplements the base XQuery syntax with a set of elements and directives that appear in the source view as pragmas. Pragmas are a standard XQuery feature that give implementors and vendors a way to include custom elements and directives within XQuery code.

The BEA implementation of XQuery also contains some extensions to the language and additional functions. BEA extensions to XQuery and links to W3C documentation are described in the Data Services Platform XQuery Developer's Guide.

Figure 8-1 Source View Showing Pragmas, Namespace Declarations, and a Function

# Using Source View

You can view a file in Source View by clicking the Source View tab. To open Source View to a particular query function, first select the function from Design View or XQuery Editor View, then click the Source View tab.

## Finding Text

You can search for specific text strings in Source View using is open you can access file search using WebLogic Workshop's Edit —> Find command option or <Ctrl-f>. Complete search and replace facilities are available including specifying case, whole words only, wildcard search patterns, and limited search. You also have the option to mark all occurrences of found strings.

Found items are highlighted in yellow. This makes it easy to trace the use of variables, for example.

Figure 8-2 Source View Search Dialog Box

## Function Navigation

As a convenience you can quickly navigate to the data service represented by a particular function by clicking Ctrl while holding your mouse over a particular function call such as:

>     for $fk in f3:ADDRESS()

If you click the pop-up which repeats the function name, the data service that contains that function will open to that function.

## Code Editing Features

WebLogic Workshop contains a rich code editing environment.

### Color Coding

XQuery documents in Source View are color-coded to highlight the various elements of the source code. By default keywords are blue and bold, comments (including pragmas) are colored grey, and variables are colored magenta.

Figure 8-3 Color Coding in Source View

You can customize color coding through the Preferences dialog (Tools —> Preferences).

### Code Complete

When working with Source View you can use WebLogic Workshop function completion feature.

#### Completing Functions

If you know the namespace prefix, you can activate the function-completion mechanism.

Function completion is invoked when you type a namespace prefix followed by a colon. The namespace prefix should be bound to a URI corresponding to a data service or XFL file. Alternatively, you can type the prefix followed by a colon followed by Ctrl-Space.

Figure 8-4 Function Completion Using Namespace Prefixes

#### Completing Xpath Expressions

The function-completion facility can also be used to complete Xpath expressions:

1. Position your cursor at the end of the existing path expression.
2. Press the key combination of Ctrl-Space.
3. Select the appropriate element from the pop-up list (Figure 8-5).

Figure 8-5 XPath Code Completion in Source View

### Error Identification

Syntax errors that occur in source either as a result of editing or as a result of changes made in the XQuery Editor are flagged on Source View scroll bar (Figure 8-6). Clicking on the error mark takes the cursor to that line of code.

The actual code in question is underlined in red. Mouse-over the text to see the complete error message.

For additional information on editing the WebLogic Workshop properties configuration file see:

http://e-docs.bea.com/workshop/docs70/help/reference/configfiles/conWorkshop_propertiesConfigurationFile.html

Figure 8-6 Syntax Errors Are Flagged and Mouse-over Text Provides Details

If you would like Source View to provide code completion and error highlighting for additional classes, you can edit the `Workshop.properties` file to add class files or JAR files to the paths.classPath property, then restart WebLogic Workshop.