What are the different xsi:noNamespaceSchemaLocation in Magento 2 and when to use them?
-
04-10-2020 - |
Question
Looking through Magento 2 di.xml
files there are various types of xsi:noNamespaceSchemaLocation
When should we be using each schema?
Solution
It depends on the type of XML file you create.
Basically, all the XSD files can be found under the lib/internal/Magento/Framework
folder, here is the list on 2.1.2:
For example, if you create a etc/acl.xml
in your module, you'll have to use the acl.xsd
file.
There are a few details about it in the official documentation:
- http://devdocs.magento.com/guides/v2.1/extension-dev-guide/build/XSD-XML-validation.html
- http://devdocs.magento.com/guides/v2.0/config-guide/config/config-create.html#config-files-validate
My personal practice is: when I want to create an XML file, I check the same type of file in the core and get the URN schema from it.
Also, you can create your own XSD in case you want to use a custom type of XML: How can we write an XSD file in Magento 2?
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange