normalizing svg files

Jos van den Oever jos at vandenoever.info
Tue Sep 6 09:58:57 UTC 2016


Hi all,

Icons in breeze are stored as uncompressed SVG. That should make diffs more 
readable. In practice, diffs can be quite hard to read due to different ways of 
writing out XML by different applications, application versions and settings.

A solution to this is to use XML normalization (c14n). xmllint provides this.

I've attached a script that will normalize XML files. I've used a similar 
script for quite some time.

  "$xmllint" --nonet --c14n11 "$1" \
    | XMLLINT_INDENT=' ' \
      "$xmllint" --nonet --format --encode utf-8 --xmlout --nsclean - \
    | "$perl" -p -e 's/[ \t]+$//g' - \
    > "$tmpfile" || "$rm" "$tmpfile"

The script follows the c14n11 transform with a formatting. The formatting 
changes <a></a> to <a/> and adds an initial <?xml .. ?>.

The most notable feature is that attributes are sorted and placed on one line.

Like whitespace discussions, the actual choice is not that important, but for 
nice diffs, consistency is.

There's a slight space saving (1MB out of 64MB).

Cheers,
Jos
-------------- next part --------------
A non-text attachment was scrubbed...
Name: normalize.sh.gz
Type: application/gzip
Size: 788 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20160906/b95cd674/attachment.bin>


More information about the Kde-frameworks-devel mailing list