我的目标是更改属性和值为<li audience="beginner"></li>
的元素中包含的任何文本的字体颜色。我目前希望在Dita Open Toolkits PDF插件的custom.xsl文件中执行此操作。 custom.xsl将覆盖common.xsl中的任何样式。我的问题是如何在属性集标签中按属性选择?
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>
答案 0 :(得分:0)
旧约的选择标准如下:
...
<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>
...
希望这有帮助。