Data Services Developer's Guide

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

Working with XQuery Source

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


What is Source View?

The underlying XQuery source of a data service typically:

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.

Syntax Errors Are Flagged and Mouse-over Text Provides Details

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

AquaLogic 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.

AquaLogic Data Services Platform supplements the base XQuery syntax with a set of elements and directives that appear in 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 AquaLogic Data Services Platform XQuery Developer's Guide.

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

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 Arrow symbol 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

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

Color Coding in Source View

You can customize color coding through the Preferences dialog (Tools Arrow symbol Preferences).

Code Completion

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

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).
  4. Figure 8-5 XPath Code Completion in Source View

    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:

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

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 file to add class files or JAR files to the paths.classPath property, then restart WebLogic Workshop.

  Back to Top       Previous  Next