<oXygen/> XML Editor User Guide

Working with XQuery

What is XQuery

XQuery is the query language for XML and is currently under development at the W3C. The many benefits of XQuery include:

  • XQuery allows you to work in one common model no matter what type of data you're working with: relational, XML, or object data.

  • XQuery is ideal for queries that must represent results as XML, to query XML stored inside or outside the database, and to span relational and XML sources.

  • XQuery allows you to create many different types of XML representations of the same data.

  • XQuery allows you to query both relational sources and XML sources, and create one XML result.

Syntax Highlight and Content Completion

To create a new XQuery document select File-> New (Ctrl+N) and when the New Document dialog appears select XQuery entry.

Once you created the new document <oXygen/> provides syntax highlight for keywords and all known XQuery functions and operators. Also for these there is available a code-insight component that can be activated by pressing Ctrl+Space keys. The functions and operators are presented together with a comment about parameters and functionallity.

Figure 6.1. XQuery Tag Insight

XQuery Tag Insight

XQuery Validation

With <oXygen/> you can validate your documents before using them in your transformation scenarios. The validation uses the Saxon 8.1B processor or the Saxon 8 SA if you installed it. This is conformant to the XQuery Working Draft http://www.w3.org/TR/xquery/. The processor is used in two cases: validation of the expression and execution. Although the execution implies a validation, it is faster to syntactically check the expression without executing it. The errors that occurred in the document are presented in the messages view at the bottom of editor window, with a full description message. As with all error messages, if you click on one entry, the line where the error appeared is highlighted.

Figure 6.2. XQuery Validation

XQuery Validation

Transforming XML Documents Using XQuery

XQueries are very similar to the XSL stylesheets in the sense they both are capable of transforming an XML input into another format. You can define transformation scenarios that specify the input URL, the preview mode, XML or XHTML. The result can be saved and opened in the associated application. You can even run a FO processor on the output of an XQuery. The transformation scenarios may be shared between many XQuery files, and are exported at the same time with the XSLT scenarios. The transformation performed can be based on the XML document specified in the Input field, or, if this field is empty, the documents refferred from the query expression are used instead.

The transformation uses the processor Saxon 8.1B or Saxon 8 SA if you installed it.