Re: Warning statement for both ANSI and ISO #conditional-processing #hazard-statements


Chris Brand
 

Hi John

You could control the output of ISO or ANSI icons via the map. I use this technique in my PDF plugin to control for instance the layout (A4/US).

First you need to define a variable in roots-processing.xsl of your plugin:
   <xsl:variable name="ansi" select="(/*/opentopic:map/*[contains(@class, ' map/topicmeta ')]//*[contains(@class, ' topic/othermeta ')][@name='ansi']/@content)[1]"/>

In the Oxygen PDF plugin, you find a template that replaces the note icons. Copy it to your commons.xsl or custom.xsl and modify it to resemble something like this (other note types excluded for the sake of simplicity):
    <!-- Custom Oxygen note images for PDF -->
    <xsl:template match="*[contains(@class,' topic/note ')]" mode="setNoteImagePath">
        <xsl:variable name="noteType" as="xs:string">
            <xsl:choose>
                <xsl:when test="@type">
                    <xsl:value-of select="@type"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="'note'"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:choose>
            <xsl:when test="$ansi='yes'">
                <xsl:choose>
                    <xsl:when test="$noteType = 'caution'">Customization/OpenTopic/common/artwork/important-ansi.png</xsl:when>
                    <xsl:when test="$noteType = 'danger'">Customization/OpenTopic/common/artwork/danger-ansi.png</xsl:when>
                    <xsl:when test="$noteType = 'warning'">Customization/OpenTopic/common/artwork/warning-ansi.png</xsl:when>
                    <xsl:otherwise>
                        <xsl:call-template name="getVariable">
                            <xsl:with-param name="id" select="concat($noteType, ' Note Image Path')"/>
                        </xsl:call-template>
                    </xsl:otherwise>
                </xsl:choose>           
            </xsl:when>
            <xsl:otherwise>
                <xsl:choose>
                    <xsl:when test="$noteType = 'caution'">Customization/OpenTopic/common/artwork/important-iso.png</xsl:when>
                    <xsl:when test="$noteType = 'danger'">Customization/OpenTopic/common/artwork/danger-iso.png</xsl:when>
                    <xsl:when test="$noteType = 'warning'">Customization/OpenTopic/common/artwork/warning-iso.png</xsl:when>
                    <xsl:otherwise>
                        <xsl:call-template name="getVariable">
                            <xsl:with-param name="id" select="concat($noteType, ' Note Image Path')"/>
                        </xsl:call-template>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:otherwise>       
        </xsl:choose>
    </xsl:template>

Make sure to copy all your icons to cfg\common\artwork of your plugin (they are probably already there).

In your map, add an <othermeta> element like this (if using a bookmap):
   <bookmeta>
      <othermeta name="ansi" content="yes"/>
   </bookmeta>

Now publish your map with this "switch" enabled and all icons should render in the ANSI style. If you don't set the variable, the ISO icons are taken.


Try it!

Chris.


Join main@dita-users.groups.io to automatically receive all group messages.