Skip to content

Problematic xmlns:ns0 with write_xml #246

@alexreg

Description

@alexreg

Take an SVG like the following.

<svg xmlns:ns0="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events">
    ...
</svg>

If I then load and write this SVG back to a file, as follows.

svg = SVG.parse("input.svg")
svg.write_xml("output.svg")

Then I get something like this.

<svg xmlns:ns0="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events">
    ...
</svg>

This is invalid XML, since the same namespace is defined with two different names (ns0 and xlink), and causes problems with some other programs that read SVGs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions