Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Metadata in SVG

Tags:

Is there a way to attach metadata directly to a grouping element () in an svg file? I couldn't find anything about that in the specification or elsewhere on the web, so I assume it's not possible. Perhaps there are other ways to attach element specific metadata within the svg file...

What I try to do is to create a map and attach information about adjacent countries.

Cheers.

like image 546
sol Avatar asked Oct 30 '09 23:10

sol


People also ask

What is metadata in SVG?

21.2 The 'metadata' elementThe 'metadata' child element to an 'svg' element serves the purposes of identifying document-level metadata. The DTD definitions of many of SVG's elements (particularly, container and text elements) place no restriction on the placement or number of the 'metadata' sub-elements.

Does SVG have metadata?

Currently, many SVG documents contain RDF metadata that provides a title in the Dublin Core [DCORE] namespace, which is useful for certain types of processing, but which is not treated as a title for the document by many user agents.

What data does an SVG file contain?

SVG stands for Scalable Vector Graphic file. It's a file type that's used to render two-dimensional images on the web. Unlike the other standard file formats for images, SVG stores images in a vector format made up of lines, points, shapes, and curves based upon mathematical formulas.

Are svgs written in XML?

SVG files are written in XML, a markup language used for storing and transferring digital information. The XML code in an SVG file specifies all of the shapes, colors, and text that comprise the image. As you can see, there's not much code here. We only need one line of code to draw a circle.


1 Answers

As XML is extensible you can add attributes and element children as you wish. Here's a possible example:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:sol="http://www.sol.org">
  <circle cx="10" cy="20" sol:country="ruritania" r="5"/>
</svg>

Here the svg and circle elements are in SVG namespace and sol:country is in your namespace. I believe that SVG user agents will ignore foreign namespaces. You could also use a metadata schem such as Dublin Core.

Alternatively you could use a desc element (http://www.w3.org/TR/SVG/struct.html#DescElement)


5.4 The 'desc' and 'title' elements

Each container element or graphics element in an SVG drawing can supply a 'desc' and/or a 'title' description string where the description is text-only. When the current SVG document fragment is rendered as SVG on visual media, 'desc' and 'title' elements are not rendered as part of the graphics. User agents may, however, for example, display the 'title' element as a tooltip, as the pointing device moves over particular elements. Alternate presentations are possible, both visual and aural, which display the 'desc' and 'title' elements but do not display 'path' elements or other graphics elements. This is readily achieved by using a different (perhaps user) style sheet. For deep hierarchies, and for following 'use' element references, it is sometimes desirable to allow the user to control how deep they drill down into descriptive text.

like image 72
peter.murray.rust Avatar answered Oct 12 '22 09:10

peter.murray.rust