Diazo theme output changed after upgrading Plone 4.3.7 site

If you upgrade your Plone site from 4.3.7 to any newer version and you have reasonably complex diazo rules, please double test your theme before going into production. It might not be a 100% safe replacement and if you spot weird changes, put Diazo on the verify list.

We have built a number of sites with Bootstrap where we use Diazo to complement the deco-grid classes with bootstrap equivalents using some inline xslt. After upgrading from 4.3.7 some of these bootstrap grid classes were suddenly missing.

After a long drill down search we found out with diazocompiler that Diazo is producing different results for the same rules.xml between diazo 1.0.6 and 1.1.3. (Plone 4.3.7 -> Plone 4.3.8). In our case the two rules below were causing the problem. Rule 2 was suddenly disabling all application of rule 1. Switching their position solved the problem for us. YMMV. I'm not claiming this is correct usage of inline xslt, but it used to work and it suddenly breaks.

<replace content="//*[contains(@class, 'width-1:4')]">
  <xsl:copy>
    <xsl:copy-of select="@id" />
    <xsl:attribute name="class"><xsl:value-of select="@class" /> col-md-4</xsl:attribute>
    <xsl:apply-templates />
  </xsl:copy>
</replace>

<replace content="//*[contains(@class, 'width-1:4') or contains(@class, 'width-1:2') or contains(@class, 'width-3:4')]"
  if-content="/html/body[contains(@class,'portaltype-collective-cover-content')]">
  <xsl:copy>
    <xsl:copy-of select="@id" />
    <xsl:attribute name="class"><xsl:value-of select="@class" /> col-md-12</xsl:attribute>
    <xsl:apply-templates />
  </xsl:copy>
</replace>

With my limited/zero knowledge of the Diazo xslt macros and transformations the changed output doesn't seem to make any sense. If a Diazo/xslt guru is interested in the debug output, contact me. What gets inserted in the xslt is this part:

<xsl:template match="//*[contains(@class, 'width-1:4') or contains(@class, 'width-1:2') or contains(@class, 'width-3:4')]">
    <xsl:apply-templates select="." mode="before-content"/>
    <xsl:apply-templates select="." mode="replace-content"/>
    <xsl:apply-templates select="." mode="after-content"/>
</xsl:template>
1 Like

we had problems with diazo when updating some sites from 4.3.7 to 4.3.9, too.

as a workaround we pinned diazo to 1.0.6

Unexpected error whilst trying to apply transform chain
Traceback (most recent call last):
  File "/home/zope/project/eggs/plone.transformchain-1.1.0-py2.7.egg/plone/transformchain/transformer.py", line 43, in __call__
    newResult = handler.transformIterable(result, encoding)
  File "/home/zope/project/eggs/plone.app.theming-1.1.7-py2.7.egg/plone/app/theming/transform.py", line 181, in transformIterable
    transformed = transform(result.tree, **params)
  File "xslt.pxi", line 567, in lxml.etree.XSLT.__call__ (src/lxml/lxml.etree.c:124426)
XSLTApplyError: xsl:attribute: Cannot add attributes to an element if children have been already added to the element.

we did not yet find the time to investigate this further but a few days after the 4.3.9 release i stumbled upon this issue https://github.com/plone/diazo/issues/54#issuecomment-212261426 which might help you solve your problem too.

1 Like

I ran into this as well and needed to pin to 1.0.6