Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Eliminate XSD relative paths #1012
Currently XSD path references are file paths using ../../.. notation. This is not desirable. Relative paths impose physical file location constraints on your component, as well as for the component where the XML-schema resides. It denies flexibility of how you can deploy your component. There is also a separate plan to make it easier to locate modules in places other than under app/code (e.g. under 'vendor' as well), in which case the physical location of the XSD file cannot be guaranteed.
The plan is to move to absolute paths (possibly a URN) that the code knows how to resolve to a XSD on the file system. An approach based on just the filename (such as "layout.xsd") may also be possible.
Some have proposed it be a URL where the file is hosted publicly somewhere such as GitHub. This is not proposed. Instead it is proposed that developers are required to configure their development environment to map the XSD references to physical file locations.
Stage 1 of this work would be to propose a strategy friendly with the PHP code in developer mode using XSD files to validate XML files. This should be reviewed and signed off by the Magento team before implementation (to avoid wasted effort).
Stage 2 would be to implement the changes required.
For example, any module can introduce a new XSD for its own configuration that another module may then want to replace/extend. For example, one approach is to use something like urn:magento:xsd:Vendor:Module:v1.0:layout.xsd so the vendor/module name is in the path. Then the XSD reference is relative to the home directory of a module, wherever it is. The XML parsing library would need to be extended to map this form of schema reference to the actual filename of the XSD file.
Consideration should also be give to tools like PHP Storm and how easy it will be to configure them. Can PHP Storm import the equivalent of a SGML CATALOG file for mapping URIs to physical file locations?
internal ticket MAGETWO-33621 and related comment.
There is no perfect solution here. We could host but questions arise on versioning, support for community schemas and this creates unnecessary complexities at this time. We could change to a URN but then action is required for every XSD in PHPStorm. We would also need to add support for the URN based resolution for our static tests. The relative path works for code within the app/code and we suspect that is how development of an extension will typically start. This is when validation against the XSD is most critical. When an extension is hosted in a separate repo, versioned and published independently the relative path is a problem but the user can configure PHPStorm to map to the schema in the project and validation can occur. In light of these details, I recommend no action at this time.