Change rules.xml

Hi community

I am not so familiar with coding and programming and maybe this is a duplicate post.

I try to change me rules.xml but end up with an error.

"ERROR: Multiple unconditional replace rules may not match a single theme node."

my rules.xml:

<?xml version="1.0" encoding="UTF-8"?>
<rules
    xmlns="http://namespaces.plone.org/diazo"
    xmlns:css="http://namespaces.plone.org/diazo/css"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xi="http://www.w3.org/2001/XInclude">

 
  <!-- Import Barceloneta rules -->
  <xi:include href="++theme++barceloneta/rules.xml" />


  <rules css:if-content="#visual-portal-wrapper">
    <!-- Placeholder for your own additional rules -->
    
  
  </rules>
  
</rules>

and I'll get the error when I try to add this lines:

 <replace css:theme="#content-container" method="raw">
    <xsl:variable name="central">
      
      <xsl:if test="//aside[@id='portal-column-one'] and //aside[@id='portal-column-two']">col-xs-12 col-sm-12 col-md-6 col-md-push-0</xsl:if>
      <xsl:if test="//aside[@id='portal-column-two'] and not(//aside[@id='portal-column-one'])">col-xs-12 col-sm-12 col-md-9</xsl:if>
      <xsl:if test="//aside[@id='portal-column-one'] and not(//aside[@id='portal-column-two'])">col-xs-12 col-sm-12 col-md-9 col-md-push-0</xsl:if>
      <xsl:if test="not(//aside[@id='portal-column-one']) and not(//aside[@id='portal-column-two'])">col-xs-12 col-sm-12 col-md-12</xsl:if>

    </xsl:variable>
 </replace>

How to make this change to work.

best regards
Manfred

It's not clear what the purpose of your code is. As far as I know, you can not use a variable element in the way you are attempting.

Regardless: a good place to start when experimenting with Diazo is to read the Diazo Theme Engine Guide and to follow the Advanced Diazo Training.

Hi Norbert

Through the "<xi:include href="++theme++barceloneta/rules.xml" />" i import

  <!-- Central column -->
  <replace css:theme="#content-container" method="raw">

    <xsl:variable name="central">

      <xsl:if test="//aside[@id='portal-column-one'] and //aside[@id='portal-column-two']">col-xs-12 col-sm-12 col-md-6 col-md-push-3</xsl:if>
      <xsl:if test="//aside[@id='portal-column-two'] and not(//aside[@id='portal-column-one'])">col-xs-12 col-sm-12 col-md-9</xsl:if>
      <xsl:if test="//aside[@id='portal-column-one'] and not(//aside[@id='portal-column-two'])">col-xs-12 col-sm-12 col-md-9 col-md-push-3</xsl:if>
      <xsl:if test="not(//aside[@id='portal-column-one']) and not(//aside[@id='portal-column-two'])">col-xs-12 col-sm-12 col-md-12</xsl:if>
    </xsl:variable>

This i need to change to

  <xsl:if test="//aside[@id='portal-column-one'] and //aside[@id='portal-column-two']">col-xs-12 col-sm-12 col-md-6 col-md-push-0</xsl:if>
  <xsl:if test="//aside[@id='portal-column-two'] and not(//aside[@id='portal-column-one'])">col-xs-12 col-sm-12 col-md-9</xsl:if>
  <xsl:if test="//aside[@id='portal-column-one'] and not(//aside[@id='portal-column-two'])">col-xs-12 col-sm-12 col-md-9 col-md-push-0</xsl:if>
  <xsl:if test="not(//aside[@id='portal-column-one']) and not(//aside[@id='portal-column-two'])">col-xs-12 col-sm-12 col-md-12</xsl:if>

maybe its clearer now.

best regards
Manfred

Gotcha, I overlooked your include. What happens is that the replace is applied twice. Once from your imported rules.xml and again in your modifications below.

Start from a copy of the default barceloneta theme and make your modifications directly in your copy of rules.xml.

Hi Norbert

If i copy the barceloneta rules, i have to copy it every time the barceloneta changed his version, to stay up to date, is there no other way to replace the replacement?

When I developed a theme for a client, I tried and failed leaving the following comment:

<!-- this is a copy of `barceloneta`'s `rules.xml`. We would like to inherit instead (as
documented in the `barceloneta` documentation) but this fails because some `xsl-variable` are
then ineffective (likely a `diazo` bug) -->

Thus, according to the documentation, it should be possible but at the time of my trial (for Plone 5.2.0), it did not work as promised.

Looks like you are correct, see this issue on github:

Edit/add: maybe not clear from my original answer, you can use rules.xml as an include but it means you can not apply a second unconditional replace like you tried to do. Your rules must be specific, and will complement the included rules.

ok I changed my rules.xml a bit and now its working

   <!-- Central column -->
  <rules css:if-content="#portal-column-one">
  <replace css:theme="#content-container" >

    <xsl:variable name="central">
      <xsl:if test="//aside[@id='portal-column-one'] and //aside[@id='portal-column-two']">col-xs-12 col-sm-12 col-md-6 col-md-push-0</xsl:if>
      <xsl:if test="//aside[@id='portal-column-two'] and not(//aside[@id='portal-column-one'])">col-xs-12 col-sm-12 col-md-9</xsl:if>
      <xsl:if test="//aside[@id='portal-column-one'] and not(//aside[@id='portal-column-two'])">col-xs-12 col-sm-12 col-md-9 col-md-push-0</xsl:if>
      <xsl:if test="not(//aside[@id='portal-column-one']) and not(//aside[@id='portal-column-two'])">col-xs-12 col-sm-12 col-md-12</xsl:if>
    </xsl:variable>

    <div class="{$central}">
      <div class="row">
        <div class="col-xs-12 col-sm-12">
          <xsl:apply-templates css:select="#content" />
        </div>
      </div>
      <footer class="row">
        <div class="col-xs-12 col-sm-12">
          <xsl:copy-of css:select="#viewlet-below-content" />
        </div>
      </footer>
    </div>
  </replace>
  </rules>

  <!-- Import Barceloneta rules -->
  <xi:include href="++theme++barceloneta/rules.xml" />

Thanks for your help and inputs.

best regards
Manfred

1 Like