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.
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.
<!-- Replaces the values for an element with the local name "lg", from the given namespace --> <match elementName="lg" elementNS="http://www.oxygenxml.com/ns/samples"> <items action="replace"> <item value="stanza"/> <item value="refrain"/> </items> </match> <!-- Adds two values for an attribute with the local name "type", from any namespace --> <match attributeName="type"> <items> <item value="stanza"/> <item value="refrain"/> </items> </match>
<xslt href="../xsl/get_values_from_db.xsl" useCache="false" action="replace"/>
A more complex scenario for configuring the content completion proposals would be if you want to choose the possible values to provide, depending on the context of the element in which the content completion was invoked.
Suppose that you want to propose certain possible values for one property (for example, color) and other values for another property (for example, shape). If the property represents a color, then the values should represent applicable colors, while if the property represents a shape, then the values should represent applicable shapes. See the following code snippets:
<sampleArticle> <!-- The possible values for @value should be "red" and "blue" --> <property name="color" value=""/> <!-- The possible values for @value should be "square" and "rectangle" --> <property name="shape" value=""/> </sampleArticle>The content completion configuration file:
<config xmlns="http://www.oxygenxml.com/ns/ccfilter/config"> <match elementName="property" attributeName="value"> <xslt href="get_values.xsl" useCache="false" action="replace"/> </match> </config>The stylesheet that defines the possible values based on the context of the property on which the content completion was invoked:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:saxon="http://saxon.sf.net/" exclude-result-prefixes="xs" version="2.0"> <xsl:param name="documentSystemID" as="xs:string"></xsl:param> <xsl:param name="contextElementXPathExpression" as="xs:string"></xsl:param> <xsl:template name="start"> <xsl:apply-templates select="doc($documentSystemID)"/> </xsl:template> <xsl:template match="/"> <xsl:variable name="propertyElement" select="saxon:eval(saxon:expression($contextElementXPathExpression, ./*))"/> <items> <xsl:if test="$propertyElement/@name = 'color'"> <item value='red'/> <item value='blue'/> </xsl:if> <xsl:if test="$propertyElement/@name = 'shape'"> <item value='rectangle'/> <item value='square'/> </xsl:if> </items> </xsl:template> </xsl:stylesheet>