仅当满足特定条件时,我才需要向来自主题的元素添加一个类。我试过了 this solution , 通过替换 prepend
调整 Diazo 与 before
:
<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
的情况下,如何才能将类添加到主题元素?内容中的元素?
最佳答案
prepend css:theme
的 Diazo 替换是 css:theme-children 之前
,而不是 css:theme 之前
。您的示例适用于更改后的内容。
关于xslt - Diazo - 有条件地向主题元素添加类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10131092/