Topics

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

John Piechowski
 

We write manuals using ANSI icons and ISO icons. In many cases, our warning messages are the same except for icons.

Today, we use outputclass='iso' and modified DITA-OT to outputput the correct alert symbol (the exclamation triangle output by in the <note> tag.

<note outputclass="iso" type="warning" id="xxx">

Now we are trying to combine our ANSI and ISO warnings to eliminate duplication. Doing this means that outputclass no longer will work to select safety alert symbol.

We can use DITAVAL to output the correct specific hazard icon, but I am interested in feedback on the best way to handle the safety alert symbol.

I am thinking that we could use the same DITAVAL filter and hardcode in XSL to select the correct ANSI or ISO.
Something like:
<note ansiiso="iso" type="warning" id="xxx">

Then @ansiiso custom filter would select the correct image.

But I don't know if a solution that hardcodes a custom filter in XSL is really the best solution.

Is anyone else using the same warning text with both ANSI and ISO icons? If so, how are you solving this?

Larry Kollar
 

If you can use DITAVAL for the hazard icon, why wouldn't that work for the safety alert symbol as well?

As long as you don't have to mix ANSI and ISO in the same book, you could put the right image in a key file and use conkeyref to insert it.

John Piechowski
 

Because the safety alert symbol is generated by the note tag and not part of content in the topic.

<Note type='warning'>

Automatically renders the exclamation and 'warning' text in standard Dita. Seemed to make sense not to do warnings completely outside the note tag.



On Mon, Feb 10, 2020, 11:06 AM <lkollar@...> wrote:
If you can use DITAVAL for the hazard icon, why wouldn't that work for the safety alert symbol as well?

As long as you don't have to mix ANSI and ISO in the same book, you could put the right image in a key file and use conkeyref to insert it.

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.


John Piechowski
 

Thanks. Exactly what I was looking for.

Appreciate it.
John

On Wed, Feb 19, 2020 at 7:28 AM Chris Brand via Groups.Io <chrizzbee74=yahoo.com@groups.io> wrote:
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.