: Illustrator breaking apart and prepending '_x3' to every element that starts with a number in SVG export I'm not sure if this is regular behavior, but when I do an SVG export in Illustrator,
I'm not sure if this is regular behavior, but when I do an SVG export in Illustrator, each layer name I have that is a number with be converted to a format I don't quite understand. I'm creating an SVG of a building map, so there are several sublayers that I've named the room number for each room.
When it exports, I'll have a room number of something like 100 and a layer for everything pertaining to that room, but the exporting id will be named _x31_00 and a room of 213 will become _x32_13.
I could understand if it didn't like an id starting with a number, but I don't understand why it would need to further add the underscore in the middle of the id (to make something like _x3213 or _x3_213).
I suppose I could change all the layers to something like Rm100, but I'd want to try to avoid work-arounds if at all possible.
My questions are
Is there a way to change this behavior in the configuration? and
If this is intentional by the program, I was just curious about the reasoning behind "_x3" (it's always hard to google for small amounts of characters, especially with special characters in it)
More posts by @Caterina889
1 Comments
Sorted by latest first Latest Oldest Best
As per comment by @Yorik apparently SVG standard defines id as a NCName which is Name with no colons allowed. Now a xml name can not start with a number as per XML standard. It also disallows other chars such as - and ..
Having a name that starts with a number will automatically invokes name mangling to make the name standards compilant. Not doing this could be disastrous, as XML forbids accepting malformed XML for further processing. So a svg renderer might not render the svg at all if the name does not match the standard and be doing completely the right thing.
Easiest solution is to simply rename the offending names to something that is valid like changing 99 to r99 or something similar (note name normalization applies if you use a underscore). Doing this after the fact is a bit tedious so i wrote a script for you to fix this:
#target illustrator
function is_numeric(str){
return /^d+$/.test(str);
}
var doc = app.activeDocument;
var itemCount = doc.pageItems.length;
for (var j = 0; j < itemCount; j++) {
item = doc.pageItems[j];
if (is_numeric(item.name[0]))
item.name = "r" + item.name;
}
redraw();
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.