XML technologies / SVG / Creating graphic elements from templates / Solutions

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

  1. The tag <symbol> creates a symbol that serves as a template for creating elements. Symbols are rendered only when you create an element, or instance, from them. Groups, even when defined as invisible, are rendered immediately.

  2. In principle, symbols can also be stored in external files, as the SVG standard allows. Adobe SVG Viewer 2.0 does not yet support this, but you can test such references with Batik.

  3. Stylesheets are defined in a <style> tag inside a CDATA section. They begin with the applicable tag name, optionally followed by a period and a custom class name. The following listing defines two stylesheets for the <text> tag.

<style type="text/css">
  <![CDATA[text {fill:black;font-size:12px} text.wichtig {fill:red;font-size:13px}]]>
</style>

  1. Stylesheets without a custom class name apply automatically to all tags of that name. Others can be assigned through the class attribute of the relevant tag. The following text, for example, receives the stylesheet text.wichtig:

<text x="10" y="20" class="wichtig">test</text>

   

 

 

 

back to top