Edit online

Converting Subject Scheme Map Values to a DITAVAL

Read time: 3 minute(s)

Suppose you already have a Subject Scheme Map in your project and you use it to control attribute values: Controlled Attribute Values for your DITA Project.

In the Oxygen Colors and Styles preferences page, you can also assign various colors and styles to each profiling attribute (name, value) combination. One option for this is to manually re-add attributes and values in that list. Another option would be to create an XSLT stylesheet to gather all profiling attribute names and values from the Subject Scheme Map and create a DITAVAL file. The stylesheet would look like this:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    <xsl:output indent="yes"/>
    <xsl:template match="/">
            <xsl:for-each select="subjectScheme/enumerationdef">
                <!-- For each attribute name -->
                <xsl:if test="subjectdef/@keyref and attributedef/@name">
                    <xsl:variable name="attrName" select="attributedef/@name"/>
                    <xsl:variable name="keyref" select="subjectdef/@keyref"/>
                    <!-- For each key value -->
                    <xsl:for-each select="//*[@keys=$keyref]/*//@keys">
                        <xsl:variable name="attributeValue" select="."/>
                        <prop action="flag" att="{$attrName}" val="{$attributeValue}"/>

After you obtain the DITAVAL file, you can import it directly in the Colors and Styles preferences page. If the DITAVAL file has flagging information, that information will be used directly to style each attribute value.

A possibility to enhance this workaround is to specify profiling styles for each attribute value directly in the Subject Scheme map using the <data> element like:
<subjectdef keys="linux">
    <data name="color" value="yellow"/>
in this case the XSLT stylesheet would create the DITAVAL file by picking colors directly from the Subject Scheme Map:
<prop action="flag" att="{$attrName}" val="{$attributeValue}">
        <!-- Here you can also set flagging colors depending on the profiling attribute value -->
        <xsl:when test="data[@name='color']">
            <xsl:attribute name="color" select="data/@value"/>
In this way, your Subject Scheme Map will keep both the controlled attribute values and various colors and styles, which can later be used to create a DITAVAL file and either publish with those styles or import the DITAVAL file in Oxygen to highlight certain elements with various colors: https://www.oxygenxml.com/demo/Colors_and_Styles_for_Profiled_Content.html.