defs section breaks output file because of missing xlink namespace and duplicated IDs
See original GitHub issueIf I have source files using <use xlink:href="..."/>
the output file gets corrupted. It is missing the xlink namespace. Alternatively the xlink:href
should be converted into href
which is supported in modern browsers.
e.g. the European Flag:
<svg xmlns="http://www.w3.org/2000/svg" width="810" height="540" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 810 540">
<defs>
<g id="d">
<g id="b">
<path id="a" d="M0-1l-.31.95.477.156z"/>
<use xlink:href="#a" transform="scale(-1 1)"/>
</g>
<g id="c">
<use xlink:href="#b" transform="rotate(72)"/>
<use xlink:href="#b" transform="rotate(144)"/>
</g>
<use xlink:href="#c" transform="scale(-1 1)"/>
</g>
</defs>
<path fill="#039" d="M0 0h810v540H0z"/>
<g fill="#fc0" transform="matrix(30 0 0 30 405 270)">
<use y="-6" xlink:href="#d"/>
<use y="6" xlink:href="#d"/>
<g id="e">
<use x="-6" xlink:href="#d"/>
<use xlink:href="#d" transform="rotate(-144 -2.344 -2.11)"/>
<use xlink:href="#d" transform="rotate(144 -2.11 -2.344)"/>
<use xlink:href="#d" transform="rotate(72 -4.663 -2.076)"/>
<use xlink:href="#d" transform="rotate(72 -5.076 .534)"/>
</g>
<use xlink:href="#e" transform="scale(-1 1)"/>
</g>
</svg>
Resulted in a :
<svg xmlns="http://www.w3.org/2000/svg">
[1] missing namespace xlink error
Additionally the referenced IDs within the defs
section are not rewritten/renumbered. So if multiple files contain the same ID it will also break the output file:
<defs>
<g id="a"><path d="M0-1l-.31.95.477.156z"/></g>
<g id="a"><rect width="5" height="1" y="2" x="0"/></g>
</defs>
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Inline XBRL Part 1: Specification 1.1
An Inline XBRL Element is any element defined by this Specification with a namespace name which has a value of http://www.xbrl.org/2013/ ...
Read more >EDGAR Filer Manual, Volume II
Chapter 8 (Preparing and Transmitting EDGARLink Online Submissions) of the EDGAR. Filer Manual, Volume II: “EDGAR Filing.”.
Read more >Document Structure — SVG 2
An SVG document fragment can stand by itself as a self-contained file or resource, in which case the SVG document fragment is an...
Read more >SSDN - Duplicate xmlns value and XML header problem
The output XML should look exactly like the output file I have uploaded in my previous post. I am attaching the screenshot of...
Read more >Release Notes for the DocBook XSL Stylesheets - SourceForge
Add missing xlink namespace declaration to the root element. ... simple.xlink because it produces duplicate ids in the output because the element template ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I made a template that fixes this issue by checking if
xlink:href
occurs in the symbols or defs and outputting axmlns:xlink
attribute on the<svg>
element in that case: https://github.com/gradientz/assets-builder/blob/master/assets-builder/tasks/svgsymbols-sprite.svg?short_path=5622458For avoiding duplicating ids, I use
gulp-svgmin
to rewrite the ids:@Hiswe Sure. Simply check all IDs which will be added together to
defs
section. Should be enough I think. Thx man.