2012-04-12 48 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。你的例子適用於改變。