Diazo - Conditionally add a class to a theme element

萝らか妹 提交于 2019-12-10 10:20:25

问题


I need to add a class to an element coming from the theme only if certain conditions are met. I've tried this solution, adjusted for Diazo by replacing prepend with 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>

but I get the following error:

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

I get that error even when I remove all other rules such that there is only the <theme> rule and the <before> rule.

How can I add a class to a theme element only when there is no #portal-column-two element in the content?


回答1:


The Diazo replacement for prepend css:theme is before css:theme-children, not before css:theme. Your example works with that changed.



来源:https://stackoverflow.com/questions/10131092/diazo-conditionally-add-a-class-to-a-theme-element

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!