svg:use (Use)
Describes the svg:use element in the SVG namespace that can be embedded in DrawingML-compatible graphics..
Description
svg:use is a DrawingML or SVG namespace element used to describe a specific part of a shape, text run, theme, or graphic. In the ECMA-376 DrawingML model, it participates in the XML content tree that defines visual appearance, geometry, and formatting for OOXML content.
The element is commonly encountered in presentation, document, and spreadsheet packages where shapes, charts, pictures, or text boxes are serialized as Open XML. The examples below illustrate a typical usage pattern and a corresponding Open XML SDK implementation.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
href |
string | IRI | Reference to another SVG element. |
x |
length | CSS length | X offset for the reused element. |
y |
length | CSS length | Y offset for the reused element. |
width |
length | CSS length | Width of the reused element. |
height |
length | CSS length | Height of the reused element. |
XML Example
<svg:use href="#icon" x="20" y="20" width="40" height="40"/>
using System.Xml.Linq;
XNamespace svg = "http://www.w3.org/2000/svg";
var use = new XElement(svg + "use",
new XAttribute("href", "#icon"),
new XAttribute("x", "20"),
new XAttribute("y", "20"),
new XAttribute("width", "40"),
new XAttribute("height", "40"));
Console.WriteLine(use);
Notes
- The permitted child elements and attribute values depend on the surrounding OOXML part and the schema version in use.
- In practice, DrawingML content is usually generated from higher-level shape or picture APIs rather than built manually element-by-element.
- When this element appears inside a document package, it is typically linked by relationships or contained in a drawing part that is referenced from a shape or graphic object.