In Magento 2, some layout handle XML files open with the
<page.../>
root tag. Others open with the
<layout.../>
root tag. Does using either of the above tags introduce any functionality differences to a layout handle XML file? Or is this pure window dressing? Or something in between.
Two examples
<!-- File: vendor/magento/module-weee/view/frontend/layout/default.xml -->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
and
<!-- File: vendor/magento/module-widget/view/adminhtml/layout/adminhtml_widget_loadoptions.xml -->
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
Best Answer
These matters due to a different XSD configurations. The
declaration says that we want to use layout with XSD definition provided in the
In the
layout_generic.xsd
file it provides definition forlayout
node withgenericLayout
element type.Having that, the layout file has been validated by the XSD when xml is loaded. In addition to this it highlights all possible nodes and node attributes in the layout.xml file.
Same with
page_configuration.xsd
definition for<page />
node. This XSD describes nodes which can be used to describe page.Hope it helps.