Content Completion in XPath Expressions

In XSLT stylesheets, the Content Completion Assistant provides all the features available in the XML editor and also adds some enhancements. In XPath expressions used in attributes of XSLT stylesheets elements like match, select and test, the Content Completion Assistant offers the names of XPath and XSLT functions, the XSLT axes, and user-defined functions (the name of the function and its parameters). If a transformation scenario was defined and associated to the edited stylesheet, the Content Completion Assistant computes and presents elements and attributes based on:

The associated document is displayed in the XSLT/XQuery Input view.

Content completion for XPath expressions is started:

The items presented in the content completion window are dependent on:

For example, if the document associated with the edited stylesheet is:

<personnel>
    <person id="Big.Boss">
        <name>
            <family>Boss</family>
            <given>Big</given>
        </name>
        <email>chief@oxygenxml.com</email>
        <link subordinates="one.worker"/>
    </person>
    <person id="one.worker">
        <name>
            <family>Worker</family>
            <given>One</given>
        </name>
        <email>one@oxygenxml.com</email>
        <link manager="Big.Boss"/>
    </person>
</personnel>

and you enter an xsl:template element using the content completion assistant, the following actions are triggered:

The set of XPath functions depends on the XSLT version declared in the root element xsl:stylesheet: 1.0, 2.0 or 3.0.

Content Completion in the match Attribute

If the cursor is inside the select attribute of an xsl:for-each, xsl:apply-templates, xsl:value-of or xsl:copy-of element the content completion proposals depend on the path obtained by concatenating the XPath expressions of the parent XSLT elements xsl:template and xsl:for-each as shown in the following figure:

Content Completion in the select Attribute

Also XPath expressions typed in the test attribute of an xsl:if or xsl:when element benefit of the assistance of the content completion.

Content Completion in the test Attribute

XSLT variable references are easier to insert in XPath expressions with the help of the content completion popup triggered by the $ character which signals the start of such a reference in an XPath expression.

Content Completion in the test Attribute

If the { character is the first one in the value of the attribute, the same Content Completion Assistant is available also in attribute value templates of non-XSLT elements.

Content Completion in Attribute Value Templates

The time delay configured in Preferences page for all content completion windows is applied also for the XPath expressions content completion window.