Magento – Magento 2 DOM validation exception when in developer mode

layouttemplateultimovalidationxml

I'm running Magento 2.2.1 and Infortis Ultimo 2.5.1. When I'm in developer mode and I attempt to access a product page on the front end, I get the exception.

Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'referenceContainer', attribute 'htmlTag': [facet 'enumeration'] The value '' is not an element of the set {'aside', 'dd', 'div', 'dl', 'fieldset', 'main', 'nav', 'header', 'footer', 'ol', 'p', 'section', 'table', 'tfoot', 'ul'}.
Line: 1159

Element 'referenceContainer', attribute 'htmlTag': '' is not a valid value of the atomic type 'htmlTagType'.
Line: 1159

Element 'referenceContainer', attribute 'htmlClass': [facet 'pattern'] The value '' is not accepted by the pattern '[a-zA-Z][a-zA-Z\d-_](\s[a-zA-Z][a-zA-Z\d-_])*'.
Line: 1159

This is because the htmlTag and htmlClass attributes in app/design/frontend/Infortis/base/Magento_Catalog/layout/catalog_product_view.xml are not being set.

<!-- Reset attributes of main containers -->
<referenceContainer name="product.info.main" htmlTag="" htmlClass="" before="-" />
<referenceContainer name="product.info.media" htmlTag="" htmlClass="" after="product.info.main" />

When switching to production mode the page renders correctly as expected with no errors. I've tried running the following commands:

php -d memory_limit=512M bin/magento cache:clean
php -d memory_limit=512M bin/magento cache:flush
php -d memory_limit=512M bin/magento setup:upgrade
php -d memory_limit=512M bin/magento setup:di:compile
php -d memory_limit=512M bin/magento indexer:reindex

Error is still appearing when in developer mode as described above.

Best Answer

The problem you are facing is due to use of htmlTag, htmlClass for referenceContainer. You must write as follows:

<!-- Reset attributes of main containers -->
<referenceContainer name="product.info.main"  />
<referenceContainer name="product.info.media" />

Please try without those html tags as you will not be needing them in referenceContainers. You can put those for containers and blocks.

Related Topic