In magento2 you can validate your xml files against its corresponding schema definition.

In magento1 we had

1
2
3
4
<?xml version="1.0"?>
<config>
    ....
</config>

In magento2 this becomes:

1
2
3
4
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    ....
</config>

The extra information provided there specifies the schema instance used and the URN to the corresponding xsd file. In our case we point out that our xml must follow the rules presented in the file: vendor/magento/framework/Module/etc/module.xsd. The URN is a type of URI that is location-independent (unlike the URL).

Remember the days when your module didn’t work and you had to look for hours through xmls to find the typo? Those days should be over now because IDEs (like PhpStorm) can validate instantly your xml against the specified xsd.

All you have to do is run php bin/magento dev:urn-catalog:generate .idea/misc.xml and then if you reopen your IDE you can validate your xmls.

In PhpStorm look for an exclamation mark or a green validation mark in the top right corner. Also you can go to PhpStorm > Preferences > Languages & Frameworks > Schemas and DTDs and see all current URN resolutions.

Most common used:

1
2
3
4
for module declaration: <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
for routers: <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
for layouts: <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
for DI: <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">