Home > Blockchain >  Explain these Colab warnings for my valid SVG code
Explain these Colab warnings for my valid SVG code

Time:01-06

I put the following code into a code cell in Google Colab:

%%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 width="400" height="110">
  <rect width="300" height="100" style="fill:rgb(100,100,255); stroke-width:3; stroke:rgb(0,0,0)" />
</svg>

The result is properly executed and rendered but the code itself is embellished with red markings at the beginning of each tag and there is a red vertical line at the right border of the cell to indicate some warnings.

The code itself has been validated by enter image description here

enter image description here

CodePudding user response:

You are missing the namespace: xmlns="http://www.w3.org/2000/svg" in the root element (<svg>).

A SVG document is a XML document, which is a general markup language. The application that reads the file/document needs to know what "language" the element uses.

<?xml version="1.0" encoding="UTF-8" ?>
<svg xmlns="http://www.w3.org/2000/svg" width="400" height="110">
  <rect width="300" height="100" style="fill:rgb(100,100,255); stroke-width:3; stroke:rgb(0,0,0)" />
</svg>

CodePudding user response:

The red markings are gone now. It was only a Colab bug after they introduced a new feature highlighting syntax issues. This new feature treated the code as written in Python.

  •  Tags:  
  • Related