Configuring the Proposals in the Content Completion Assistant
Oxygen XML Editor gathers information from the associated schemas (DTDs, XML Schema,
RelaxNG) to determine the proposals that appear in the Content Completion
Assistant. Oxygen XML Editor also includes support that allows you to
configure the possible attribute or element values for the proposals. To do so, a
configuration file can be used, along with the associated schema, to add or replace possible
values for attributes or elements that are proposed in the Content Completion
Assistant. An example of a specific use-case is if you want the
Content Completion Assistant to propose several possible values for
the language code whenever you use an xml:lang attribute.
To configure content completion proposals, follow these steps:
- Create a new resources folder (if it does not already exist) in the
frameworks directory for the document type. For instance:
OXYGEN_INSTALL_DIR/frameworks/dita/resources.
- Open the
Preferences dialog box and go to Document
Type Association. Edit the document type configuration for your XML
vocabulary, and in the Classpath tab add a link to that
resources folder.
- Use the New document wizard to create a configuration file using
the Content Completion Configuration file template.
- Make the appropriate changes to your custom configuration file. The file template
includes details about how each element and attribute is used in the configuration
file.
- Save the file in the resources folder, using the fixed name:
cc_value_config.xml.
- Re-open the application and open an XML document. In the Content Completion
Assistant you should see your customizations.
The Configuration File
The configuration file is composed of a series of
match instructions that
will match either an element or an attribute name. A new value is specified inside one or
more
item elements, which are grouped inside an
items
element. The behavior of the
items element is specified with the help of
the
action attribute, which can have any of the following values:
- append - Adds new values to appear in the proposals list (default
value).
- addIfEmpty - Adds new values to the proposals list, only if no other
values are contributed by the schema.
- replace - Replaces the values contributed by the schema with new
values to appear in the proposals list.
The values in the configuration file can be specified either directly or by calling an
external XSLT file that will extract data from any external source.
Example - Specifying Values Directly
<match elementName="lg" elementNS="http://www.oxygenxml.com/ns/samples">
<items action="replace">
<item value="stanza"/>
<item value="refrain"/>
</items>
</match>
<match attributeName="type">
<items>
<item value="stanza"/>
<item value="refrain"/>
</items>
</match>
Example - Calling an External XSLT Script
<xslt href="../xsl/get_values_from_db.xsl" useCache="false" action="replace"/>
In this example, the
get_values_from_db.xsl is executed in order to
extract values from a database.
Note: A comprehensive XSLT sample is included in the
Content Completion Configuration file template.