我可以根据需要处理两个表达式:
<xsl:if test="string-length(.) > 15">
<xsl:if test="not(contains(., ' '))">
<xsl:attribute name="font-size">5pt</xsl:attribute>
</xsl:if>
</xsl:if>
但是我不清楚为什么我不能只写成一个test
:
<xsl:if test="string-length(.) > 15 && not(contains(., ' '))">
<xsl:attribute name="font-size">5pt</xsl:attribute>
</xsl:if>
这会引发处理器(Apache XSL FO)的未知错误。
我正在测试当前所在的节点,以查看它是否包含15个以上的字符且没有空格。如果满足该匹配条件,则将字体大小减小为5pt
。
答案 0 :(得分:1)
XSLT中使用的表达语言是XPath,在XSLT 2.0中则是XPath 2.0。布尔值and
仅具有英文名称,因此您只需要string-length(.) > 15 and not(contains(., ' '))
。