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

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

To use a defined symbol, use the <use> tag again and specify the symbol with its xlink:href attribute. To scale or rotate the object, also use the transform attribute. The listing creates three copies of the symbol smButton at different positions, reduced to 70% of their original size.

<use x="0" y="0" xlink:href="#smButton" transform="translate(200 50) scale(0.7)"/>
<use x="0" y="0" xlink:href="#smButton" transform="translate(160 120) scale(0.7)"/>
<use x="0" y="0" xlink:href="#smButton" transform="translate(90 180) scale(0.7)"/>

The browser displays this result:

Copies created from smButton

Figure: Copies created from smButton.

   

 

 

 

back to top