xml-lint icon indicating copy to clipboard operation
xml-lint copied to clipboard

feat(validation): gets schema also from xsi:schemaLocation

Open judzi opened this issue 1 year ago • 0 comments

Changes Made:

Previously, the code logic was designed to extract a single schema location from the xsi:noNamespaceSchemaLocation attribute. Now, it also handles extraction from the xsi:schemaLocation attribute.

Example:

Consider the following example of a Symfony routing XML configuration file (https://symfony.com/doc/current/routing.html#creating-routes-in-yaml-xml-or-php-files):

<?xml version="1.0" encoding="UTF-8"?>
<routes xmlns="http://symfony.com/schema/routing"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://symfony.com/schema/routing
                            https://symfony.com/schema/routing/routing-1.0.xsd"
>
    <route id="blog_show" path="/blog/{slug}" controller="BlogController::show">
        <default key="_controller">App\Controller\BlogController::show</default>
    </route>
    
    <route id="blog_list" path="/blog" controller="BlogController::list">
        <default key="_controller">App\Controller\BlogController::list</default>
    </route>
</routes>

In this example, the xsi:schemaLocation attribute is utilized within a Symfony XML configuration file for defining the schema to validate the structure and content of this specific XML file against the corresponding schema definition (https://symfony.com/schema/routing/routing-1.0.xsd).

This enhancement ensures compatibility with XML files following a similar structure, allowing the code to handle schema locations specified within the xsi:schemaLocation attribute.

judzi avatar Dec 11 '23 15:12 judzi