I would like to convert all CSS "class" attributes of svg document tags to
"style" attributes, for example:
Input:
<?xml version="1.0" encoding="ISO-8859-2"?>
<svg width="200" viewBox="0 0 200 400"
height="400"xmlns="http://www.w3.org/2000/svg">
<defs>
<style type="text/css">
<![CDATA[
.str2 {stroke:#4C4C4C;stroke-width:25}
.str1 {stroke:#FF00FF;stroke-width:7;stroke-dasharray:13 7}
.fil1 {fill:#0000FF}
.fil2 {fill:#00FF00}
]]>
</style>
</defs>
<g class="fil1 str1">
<rect x="50" y="50" width="100" height="75" class="fil2"/>
<rect x="50" y="150" width="100" height="75"/>
<rect x="50" y="250" width="100" height="75" class="fil2 str2"/>
</g>
</svg>
Output:
<?xml version="1.0" encoding="ISO-8859-2"?>
<svg width="200" viewBox="0 0 200 400" height="400"
xmlns="http://www.w3.org/2000/svg">
<g style="fill:#0000FF; stroke:#FF00FF;stroke-width:7;stroke-dasharray:13 7">
<rect x="50" y="50" width="100" height="75" style="fill:#00FF00"/>
<rect x="50" y="150" width="100" height="75"/>
<rect x="50" y="250" width="100" height="75"
style="fill:#00FF00;stroke:#4C4C4C;stroke-width:25"/>
</g>
</svg>
I've thought about using Batik CSS and SVG specific DOM interfaces, but I am not
sure if there are suitable methods for my problem.
I tried:
String styleCSS =
((CSSStylableElement)node).getComputedStyleMap(null).toString(CSSUtilities.getCSSEngine((Element)node));
but it gives me a lot of inherited and default CSS settings for the node. For
example for the second rect from the document above I get:
clip-path: none; color-rendering: auto; display: inline; fill: rgb(0, 255, 0);
fill-opacity: 1; filter: none; mask: none;
opacity: 1; pointer-events: visiblepainted; shape-rendering: auto; stroke:
rgb(255, 0, 255); stroke-dasharray:
[EMAIL PROTECTED]; stroke-dashoffset: 0;
stroke-linecap: butt;
stroke-linejoin: miter; stroke-miterlimit: 4; stroke-opacity: 1; stroke-width:
7; visibility: visible;
Thanks in advance for help,
Regards,
Lukasz Matuszczak
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]