Hi,
I have just checked into trunk some of the fruits of Abhishek's GSOC project to improve Inkscape's SVG output. Abhishek wrote the core routines to which I added a variety of utility functions. This code can result in cleaner and smaller SVG. It does the following things:
For a given element (<rect>, <path>, etc.) it checks:
1. That all attributes are valid.[1]
2. That properties are appropriate.[2]
3. That properties are useful.[3]
What Inkscape does when it finds a problem is controlled by settings under the "SVG output" section of the Inkscape Preferences dialog. For each of the above cases, you can independently:
1. Print out warnings to the console (if running Inkscape from the command line).
2. Delete the invalid or not useful items.
In the dialog, you can choose when Inkscape should test the SVG:
1. When reading files. (If this option is enabled at start-up, files Inkscape uses internally like icons.svg will also be checked.)
2. When editing files. (Mostly useful for debugging Inkscape.)
3. When writing files.
This code has been test on a variety of SVG files but it will need much broader testing. The default preferences are set to do nothing so as to avoid the risk of damaging files. Please take your favorite SVG files and compare the visual output when the "Remove" and "Writing" boxes are checked in the Inkscape Preferences dialog. Also, compiling the code under Windows and OSX needs to be checked.
Tav
[1] Only elements in the SVG name space are tested.
[2] The SVG specification explicitly allows styling properties such as 'font-family' on most SVG elements (e.g. <rect>) but there a many cases where they are of no use.
[3] A property is useful if it changes an inherited or default value.