Do not use either <iframe> or <embed> . Instead, embed your SVG directly in XHTML, for example:
http://phrogz.net/svg/svg_in_xhtml5.xhtml
In doing so, you have full access to the SVG DOM as part of your document. As shown in this example, you just need to be sure to create SVG elements (but not attributes) using the SVG namespace. You must also ensure that your website submits the content type for xhtml as application/xhtml+xml or text/xml , not text/html .
phrogz$ curl --silent -I http://phrogz.net/svg/svg_in_xhtml5.xhtml | grep "Type" Content-Type: application/xhtml+xml
For more examples of JavaScript that process SVG mixed with HTML, see the various .xhtml files in the same directory . A particularly convincing example is this one , which dynamically creates hundreds of small SVG files in the form of inline elements that texts texts.
And to your question:
Can SVG evaluate math expressions in element attributes (just to be sure)?
In general, no. However, using SMIL Animation allows you to specify different methods for interpolating properties over time.
Finally, note that you do not need to put SVG in HTML to make it dynamic. You can script SVG with JavaScript directly. For example, see this test file (click the green button to start the simulation):
http://phrogz.net/svg/SpringzTest.svg
Phrogz
source share