3
只有在滿足某些條件的情況下,我才需要向來自主題的元素添加一個類。我試過this solution,調整重氮通過更換prepend
與before
:Diazo - 有條件地向主題元素添加一個類
<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
元素時,如何才能將類添加到主題元素?