I see that in Magento 2 all the xml (config, system, layout files, ...) files have a xsd associated for validation. This seams nice. Now you know what you are allowed to put in each file.

But I see that there are 2 validation schemas for each type of file.
Let's take system.xml for example.
The schema used inside the files is app/code/Magento/Backend/etc/system_file.xsd but there is also app/code/Magento/Backend/etc/system.xsd
I found a reference to system.xsd in Magento\Backend\Model\Config\SchemaLocator and it is declared as _schema and system_file.xsd is called _perFileSchema.

The difference between the 2 files are minor.
Just some label differences and on one tag there is a minoccurs="1" while on the other is minoccurs="0"

When is the _schema file used? In this example system.xsd.

1 Answer 1


Schema is for validation of merged configuration (configuration taken from xml files of all modules)

Per file schema is for validation of separate xml files.

The reason for this separation is that there are situations when constraints for each separate file are softer than for merged configuration. This might happen because merged configuration should be totally valid and ready for use by application while separate xml file is allowed to provide only part of required nodes/attributes that will only make sense when merged with all other config files so per-file schema should allow for this.

  • You can't imagine how lucky I feel having you answering magento 2 questions here. It all makes sense to me now. Thanks. I'm writing my first config loader now for educational purposes. Now I have all the data I need. One more side question. Depending on how the config file looks like, it's possible to use the same schema file for single files and the merged config, right?
    – Marius
    Sep 4, 2014 at 12:02
  • Yes. Most config types in Magento have only one schema.
    – Anton Kril
    Sep 4, 2014 at 16:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.