Oxygen XPath Toolbar

To use XPath expressions effectively, you need a good understanding of the XPath Core Function Library. Oxygen XML Author provides an XPath toolbar that eases the development of XML documents.

In Oxygen XML Author you can execute an XPath expression (XPath 1.0, XPath 2.0, XPath 2.0 SA, XPath 3.0, XPath 3.0 SA) ( from the XPath toolbar. To execute an XPath expression . You can use the XPath toolbar to execute both XPath 2.0 basic and XPath 2.0 schema aware expressions. XPath 2.0 schema aware takes into account the Saxon EE XML Schema version option.
Note: The results returned by XPath 2.0 SA and XPath 3.0 SA have a location limited to the line number of the start element (there are no column information and no end specified).
Note: Oxygen XML Author uses Saxon to execute XPath 3.0 expressions, but implements a part of the 3.0 functions. When using a function that is not implemented, Oxygen XML Author can return a compilation error.

Syntax highlight is available in the XPath toolbar and allows you to identify the components of an XPath expression. To customize the colors of the components of an XPath expression, go to Options > Preferences > Editor > Colors.

The content completion assistant is also available in the XPath toolbar. It offers context-dependent proposals and takes into account the cursor position in the document you are editing. The set of XPath functions proposed by the content completion assistant also depends on the XPath version. Select the XPath version from this drop-down menu on the XPath toolbar.

In the following figure, the content completion assistant offers element names from the current document and all XPath 2.0 functions:

Content Completion in the XPath toolbar

When Oxygen XML Author evaluates an XPath expression, it uses XML catalogs to resolve the location of documents referred in the expression. To configure XML catalogs, go to Options > Preferences > XML > XML catalog. .

An example is evaluating the collection(URIofCollection) function (XPath 2.0). To resolve the references from the files returned by the collection() function with an XML catalog, specify the class name of the XML catalog enabled parser for parsing these collection files. The class name is ro.sync.xml.parser.CatalogEnabledXMLReader. Specify it as it follows:

let $docs := collection(iri-to-uri(
    "file:///D:/temp/test/XQuery-catalog/mydocsdir?recurse=yes;select=*.xml;
    parser=ro.sync.xml.parser.CatalogEnabledXMLReader"))

Enable XPath update on caret move. to display the XPath expression at the current cursor position in the XPath toolbar, when you navigate through a document.

When you run an XPath expression, Oxygen XML Author displays the results of its execution in the Results ViewThe Results View. This view contains five columns:

To arrange the results depending on a column click on its header. To group the results by their resource, or by their system id, right click the header of any column in the results view and select Group by "Resource" or Group by "System ID". If no information regarding location is available, Oxygen XML Author displays Not available in the Location column. Oxygen XML Author displays the results in a valid XPath expression format.

- /node[value]/node[value]/node[value] -
Note: You can stop the current execution of an XPath expression by using the toolbar or by executing another XPath expression. This is valid when you execute XPath 2.0 and Xpath 3.0 expressions.

XPath results highlighted in editor panel with character precision

If you use the grid editor, when you click a record in the Results View, Oxygen XML Author highlights the entire node.

XPath results highlighted in the Grid Editor

When you type expressions longer than 60 characters, a dialog pops up and offers you the possibility to switch to the XPath builder view. The XPath builder view is specially designed to assist you with typing and testing complex XPath 1.0 / 2.0 expressions.

Using XPath with DocBook DTD

The following examples are taken from a DocBook book based on the DocBook XML DTD. The book contains a number of chapters. To return all the chapter nodes of the book, enter //chapter in the XPath expression field and press (Enter). This action returns all the chapter nodes of the DocBook book in the Results View. Click a record in the Results View to locate and highlight its corresponding chapter element and all its children nodes in the document you are editing.

To find all example nodes contained in the sect2 nodes of a DocBook XML document, use the following XPath expression: //chapter/sect1/sect2/example. Oxygen XML Author adds a result in the Results View for each example node found in any sect2 node.

For example, if the result of the above XPath expression is:

- /chapter[1]/sect1[3]/sect2[7]/example[1]

it means that in the edited file the example node is located in the first chapter, third section level one, seventh section level 2.

Important: If you define a default namespace, Oxygen XML Author binds this namespace to the first free prefix from the list: default, default1, default2, and so on. For example, if you define the default namespace xmlns="something" and the prefix default is not associated with another namespace, you can match tags without prefix in an XPath expression typed in the XPath toolbar by using the prefix default. To find all the level elements when you define a default namespace in the root element, execute this expression: //default:level in the XPath toolbar.

To define default mappings between prefixes (that you can use in the XPath toolbar) and namespace URIs go to XPath Options preferences panel and enter the mappings in the Default prefix-namespace mappings table. The same preferences panel allows you to configure the default namespace used in XPath 2.0 expressions. Different results tabs are created for each executed XPath query.

To apply an XPath expression relative to the element on which the caret is positioned, use the following actions: