Here is the content of the files I refer to:
<?xml version="1.0" standalone="yes" ?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" width="400px" height="300px">
<desc>a single red square</desc>
<g id="oAll">
<rect id="oRect" x="50" y="100" width="100" height="100" fill="red"/>
</g>
</svg>
It turns out that Firefox working with standalone files does not need the XML declaration nor the DTD but certainly needs the namespace reference.
It is nice to see the SVG drawings operate in standalone files but what I need is to be able to fetch textual SVG data on the fly and display it on my page. By all appearances you are supposed to use the .innerHTML property to trigger the parsing of the XML (http://www.whatwg.org/specs/web-apps/current-work/#innerhtml1 section 2.5.3) but all I get is the descriptive alternative.
I have a simple .html and it appears below. Anyone who thinks they can help could save this text as a .html to demonstrate the problem. Here, when the file is loaded it firsly displays the unformatted xml data and then it runs the .innerHTML assignation. It then displays the descriptive alternative message instead of the red square.
- Code: Select all
<html>
<head>
<script>
function go(){
var xmlSVG='<?xml version="1.0" standalone="yes" ?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" width="400px" height="300px"><desc>a single red square</desc><g id="oAll"><rect id="oRect" x="50" y="100" width="100" height="100" fill="red"/></g></svg></xml>';
alert(xmlSVG);
var anElementObject=document.getElementById("anElement");
anElementObject.innerHTML=xmlSVG;
}
</script>
</head>
<body onload="go()">
<div id="anElement">.....</div>
</body>
</html>


