The content completion assistant adds special features for editing XSLT stylesheets.
Inside XSLT templates of an XSLT stylesheet the content completion presents also all the elements allowed in any context by the schema associated to the result of applying the edited stylesheet. That schema is defined by the user in the Content Completion / XSL preferences. There are presented all the elements because in a template there is no context defined for the result document so the user is allowed to insert any element defined by the schema of the result document.
Namespace prefixes in scope for the current context are presented at the top of the content completion window to speed the insertion of prefixed elements into the document.
In XSLT stylesheets the content completion assistant provides all the features available in the editor for XML documents and also adds some enhancements. In XPath expressions used in attributes of XSLT stylesheets elements like match, select and test it offers XPath functions, XSLT functions, XSLT axes and user defined functions. 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 input XML document selected in the scenario and on the current context in the stylesheet. The associated document is displayed in the XSLT/XQuery input view.
Content Completion for XPath expressions is started:
on XPath operators detected in one of the match, select and test attributes of XSLT elements: ", ', /, //, (, [, |, :, ::, $
for attribute value templates of non XSLT elements, that is the '{' character is detected as the first character of the attribute value
on request if the combination CTRL + Space is pressed inside an edited XPath expression
The items presented in the content completion window are dependent on the context of the current XSLT element, the XML document associated with the edited stylesheet in the transformation scenario of the stylesheet and the XSLT version of the stylesheet (1.0 or 2.0). 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 element xsl:template using the content completion assistant the match attribute is inserted automatically, the cursor is placed between the quotes and the XPath content completion assistant automatically displays a popup window with all the XSLT axes, XPath functions and elements and attributes from the XML input document that can be inserted in the current context. The set of XPath functions depends on the XSLT version declared in the root element - xsl:stylesheet (1.0 or 2.0).
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 are dependent of the path obtained by concatenating the XPath expressions of the parent XSLT elements xsl:template and xsl:for-each like the following figure shows:
Also XPath expressions typed in the test attribute of an xsl:if or xsl:choose / xsl:when element benefit of the assistance of the content completion.
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.
The same content completion assistant is available also in attribute value templates of non XSLT elements if the '{' character is the first one in the value of the attribute.
When editing the arguments of an XPath/XSLT function, <oXygen/> keeps track of the current entered argument by displaying a tooltip above the function containing the function signature. The currently edited argument is displayed in bold.
When moving the caret through the expression, the tooltip is updated to reflect the argument that is found at the caret position.
Let's consider the following example. We are concatenating the absolute value of two variables: v1 and v2.
<xsl:template match="/"> <xsl:value-of select="concat(abs($v1), abs($v2))"></xsl:value-of> </xsl:template>
When moving the caret before the first "abs" function, the editor will identify that it represent the first argument of the "concat" function, and will show in bold that the first argument is named "$arg1" and is of type "xdt:anyAtomicType" and it is optional. The function takes also other arguments, having the same type, and returns a "xs:string".
Moving the caret on the first variable "$v1", the editor identifies the "abs" as context function and shows its signature:
Further, clicking on the second "abs" function name, the editor detects that it represents the second argument of the "concat function". It redisplays the correct tooltip, displaying the second argument in bold.
The tooltip helper is present also in the XPath Toolbar and the XPath Builder.