Hi everyone,
We're using Inkscape to great effect: thank you for a great product.
We do have a significant problem however. Our system embeds SVGs within SVGs (using the <svg:svg> tag) and then generates PDFs. We have a database of SVG artwork, and we embed those into templates by replacing the <svg:rect>s in the template with the <svg:svg> tags in the XML. It works great, until we have ID collisions between the embedded SVGs.
Here's the detailed scenario:
1) We create an SVG of a Blue Star. It has a gradient from dark to light blue that Inkscape generates an id for, say 'linearGradient4353'
2) We then save the file as "star_blue.svg" and modify it to change the gradient from dark green to light green. However, Inkscape does not change the ID.
3) We do this with star_green.svg, star_yellow.svg and 5 others.
4) Someone places more than one star in a template and there is a collision in the final document.
When this happens, the FIRST declaration of the linearGradient4353 is used for all references. That means that all the stars (in this case) would come out blue.
BTW: this is referred to here as the "purple banana" problem as that's when we first saw it.
Now, I understand (from a code perspective) how this happens: when the second declarations are found, they are ignored as that ID is already defined.
I also can't see a real problem with the SVG Spec here -- it doesn't say what to do when there is a collision between IDs -- it says they must be unique. So, taking the first one is probably a perfectly legal interpretation of the Spec.
However, it's not the best one for the end user. I think that would be to treat <svg:svg> tags as scopes and use a stack. If there is a collision, the inner declaration would hide the outer one until the closing </svg:svg> tag. That would make embedding SVGs far easier and more intuitive.
Assuming that can't be done, is there any other solution anyone can suggest? Right now, I'm considering writing a script that goes through all 6000+ SVG files and prepends the ID of the image to each ID declaration. Then I'll have to have the creation script do the same thing for all new pictures. That's a long and fairly dangerous solution (I don't like mass editing every picture in our DB). However, it's the best answer I have.
Any help out there?
Thanks
Bill