如何在 Dita OTs custom.xsl 中按属性 select

How to select by attribute in Dita OTs custom.xsl

我的目标是更改包含在属性和值为 <li audience="beginner"></li> 的元素中的任何文本的字体颜色。我目前希望在 Dita Open Toolkits PDF 插件的 custom.xsl 文件中执行此操作。 custom.xsl 将覆盖 common.xsl 中的所有样式。我的问题是如何 select by attribute-set 标签中的属性?

Custom.xsl

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
    version="2.0">
    <xsl:attribute-set name="li">
        <xsl:attribute name="color">red</xsl:attribute>
    </xsl:attribute-set>
</xsl:stylesheet>

XML

<li audience="beginner" class="- topic/li ">This text should be blue</li>
<li audience="expert" class="- topic/li ">This text should be red</li>

旧约的选择标准类似于:

    ...
    <xsl:template match="*[contains(@class,' topic/li ')]">
        <xsl:attribute name="color">
        <xsl:choose>
            <xsl:when test="@audience="beginner">blue</xsl:when>
            <xsl:when test="@audience="expert">red</xsl:when>
            <xsl:otherwise>black</xsl:otherwise>
        </xsl:choose>
        </xsl:attribute>
    ... (anything else you want to do with li)
    </xsl:template>
    ...

希望对您有所帮助。