Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validating Magento 2 XML files #17

Closed
churiart opened this issue Dec 13, 2018 · 5 comments
Closed

Validating Magento 2 XML files #17

churiart opened this issue Dec 13, 2018 · 5 comments

Comments

@churiart
Copy link

churiart commented Dec 13, 2018

I'm trying to make Exalt to work with Magento 2 xml files for validation. Its xml files could start with e.g.:

<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">

and that urn points to schema.xsd file in (starting from root directory):

ROOT/vendor/Magento/framework/Setup/Declaration/Schema/etc/schema.xsd

I have generated a catalog file named misc.xml with the built in Magento command which contains:

<?xml version="1.0"?>
<project version="4">
  <component version="2" name="ProjectRootManager"/>
  <component name="ProjectResources">
    <resource url="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd" location="D:/path/to/Magento/vendor/magento/framework/Setup/Declaration/Schema/etc/schema.xsd"/>
    <resource url="urn:magento:framework:ObjectManager/etc/config.xsd" location="D:/path/to/Magento/vendor/magento/framework/ObjectManager/etc/config.xsd"/>
.
.
.

and gave it to Exalt:

{
    "xml_catalog_files": [
        "D:/path/to/Magento/misc.xml"
    ]
}

But Exalt throws error on not finding urn (Failed to locate the main schema resource...). Is there anyway to configure Exalt to understand the file path?
Thanks

@eerohele
Copy link
Owner

Your misc.xml doesn't look like an OASIS XML catalog file, which is the only kind of catalog Exalt supports.

Can you try replacing misc.xml with an OASIS XML catalog? I think something like this should work:

<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE catalog
  PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN"
         "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
  <uri
    name="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd"
    uri="ROOT/vendor/Magento/framework/Setup/Declaration/Schema/etc/schema.xsd"/>
</catalog>

It's been a while since I've worked with this stuff, though, so you might need to fiddle with that a bit.

@churiart
Copy link
Author

churiart commented Dec 13, 2018

Thank you I got it working:

<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE catalog
  PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN"
         "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
    <uri name="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd" uri="file:///D:/path/to/installation/vendor/magento/framework/Setup/Declaration/Schema/etc/schema.xsd"/>
    <uri name="urn:magento:framework:ObjectManager/etc/config.xsd" uri="file:///D:/path/to/instllation/vendor/magento/framework/ObjectManager/etc/config.xsd"/>
    .
    .
    .
</catalog>

@eerohele
Copy link
Owner

By the way, I think you could also do something along these lines:

<rewriteURI uriStartString="urn:magento:framework:" rewritePrefix="file:///D:/path/to/installation/vendor/magento/framework/"/>

I didn't test, though.

@churiart
Copy link
Author

The exact same statement worked great and saved tens of kilobytes!
Thank you

@eerohele
Copy link
Owner

I'm nothing if not prudent when it comes to kilobytes.

Glad to hear it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants