SVG validity checks

From Meta, a Wikimedia project coordination wiki

Out of 2871 randomly-selected SVG files from Commons, 13 (about 0.5%) failed to pass a basic XML well-formedness check. From this sample we might expect about 600-800 invalid files total.

Following are the failed images from my sample set, broken down by type of error. --brion 01:08, 6 February 2008 (UTC)Reply[reply]

Bad element nesting[edit]

This is a blatant well-formedness error. No SVG renderer likes these files, and they don't work on the site as is.

Bad character encoding[edit]

Text in this file is ISO-8859-1, but since there's no XML header declaring this, a conforming XML parser must assume it's UTF-8 and should barf when coming to the non-ASCII bits.

Amusingly, Firefox does render this file, while rsvg doesn't.

Unbound namespace: xlink[edit]

The next couple sections are files which fail to declare all the namespaces used in the document. Possibly these come from bad exporters, or from uncareful manual editing of generated files.

rsvg currently renders these files for you on Wikimedia, but Firefox won't take them if you try to view them inline. I'd consider it reasonable to start rejecting these... but at least some of them would be easy to fix automatically on upload with some sort of lint check.

The xlink namespace is used for links, including internal references within an SVG document, and really ought to be declared when used. :)

Unbound namespace: sodipodi[edit]

Used for various metadata by the SVG editors sodipodi and Inkscape.

Unbound namespace: RDF[edit]

General metadata in some files...

Unbound namespace: ns[edit]

Not too sure what this one's for. Some sort of editing metadata, looks like.