GoLand 2018.2 Help

XPath Expression Evaluation

An XPath expression needs evaluation to test it before using in program code or XSLT scripts or before, making structured queries against XML documents.

GoLand lets you evaluate XPath expressions in two modes:

  • In the Simple mode, you can enter simple one-line expressions that don't require any customization of namespace prefixes. This mode does not let you configure Context settings or use predefined variables.
  • In the Advanced mode, you can conveniently edit long expressions in a multi-line mode and edit the XPath context.

Some error checks and XPath inspections also provide Quick Fixes for detected problems, e.g. the possibility to map an unresolved namespace-prefix to a URI by intention.

To evaluate an XPath expression

  1. Choose Evaluate XPath from the context menu of the active editor tab or go to Edit | Find | Evaluate XPath. The Evaluate XPath Expression dialog box opens.
  2. To toggle the evaluation mode, click the Advanced/Simple button. In either mode, the dialog box features a history of the recently evaluated expressions, completion, syntax-checking and highlighting, as well as some semantic error checking of the entered expression. Semantic checks include validation of used namespace prefixes, useless XPath expressions (e.g. @comment()) and node tests for element/attribute names that don't occur in the context document and would not be successfully matched.
  3. To browse through the history of expressions:
    • In the Simple mode, the last recently used expressions can be selected from the drop-down list.
    • In the Advanced mode, use icons actions previousOccurence svg/icons actions nextOccurence svg or press Alt+Up/Alt+Down.
  4. To reconfigure the XPath context, click Edit Context. In the dialog that opens, assign custom prefixes to the namespace URIs that are used in the context document and define variables to use in queries for repeating expressions.

    It can be useful to assign a shorter prefix, resolve prefix clashes or to actually define a prefix for the default namespace. This can be essential because XPath does not automatically match elements in the default namespace without specifying a prefix for the element to be matched. edit namespaces and their prefixes and

    Each variable in the table can be assigned an expression that will be evaluated once when the query is executed. The resulting value is then available for multiple use at no additional computational cost.

  5. Optionally:
    • Select the Highlight results checkbox ti highlight the matched nodes in the current editor. Matched nodes that don't belong to the current editor (may happen by using the document() function) are not highlighted. It's recommended to display such cross-document results in the Find Usages tool window.
    • Select the Show results in Usage View checkbox to show all matched nodes in the Find Usages tool window. Select the Open in new tab checkbox to open the result in a new tab instead of reusing the last one.
Last modified: 15 August 2018