6

Upgraded to 20.04 today and, somehow, Document Viewer is not able to open .svg files. It keeps giving this error. Previously, when I was using 18.04, everything was working fine. No such errors I encountered.

XML parse error: error code=201 (3) in (null):606:15: Namespace prefix xlink for href on image is not defined

EDIT

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="200" height="200">
  <image id="image0" width="200" height="200" x="0" y="0"
    xlink:href="data:image/png;base64
7

Your document viewer complains about the svg file having an xlink notation somewhere without being declared. As such, your svg file is not a valid xml and the document viewer complains correctly. Maybe in the newer version it is more strict about it.

To fix your file open it with an editor and make sure the xlink declaration is included in the <svg> tag in the very beginning of your file, it should look something like this:

<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink">

Update: For your file, change this line:

<svg width="200" height="200">

to this:

<svg width="200" height="200"
     xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink">
| improve this answer | |
4

See: <svg> - SVG: Scalable Vector Graphics | MDN

The svg element is a container that defines a new coordinate system and viewport. It is used as the outermost element of SVG documents, but it can also be used to embed a SVG fragment inside an SVG or HTML document.

Note: The xmlns attribute is only required on the outermost svg element of SVG documents. It is unnecessary for inner svg elements or inside HTML documents.


It is enough in most cases the svg tag to have the following attributes: xmlns and viewBox; optionally width and height:

<svg xmlns="http://www.w3.org/2000/svg"
     viewBox="0 0 16 16" width="50" height="50">
  <g>
    <path d=". . ."></path>
  </g>
</svg>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.