<oXygen/>'s intelligent Content Completion feature is a content assistant that enables rapid, in-line identification and insertion of structured language elements, attributes and in some cases their parameter options.
If the Content Completion assistant is enabled in user preferences (the option Use Content Completion) it is automatically displayed whenever the < character is entered into a document or by pressing CTRL+Space on a partial element or attribute name. Moving the focus to highlight an element and pressing the Enter key or the Tab key, inserts both the start and end tags of the highlighted element into the document.
The DTD, XML Schema, Relax NG, NRL or NVDL schema used to populate the Content Completion assistant is specified in the following methods, in order of precedence:
The schema specified explicitly in the document. In this case <oXygen/> reads the beginning of the document and resolves the location of the DTD, XML Schema, Relax NG schema, NRL or NVDL schema.
![]() | Note |
---|---|
Limitation: In case of XML Schema the content completion takes into account only the schema declarations from the root element of the document. If a schema declaration is attached to other element of the XML document it is ignored. |
The default schema rule declared in the Document Type Association preferences panel which matches the edited document.
After inserting, the cursor is positioned directly before the > character of the start tag, if the element has attributes, in order to enable rapid insertion of any attributed supported by the element, or after the > char of the start tag if the element has no attributes. Pressing the space bar, directly after element insertion will again display the assistant. In this instance the attributes supported by that element will be displayed. If an attribute supports a fix set of parameters, the assistant will display the list of valid parameter. If the parameter setting is user defined and therefore variable, the assistant will be closed to enable manual insertion. The values of the attributes can be learned from the same elements in the current document.
If you press CTRL + Enter instead of Enter or Tab after inserting the start and end tags in the document <oXygen/> will insert an empty line between the start and end tag and the cursor will be positioned between on the empty line on an indented position with regard to the start tag.
If the feature Add Element Content of Content Completion is enabled all the elements that the new element must contain, as specified in the DTD or XML Schema, are inserted automatically in the document. The Content Completion assistant can also add optional content and first choice particle, as specified in the DTD or XML Schema, for the element if the two options are enabled.
The content assistant can be started at any time by pressing CTRL+Space Also it can be started with the action Start Content Completion (default shortcut is CTRL + Slash) which can be configured in : category → Content Completion, description Start Content Completion. The effect is that the context-sensitive list of proposals will be shown in the current position of the caret in the edited document if element, attribute or attribute value insertion makes sense. Such positions are: anywhere within a tag name or at the beginning of a tag name in an XML document, XML Schema, DTD or Relax NG (full or compact syntax) schema, anywhere within an attribute name or at the beginning of an attribute name in any XML document with an associated schema, and within attribute values or at the beginning of attribute values in XML documents where lists of possible values have been defined for that element in the schema associated with the document.
The content of the Content Completion assistant is dependent on the element structure specified in the DTD, XML Schema, Relax NG (full or compact syntax) schema or NRL, NVDL schema associated to the edited document.
The number and type of elements displayed by the assistant is dependent on the current position of the cursor in the structured document . The child elements displayed within a given element are defined by the structure of the specified DTD, XML Schema, Relax NG (full or compact syntax) schema or NRL, NVDL schema. All elements that can't be child elements of the current element according to the specified schema are not displayed.
Inside Relax NG documents the Content Completion assistant is able to present element values if such values are specified in the Relax NG schema. Also in Relax NG documents the Content Completion assistant presents additional values of type ID for an anyURI data type. It presents also pattern names defined in the Relax NG schema as possible values for pattern references. For example if the schema defines an enumValuesElem element
<element name="enumValuesElem"> <choice> <value>value1</value> <value>value2</value> <value>value3</value> </choice> </element>
in documents based on the schema the Content Completion assistant offers the list of values:
If the schema for the edited document defines attributes of type ID and IDREF the content assistant will display for IDREF attributes a list of all the ID values already present in the document for an easy insertion of a valid ID value at the cursor position in the document. This is available for documents that use DTD, XML Schema and Relax NG schema.
Also values of all the xml:id attributes are treated as ID attributes and collected and displayed by the content completion assistant as possible values for anyURI attributes defined in the schema of the edited document. This works only for XML Schema and Relax NG schemas.
For documents that use an XML Schema or Relax NG schema the content assistant offers proposals for attributes and elements values that have as type an enumeration of tokens. Also if a default value or a fixed value is defined in the XML Schema used in validation for an attribute or element then that value is offered in the content completion window.
If the edited document is not associated with a schema explicitly using the usual mechanisms for associating a DTD or XML Schema with a document or using a processing instruction introduced by the Associate schema action the content assistant will extract the elements presented in the pop-up window from the default schema.
If the schema for the document is of type XML Schema, Relax NG (full syntax), NVDL or DTD and it contains element, attributes or attributes values annotations, these will be presented when the content completion window is displayed, if the option Show annotations is enabled. Also the annotation is presented in a small tooltip window displayed automatically when the mouse hovers over an element or attribute annotated in the associated schema of the edited document. The tooltip window can be invoked at any time using the F2 shortcut.
In an XML Schema annotations are put in an <xs:annotation> element:
<xs:annotation> <xs:documentation> Description of the element. </xs:documentation> </xs:annotation>
If the current element / attribute in the edited document does not have an annotation in the schema and that schema is of the type XML Schema <oXygen/> seeks an annotation in the type definition of the element / attribute or, if no annotation is found there, in the parent type definition of that definition, etc.
In a Relax NG schema any element outside the Relax NG namespace (http://relaxng.org/ns/structure/1.0) is handled as annotation and the text content is displayed in the annotation window together with the content completion window:
For NVDL schemas annotations for the elements / attributes in the referred schemas (XML Schema, RNG, etc) are presented
The following HTML tags are recognized inside the text content of an XML Schema annotation: p, br, ul, li. They are rendered as in an HTML document loaded in a web browser: p begins a new paragraph, br breaks the current line, ul encloses a list of items, li encloses an item of the list.
For DTD <oXygen/> defines a custom mechanism for annotation using comments enabled from the option Use DTD comments as annotations . The text of a comment with the following format will be presented on content completion:
<!--doc:Description of the element. -->
The operation of the Content Completion assistant is configured by the options available in the options group called Content Completion.
You can define short names for predefined blocks of code called code templates. The short names are displayed in the content completion window if the word at cursor position is a prefix of such a short name. <oXygen/> comes with a lot of predefined code templates but you can define your own code templates for any type of editor.