20 Private Data
20.1 Introduction
SVG is defined to be a validating XML grammar. This means that elements
not defined in the SVG (e.g., elements defined in a different namespace)
are only allowed in particular designated sections of the SVG grammar.
The only places in the SVG grammar where arbitrary elements and/or
character data are allowed are:
- The <style> element (??? need link) within
a <defs> element (??? need link), which is
where CSS styles can be defined
- The <script> element (??? need link) within
a <defs> element (??? need link), which is
where scripts (e.g., ECMAScript) can be defined
- The <althtml> element (??? need link) which
provides the HTML (usually maybe in the form of images) which should
be used when viewing the file in a browser which doesn't yet
support SVG
- The <private> element which is described here.
A <private> element also can occur within a
<defs> element (??? need link).
The <private> element is meant for elements and
character data which are not defined as a part of the formal SVG grammar.
Common uses for <private> are:
- A place where authoring applications can put their own private data
to serve their own "roundtripping" purposes (i.e., the ability
to write, then read a file without loss of higher-level information)
- A place to define supplemental data for extensibility. For example,
suppose you have an extrusion extension which takes any 2D graphics
and extrudes it in three dimensions. When applying the extrusion
extension, you probably will need to set some parameters. The
<private> element is the expected place to establish the
parameters for the extension.
For
example, a business graphics authoring application might want to include
some private data within the <defs> section when it writes a SVG
file so that it could properly reassemble the chart (a pie chart in this
case) upon reading it back in:
<g>
<defs>
<private xmlns:myapp="http://mycompany/mapapp" >
<myapp:piechart title="Sales by Region">
<piece label="Northern Region" value="1.23"/>
<piece label="Eastern Region" value="2.53"/>
<piece label="Southern Region" value="3.89"/>
<piece label="Western Region" value="2.04"/>
<!-- Other private data goes here -->
</myapp:piechart>
</private>
</defs>
<!-- In here would be the actual graphics elements which
draw the pie chart -->
</g>