试图在XSLT中匹配多个类

时间:2011-02-24 16:34:52

标签: xslt xpath xsl-fo

我对XSLT很新,并试图为pdf格式化一些文本,我需要匹配并隐藏一些元素。

我目前正在使用:

<xsl:template match="*[@outputclass='LC ACaseName']">

匹配:

<p outputclass="LC ACaseName"> 

它工作得很好。

我现在需要做的是匹配4或5个

  

<p outputclass="<somestring>">

并对它们应用相同的样式。我可以轻松地复制上面的行,每次都替换不同的输出类名称,但这很懒,我知道必须有一个正确的方法来做这个,我应该学习。

我希望我在这里提供了足够的信息。如果我错过了什么,请说。

感谢,

Hedley Phillips

2 个答案:

答案 0 :(得分:3)

您可以在谓词中指定多个条件:

<xsl:template match="*[@outputclass='test' or @outputclass='blah']">

答案 1 :(得分:2)

我找不到重复的内容......

在XSLT / XPath 1.0中:

<xsl:template match="*[contains(
                          '|LC ACaseName|other class|',
                          concat('|',@outputclass,'|')
                       )
                     ]"> 
    <!-- Content Template --> 
<xsl:template> 

在XSLT / XPath 2.0中:

<xsl:template match="*[@outputclass = ('LC ACaseName','other class')]"> 
    <!-- Content Template --> 
<xsl:template> 

注意:对于XSLT / XPath 1.0解决方案,您需要一个不属于任何项目内容的分隔符。

相关问题