cancel
Showing results for 
Search instead for 
Did you mean: 

XSD regex override

SOLVED

XSD regex override

Hi, 

We are using a theme framework that allows an '@' in html classes. Magento aparanty does not like this accoring to the file below: 

filename: vendor/magento/framework/View/Layout/etc/elements.xsd

<xs:simpleType name="htmlClassType">
        <xs:restriction base="xs:string">
<!--            <xs:pattern value="[a-zA-Z@][a-zA-Z@\d\-_]*(\s[a-zA-Z@][a-zA-Z@\d\-_]*)*"/>-->
            <xs:pattern value="[a-zA-Z][a-zA-Z\d\-_]*(\s[a-zA-Z][a-zA-Z\d\-_]*)*"/>
        </xs:restriction>
    </xs:simpleType>

When i change to pattern it works fine, but is there any way to only change this XSD element without overriding the whole file?

Or is it possible the '@' can be added to the framework?

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions

Re: XSD regex override

Hi @willemoostelbos , considering that path to the xsd schema is hardcoded in `\Magento\Framework\View\Model\Layout\Update\Validator` I think the only way to customize schema validation, in this case, is to add custom validator as a DI preference for the `\Magento\Framework\View\Model\Layout\Update\Validator` class.

 

I think it's worth opening a pull request to https://github.com/magento/magento2 to propose more flexible validation for htmlClasses.

View solution in original post

1 REPLY 1

Re: XSD regex override

Hi @willemoostelbos , considering that path to the xsd schema is hardcoded in `\Magento\Framework\View\Model\Layout\Update\Validator` I think the only way to customize schema validation, in this case, is to add custom validator as a DI preference for the `\Magento\Framework\View\Model\Layout\Update\Validator` class.

 

I think it's worth opening a pull request to https://github.com/magento/magento2 to propose more flexible validation for htmlClasses.