I'm building a set of SVG files that include an unfortunate number of hardcoded values (they must print with some elements sized in mm, while others must be scaled as a percent, and most of the values are defined relative to each other). Rather than managing those numbers by hand (heaven forbid I want to change something), I thought I might use my trusty hammer python for the task.
SVG 1.1 doesn't natively support any kind of variable scheme that would let me do what I want, and I'm not interested in introducing javascript or unstable w3c draft specs into the mix. One obvious solution is to use string formatting to read, parse, and replace variables in my SVG file. This seems like a bad idea for a larger document, but has the advantage of being simple and portable.
My second though was to investigate the available python->svg libraries. Unfortunately, it seems that the few options tend to be either too new (pySVG still has an unstable interface), too old (not updated since 2005), or abandoned. I haven't looked closely, but my sense is that the charting applications are not flexible enough to generate my documents.
The third option I came across was that of using some other drawing tool (cairo, for instance) that can be convinced to put out svg. This has the (potential) disadvantage of not natively supporting the absolute element sizes that are so important to me, but might include the ability to output PDF, which would be convenient.
I've already done the googling, so I'm looking for input from people who have used any of the methods mentioned, or who might know of some other approach. Long-term stability of whatever solution is chosen is important to me (it was the original reason for the hand-coding instead of just using illustrator).
At this point, I'm leaning towards the first solution, so recommendations on best practices for using python to parse and replace variables in XML files are welcome.