3 Data Types
Contents
3.1 Basic data types
The common data types for dSVG's properties and attributes fall into the
following categories:
-
<boolean>: A <boolean> is specified
as either 'true' or 'false'.
-
<integer>: An <integer> is specified
as an optional sign character ('+' or '-') followed by one or more digits "0"
to "9". If the sign character is not present, the number is non-negative.
Unless stated otherwise for a particular attribute or
property, the range for a <integer> encompasses (at a minimum)
-2147483648 to 2147483647.
Within the SVG DOM, an <integer> is represented as an
long
or an
SVGAnimatedInteger.
-
<number>
(real number value): The specification of real number values is different for
property values than for XML attribute values.
-
CSS2 [CSS2] states that a
property value which is a <number> is specified in
decimal
notation
(i.e., a
<decimal-number>), which consists
of either an <integer>,
or an optional sign character followed by zero or more digits followed by a dot
(.) followed by one or more digits. Thus, for conformance with CSS2, any
property
in SVG which accepts <number> values is specified in decimal notation
only.
-
For SVG's XML attributes, to provide as much scalability in numeric values as
possible, real number values can be provided either in
decimal notation or in
scientific notation
(i.e., a
<scientific-number>), which
consists of a
<decimal-number> immediately followed by the letter "e" or "E"
immediately followed by an
<integer>.
Unless stated otherwise for a particular attribute or
property, a <number> has the capacity for at least a
single-precision floating point number (see [ICC32])
and has a range (at a minimum) of -3.4e+38F to +3.4e+38F.
It is recommended that higher precision floating point storage and computation
be performed on operations such as coordinate system transformations to provide
the best possible precision and to prevent round-off errors.
Conforming High-Quality SVG Viewers are required to use at least
double-precision floating point (see [ICC32])
for intermediate calculations on certain numerical operations.
Within the SVG DOM, a <number> is represented as a
float
or an
SVGAnimatedNumber.
-
<length>: A length is a distance
measurement. The format of a <length> is a
<number> optionally followed immediately by a
unit identifier. (Note that the specification of a
<number> is different for
property values than for XML attribute values.)
If the <length> is expressed as a value without a unit identifier (e.g.,
48), then the <length> represents a
distance in the current user coordinate system.
If one of the unit
identifiers is provided (e.g.,
12mm), then the <length> is processed
according to the description in
Units.
Percentage values (e.g.,
10%) depend on the particular property or
attribute to which the percentage value has been assigned. Two common cases
are: (a) when a percentage value represents a percent of the viewport (refer to
the section that discusses
Units in general), and (b) when a percentage value represents a percent
of the bounding box on a given object (refer to the section that describes
Object bounding box units).
Within the SVG DOM, a <length> is represented as an
SVGLength or an
SVGAnimatedLength.
-
<coordinate>: A <coordinate>
represents a <length>
in the user coordinate system that is the given distance from the origin of the
user coordinate system along the relevant axis (the x-axis for X coordinates,
the y-axis for Y coordinates).
Within the SVG DOM, a <coordinate> is represented as an
SVGLength or an
SVGAnimatedLength
since both values have the same syntax.
-
<uri>
(Uniform Resource Identifiers [URI] references): A URI is the address of a
resource on the Web. For the specification of URI references in SVG, see
URI references.
Within the SVG DOM, <uri> is represented as a
DOMString
or an
SVGAnimatedString.