How to normalize or simplify the generated xml

Discuss SVG code, accessible via the XML Editor.
jc_dev

How to normalize or simplify the generated xml

Postby jc_dev » Tue Jun 22, 2010 11:33 am

Not sure if normalize is the right word, but - given two identical rectangles, side-by-side, sometimes they have different Y coordinates and a transform property. For instance:

Code: Select all

<rect id="rect3606"
width="100" height="100"
x="200" y="600" />

<rect id="rect3607"
width="100" height="100"
x="350" y="100"
transform="translate(0, 500)" />


where the second rectangle, instead of having a Y of 600, has a Y of 100 and a translate property that presumably raises it by 500.

How can I save the file such that there is no transform property? As I've tested creating numerous rectangles, sometimes it happens accidently, but I don't know how to consistently normalize it. :) Thanks.

John C>
"For all your days, prepare, and meet them ever alike;
When you are the anvil, bear - when the hammer, strike."

User avatar
tomh
Posts: 218
Joined: Sat Feb 14, 2009 10:14 pm

Re: How to normalize or simplify the generated xml

Postby tomh » Tue Jun 22, 2010 9:56 pm

Ensure you are storing optimised transformations:
File -> Inkscape Preferences -> Transformations -> "store transformations" = Optimised
then select all your objects and nudge them left/right to update (Inkscape only changes the svg if you move/work on the objects)
Also I think File-> Save as -> optimised svg may have some options (but is is currently broken on my computer...)

Note that it may not be possible to remove all the transform attributes. ( e.g. if you transform a group of objects) as sometimes there is no other way or representing the transformed object (esspecially when using skew and rotate)

jc_dev

Re: How to normalize or simplify the generated xml

Postby jc_dev » Tue Jun 22, 2010 11:49 pm

Thanks for the reply. Although it already had optimization on, moving the rectangles up/down did remove their transform. Oddly, it still got a weird value - then I looked around and noticed that the level had a transform (I don't even remember creating a level), but fortunately, deleting the level, removed that transform also.

I didn't notice a File-> Save as -> optimised svg, but I'm running 0.47pre1, there could be a later version.

John C>
"For all your days, prepare, and meet them ever alike;
When you are the anvil, bear - when the hammer, strike."


Return to “SVG / XML Code”