|  | Stylesheet |
<xsl:stylesheet version="1.0">
<xsl:key name="acronym" match="//c:acronym" use="@id"/>
<xsl:template match="c:acro">
<xsl:choose>
<xsl:when test="$acromode = 'html'">
<xsl:call-template name="acro-html"/>
</xsl:when>
<xsl:when test="$acromode = 'TeX'">
<xsl:call-template name="acro-TeX"/>
</xsl:when>
<xsl:when test="$acromode = 'text'">
<xsl:call-template name="acro-text"/>
</xsl:when>
<xsl:otherwise>
<xsl:message> Error: $acromode must be one of "html" or "TeX" or "text". </xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="acro-text" match="c:acro" mode="text">
<xsl:variable name="id"><xsl:value-of select="."/></xsl:variable>
<xsl:for-each select="$acronymlist">
<xsl:variable name="acro" select="key('acronym', $id)"/>
<xsl:choose>
<xsl:when test="$acro">
<xsl:value-of select="$acro/c:text"/>
</xsl:when>
<xsl:otherwise>
<xsl:text><</xsl:text><xsl:value-of select="$id"/><xsl:text>></xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<xsl:template name="acro-TeX" match="c:acro" mode="TeX" priority="1">
<xsl:variable name="id"><xsl:value-of select="."/></xsl:variable>
<xsl:for-each select="$acronymlist">
<xsl:variable name="acro" select="key('acronym', $id)"/>
<xsl:choose>
<xsl:when test="$acro">
<xsl:apply-templates select="$acro/c:TeX" mode="TeX"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>{{</xsl:text><xsl:value-of select="$id"/><xsl:text>}}</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<xsl:template name="acro-html" match="c:acro" mode="html" priority="1">
<xsl:variable name="id"><xsl:value-of select="."/></xsl:variable>
<xsl:for-each select="$acronymlist">
<xsl:variable name="acro" select="key('acronym', $id)"/>
<xsl:choose>
<xsl:when test="$acro">
<xsl:apply-templates select="$acro/c:html" mode="html"/>
</xsl:when>
<xsl:otherwise>
<font color="red"><u><xsl:value-of select="$id"/></u></font>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<xsl:template match="c:acronym/c:html//*" mode="html" priority="0.5">
<xsl:copy>
<xsl:apply-templates select="@*" mode="html"/>
<xsl:apply-templates mode="html"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*" mode="html">
<xsl:copy/>
</xsl:template>
<xsl:template match="text()" mode="html">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="text()" mode="TeX">
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet> acro.xsl |