CSTUG

Stylesheet

<xsl:stylesheet version="1.0">

<!-- This stylesheet expands keyword id. It should be imported into another stylesheet. The template expands the keyword to the language according to the kwdlang parameter. It first tries to find the keyword in the language specified (you can specify two languages), then in Czech and finally it takes the first available child node. If it expands anacronym, it works according to the value of the "acromode" variable (see acro.xsl) or you can explicitly use the template in the corresponding mode or call the template by name. The template for the TeX mode accepts parameters "prefix", "infix", and "suffix". The template outputs both the language and keyword as: concat($prefix, $language, $infix, $keyword, $suffix) If the "infix" is empty (i.e. left at the default value), only the keyword is output as: concat($prefix, $keyword, $suffix) Both the prefix and suffix may also be left empty. -->
<xsl:key name="keyword" match="//c:keyword" use="@id"/> <xsl:template match="c:keyword" name="c-keyword"> <xsl:param name="kwdid"> <xsl:value-of select="."/> </xsl:param> <xsl:param name="kwdlang">cze</xsl:param> <xsl:param name="kwdlang2"/> <xsl:for-each select="$keywordlist"> <xsl:variable name="kwd" select="key('keyword', $kwdid)"/> <xsl:choose> <xsl:when test="$kwd"> <xsl:choose> <xsl:when test="$kwd/child::node()[local-name()=$kwdlang]"> <xsl:apply-templates select="$kwd/child::node()[local-name()=$kwdlang]"/> </xsl:when> <xsl:when test="$kwd/child::node()[local-name()=$kwdlang2]"> <xsl:apply-templates select="$kwd/child::node()[local-name()=$kwdlang2]"/> </xsl:when> <xsl:when test="$kwd/c:cze"> <xsl:apply-templates select="$kwd/c:cze"/> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="$kwd/child::node()[1]"/> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <font color="red"><u><xsl:value-of select="$kwdid"/></u></font> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:template> <xsl:template match="c:keyword" name="c-keyword-html" mode="html"> <xsl:param name="kwdid"> <xsl:value-of select="."/> </xsl:param> <xsl:param name="kwdlang">cze</xsl:param> <xsl:param name="kwdlang2"/> <xsl:for-each select="$keywordlist"> <xsl:variable name="kwd" select="key('keyword', $kwdid)"/> <xsl:choose> <xsl:when test="$kwd"> <xsl:choose> <xsl:when test="$kwd/child::node()[local-name()=$kwdlang]"> <xsl:apply-templates select="$kwd/child::node()[local-name()=$kwdlang]" mode="html"/> </xsl:when> <xsl:when test="$kwd/child::node()[local-name()=$kwdlang2]"> <xsl:apply-templates select="$kwd/child::node()[local-name()=$kwdlang2]" mode="html"/> </xsl:when> <xsl:when test="$kwd/c:cze"> <xsl:apply-templates select="$kwd/c:cze" mode="html"/> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="$kwd/child::node()[1]" mode="html"/> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <font color="red"><u><xsl:value-of select="$kwdid"/></u></font> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:template> <xsl:template match="c:keyword" name="c-keyword-TeX" mode="TeX"> <xsl:param name="kwdid"> <xsl:value-of select="."/> </xsl:param> <xsl:param name="kwdlang">cze</xsl:param> <xsl:param name="kwdlang2"/> <xsl:param name="prefix"/> <xsl:param name="infix"/> <xsl:param name="suffix"/> <xsl:for-each select="$keywordlist"> <xsl:variable name="kwd" select="key('keyword', $kwdid)"/> <xsl:value-of select="$prefix"/> <xsl:choose> <xsl:when test="$kwd"> <xsl:choose> <xsl:when test="$kwd/child::node()[local-name()=$kwdlang]"> <xsl:if test="$infix != ''"> <xsl:value-of select="concat($kwdlang, $infix)"/> </xsl:if> <xsl:apply-templates select="$kwd/child::node()[local-name()=$kwdlang]" mode="TeX"/> </xsl:when> <xsl:when test="$kwd/child::node()[local-name()=$kwdlang2]"> <xsl:if test="$infix != ''"> <xsl:value-of select="concat($kwdlang2, $infix)"/> </xsl:if> <xsl:apply-templates select="$kwd/child::node()[local-name()=$kwdlang2]" mode="TeX"/> </xsl:when> <xsl:when test="$kwd/c:cze"> <xsl:if test="$infix != ''"> <xsl:value-of select="concat('cze', $infix)"/> </xsl:if> <xsl:apply-templates select="$kwd/c:cze" mode="TeX"/> </xsl:when> <xsl:otherwise> <xsl:if test="$infix != ''"> <xsl:value-of select="concat(local-name($kwd/child::node()[1]), $infix)"/> </xsl:if> <xsl:apply-templates select="$kwd/child::node()[1]" mode="TeX"/> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:value-of select="$kwdid"/> </xsl:otherwise> </xsl:choose> <xsl:value-of select="$suffix"/> </xsl:for-each> </xsl:template> <xsl:template match="c:keyword" name="c-keyword-text" mode="text"> <xsl:param name="kwdid"> <xsl:value-of select="."/> </xsl:param> <xsl:param name="kwdlang">cze</xsl:param> <xsl:param name="kwdlang2"/> <xsl:for-each select="$keywordlist"> <xsl:variable name="kwd" select="key('keyword', $kwdid)"/> <xsl:choose> <xsl:when test="$kwd"> <xsl:choose> <xsl:when test="$kwd/child::node()[local-name()=$kwdlang]"> <xsl:apply-templates select="$kwd/child::node()[local-name()=$kwdlang]" mode="text"/> </xsl:when> <xsl:when test="$kwd/child::node()[local-name()=$kwdlang2]"> <xsl:apply-templates select="$kwd/child::node()[local-name()=$kwdlang2]" mode="text"/> </xsl:when> <xsl:when test="$kwd/c:cze"> <xsl:apply-templates select="$kwd/c:cze" mode="text"/> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="$kwd/child::node()[1]" mode="text"/> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:value-of select="$kwdid"/> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:template> </xsl:stylesheet>

kwd.xsl