Search code examples
svgxhtmlwikimedia

Draw.io SVGs to Wikimedia, how to overcome XHTML issue?


I was hoping to make SVG diagram with Draw.io, and upload it to Wikimedia, so it could be used on Wikipedia.

However, Draw.io's svg uses XHTML and Wikimedia has banned XHTML for security concerns. Which means I would have to somehow convert XHTML to HTML5. However, I manually tried adjusting it, which allowed it to pass but Wikimedia's upload corrupted, so the svg is empty.

So, is there a way around it? I would like to believe vector softs like Inkscape would support such conversion, but I'm just not seeing it.

Example of the Draw.io SVG

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" style="background-color: rgb(255, 255, 255);" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="1491px" height="1901px" viewBox="-0.5 -0.5 1491 1901"><defs/>
<rect fill="#ffffff" width="100%" height="100%" x="0" y="0"/><g><g data-cell-id="0"><g data-cell-id="1"><g data-cell-id="lHPyWN3xTS5u2yIX5tx5-5"><g><path d="M 610 60 L 610 80 L 460 80 L 460 93.63" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 460 98.88 L 456.5 91.88 L 460 93.63 L 463.5 91.88 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/></g></g><g data-cell-id="lHPyWN3xTS5u2yIX5tx5-6">

What Wikmedia says is:

This SVG file contains an illegal namespace "http://www.w3.org/1999/xhtml".


Solution

  • According the message that you are getting and according the draw.io SVG export docs, the problem you are facing is that your SVG uses formatted text nodes, what draw.io can export only using embedded foreignObjects with elements from the HTML namespace (basically chunks of styled HTML, for its ability to wrap lines and format children tags).

    The only way to get "clean" single-namespace SVG diagram export seems to be to ensure that all text objects have both "Word Wrap" and "Formatted Text" options turned off.