2012-04-12 26 views
3

只有在满足某些条件的情况下,我才需要向来自主题的元素添加一个类。我试过this solution,调整重氮通过更换prependbeforeDiazo - 有条件地向主题元素添加一个类

<before css:theme=".main" if-content="not(//*[@id='portal-column-two'])"><xsl:attribute name="class"><xsl:value-of select="//*[@class='main']/@class"/> full</xsl:attribute></before> 

,但我得到了以下错误:

XSLTApplyError: xsl:attribute: Cannot add attributes to an element if children have been already added to the element. 

我得到这个错误,甚至当我删除所有其他规则,例如,有只有<theme>规则和<before>规则。

只有在内容中没有#portal-column-two元素时,如何才能将类添加到主题元素?

回答

2

prepend css:theme的重氮替换是before css:theme-children而不是before css:theme。你的例子适用于改变。