I want to combine several SVG fragments from different source documents into one result document. To avoid ID conflicts, I'll have to "namespace" the IDs of each source document by prefixing them with a unique string.
I can use XPath to find all ID declarations within the SVG documents (e.g. //@id
). I could substitute the IDs either by directly manipulating the DOM or by doing some regular expression wizardry (or a combination of both). As a side note: I'm doing all this with PHP, and speed / performance doesn't matter that much, so regex replacements are just fine.
So far, I'm treating any attribute with a local name of id
as an ID declaration, like e.g.
<clipPath id="a">...</clipPath>
and I succeed in replacing corresponding IDREFs of this syntax (i.e. when preceeded by a #
):
<g clip-path="url(#a)">...</g>
Now these are my questions:
- Are there any other attributes in SVG other than those with a local name of
id
that are also ID declarations? Which ones? - Are there any other syntaxes of IDREFs in SVG other than the above one (preceeding
#
)? Which ones? - Are there any resources about IDs / IDREFs in SVG I should be aware of?
- Are there any potential conflicts other than duplicate IDs when merging SVG documents?
Thanks for any hints! :)