我需要将所有xlink用法替换为 SVG 中的简单内联 xml,然后删除“ defs ”部分并删除所有boo : 属性。这个是必需的,因为打算使用的 SVG 查看器不支持 xlinks。
初始简化 XML
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg">
<boo:metadata>
<boo:text line-space="1.5" minimum-size="15" regular-size="20"/>
</boo:metadata>
<g transform="translate(149,60)">
<rect x="0" y="0" fill-opacity="0.6" width="579" height="150"/>
<defs><!-- huge section with predefined items-->
<g id="ne">
<path id="ne..."/>
</g>
<g id="nw">
<path id="nw.."/>
</g>
<g id="rt2">
<rect id="RT2" />
<path id="some cool path id"/>
</g>
<g id="rt3">
<rect id="rt3sss" rx="2" ry="2"/>
</g>
<g boo:type="Icon" id="AIRPORT" boo:replacementWords="FLUGHAFEN">
<rect id="ICON_AIRPORT" fill="#FCFFFF" height="15" width="15"/>
<path id="ICON_AIRPORTPATH"/>
</g>
</defs>
<g boo:side="R" id="sssss" transform="translate(184,0)">
<g transform="translate(0.000000,0.000000)">
<g boo:style="HorizontalAlignment:Center;VerticalAlignment:Bottom;" transform="translate(63.202000,126.903002)">
<g transform="translate(0.000000,0.000000)">
<!-- actual usage -->
<use xlink:actuate="onLoad" xlink:type="simple" xlink:show="embed" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#NE" boo:style="HorizontalAlignment:Left;"/>
</g>
<g transform="translate(23.045999,0.000000)" boo:style="HorizontalAlignment:Left;Margin:0 5 0 5;">
<g transform="translate(0.000000,0.000000)" boo:style="Margin:0 1 0 1;">
<g transform="scale(1.150000,1.1500000)">
<!-- actual usage -->
<use xlink:actuate="onLoad" xlink:type="simple" xlink:show="embed" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#RT2"/>
</g>
<text transform="translate(16,13)" text-anchor="middle">4</text>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>
预期结果
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg">
<g transform="translate(149,60)">
<rect x="0" y="0" fill-opacity="0.6" width="579" height="150"/>
<g id="sssss" transform="translate(184,0)">
<g transform="translate(0.000000,0.000000)">
<g transform="translate(63.202000,126.903002)">
<g transform="translate(0.000000,0.000000)">
<path id="ne..."/>
</g>
<g transform="translate(23.045999,0.000000)">
<g transform="translate(0.000000,0.000000)">
<g transform="scale(1.150000,1.1500000)">
<rect id="RT2" />
<path id="some cool path id"/>
</g>
<text transform="translate(16,13)" text-anchor="middle">4</text>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>