'How are XML namespaces validated on W3C's validator?

I have two files:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   width="210mm"
   height="297mm"
   viewBox="0 0 210 297"
   version="1.1"
   id="svg5"   
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   inkscape:version="1.1.1 (c3084ef, 2021-09-22)"
   xmlns="http://www.w3.org/2000/svg">
</svg>

This one validates fine on W3C validator. But once I edit the namespace, i.e. URI in xmlns:inkscape it starts to fail:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   width="210mm"
   height="297mm"
   viewBox="0 0 210 297"
   version="1.1"
   id="svg5"   
   xmlns:inkscape="http://www.inkscape.org/namespaces/ABC"
   inkscape:version="1.1.1 (c3084ef, 2021-09-22)"
   xmlns="http://www.w3.org/2000/svg">
</svg>

It gives me this error:

Line 10, Column 38: Attribute version from namespace http://www.inkscape.org/namespaces/ABC not allowed on SVG element svg at this point.

I use https://validator.w3.org/ for validating it. I have to upload these as .svg files. I can not paste it into direct input, as it doesn't detect the format and there is no such selection in the manual choice (SVG 1.1 + URL + HTML + MathML 3.0 is detected in file upload).

What kind of black magic is going on here? I thought those URIs are pretty free-form, but it looks like W3C validator pulls some sort of schema from somewhere even if nothing is specified.

I also noticed that I can rename the namespace to something else and it all works as long as I keep the same URI.

How does validation of namespaces work? I'm just trying to add my custom namespace to my SVG files...



Solution 1:[1]

The "magic" can be found by looking at the sources:

  1. All files that do not have a DOCTYPE declaration, and all files that have a .svg extension are checked by delegation to the Nu Html Checker:

    # we send doctypeless SVG, or any doctypeless XML document with multiple
    # namespaces found, to a different engine. WARNING this is experimental.
    
  2. As you found, this validator identifies the file as SVG 1.1 + URL + HTML + MathML 3.0. These files are checked via a Relax NG scheme called svg-xhtml5-rdf-mathml.rnc. And that file explicitely checks against the inkscape namespace.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ccprog