In doing some testing for JavaScript SAX2 parser
(http://code.google.com/p/jssaxparser/ ), I discovered that in one of
our tests (which checked for identity among attributes within the
built-in parser and our own which started from
document.implementation.createDocument), when using SVG, certain
attributes were altered by Firefox. While FF 3.5 avoids the issue of
"scale(4)" turning into "scale(4, 4)", the built-in DOMParser() still
auto-changes the whitespace.
// No space
var text = '<svg xmlns="http://www.w3.org/2000/svg">'+
'<g transform="translate(20,20) scale(4)"></g></svg>';
// The attribute value now has an extra space within the translate()
function
var t = new DOMParser().parseFromString(text,"text/xml");
alert(t.getElementById('a').getAttribute('transform'));
// Here it is again showing the whole document
alert(new XMLSerializer().serializeToString(new
DOMParser().parseFromString(text,"text/xml"))); <svg
xmlns="http://www.w3.org/2000/svg"><g transform="translate(20, 20)
scale(4)"/></svg>
If you change the SVG namespace (to make this some other XML), the
attribute no longer adds a space.
So, while this issue doesn't apparently affect functionality, it still
causes problems for those which reflect on XML...
File a bug?
Brett
I believe SVG allows normalizing attribute values, yes...
-Boris