XML technologies / SVG / SVG and XML / Solutions

(Excerpt from “Das Einsteigerseminar SVG — Webgrafiken mit XML” by Helma Spona)

  1. An XML namespace determines which commands and attributes are known and usable. SVG’s namespace supplies SVG tags; the XHTML namespace supplies XHTML tags.

  2. The declaration xmlns:html="http://www.w3.org/1999/xhtml" defines the XHTML namespace and specifies that its commands in the XML file begin with html:.

  3. With XHTML’s namespace defined, create a heading with <foreignObject><html:h1>Überschrift 1</html:h1></foreignObject>.

  4. The XML file should look as follows:

<?xml version="1.0" encoding="iso-8859-1"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:html="http://www.w3.org/1999/xhtml">
  <circle cx="10" cy="10" r="4" style="fill:red;stroke:black"/>
  <text x="10" y="30" style="fill:black;font-size:10px">test</text>
</svg>

  1. Create text with the HTML namespace and the <foreignObject> tag.

<foreignObject>
  <html:p>text</html:p>
</foreignObject>

  1. Position it with the attributes x and y of the tag <foreignObject>: <foreignObject x="20" y="0">.

   

 

 

 

back to top