0

我的目标是更改包含在具有属性和值的元素中的任何文本的字体颜色<li audience="beginner"></li>。我目前正在寻找在 Dita Open Toolkits PDF 插件的 custom.xsl 文件中执行此操作。custom.xsl 将覆盖 common.xsl 中的任何样式。我的问题是如何在属性集标签中按属性选择?

自定义.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>
4

1 回答 1

0

OT 的选择标准类似于:

    ...
    <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>
    ...

希望这可以帮助。

于 2016-12-12T12:28:14.067 回答