xslt - Diazo - 有条件地向主题元素添加类

标签 xslt diazo

仅当满足特定条件时,我才需要向来自主题的元素添加一个类。我试过了 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/

相关文章:

xml - 获取节点总数和计数节点

xml - XSLT 模板不适用于所有使用 lxml 的元素

plone - xsl :attributes strips the "content"

plone - 使用带有 notheme 的 diazo 将类添加到 body 标签

plone - 如何将 portlet 移动到内容的#content 区域?

xml - 如何在 XSLT 中正确分支?

xml - 获取不同层中的所有 <PRO>-标签

css - 包含样式表时导致错误的 XSL 文件

css - 从特定容器中排除主题

plone - Diazo:css:if-content 和 css:if-not-content 都匹配