Basic Data Types and Interfaces – SVG 1.1 (Second Edition) (original) (raw)

Contents

4.1 Syntax

The EBNF grammar is as used in the XML specification, with the addition of ~, a case-insensitive literal: characters in the ASCII range (only) are declared to be case-insensitive. For example, ~"Hello" will match (H|h)(e|e)(l|L)(l|L)(o|O). This makes the productions much easier to read.

? optional, zero or one
+ one or more
* zero or more
| alternation
"string" literal
~"string" case-insensitive literal
[] a character range
[^] excluded character range
() grouping

4.2 Basic data types

This section defines a number of common data types used in the definitions of SVG properties and attributes. Some data types that are not referenced by multiple properties and attributes are defined inline in subsequent chapters.

Note that, as noted below, the specification of some types is different for CSS property values in style sheets (in the ‘style’ attribute,‘style’ element or an external style sheet) than it is for for XML attribute values (including presentation attributes). This is due to restrictions in the CSS grammar. For example, scientific notation is allowed in attributes, including presentation attributes, but not in style sheets.

Angles are specified in one of two ways depending upon whether they are used in CSS property syntax or SVG presentation attribute syntax:

In the SVG DOM, values are represented usingSVGAngle or SVGAnimatedAngle objects.

The basic type is a sequence of zero or more characters. Specifically:

anything ::= Char*

where Char is the production for a character, as defined in XML 1.0 ([XML10], section 2.2).

The basic type is a CSS2 compatible specification for a color in the sRGB color space [SRGB]. applies to SVG's use of the ‘color’ property and is a component of the definitions of properties ‘fill’,‘stroke’, ‘stop-color’, ‘flood-color’ and‘lighting-color’, which also offer optional ICC-based color specifications.

SVG supports all of the syntax alternatives for defined inCSS2 syntax and basic data types ([CSS2], section 4.3.6), with the exception that SVG allows an expanded list ofrecognized color keywords names.

A is either a keyword (seeRecognized color keyword names) or a numerical RGB specification.

In addition to these color keywords, users may specify keywords that correspond to the colors used by objects in the user's environment. The normative definition of these keywords is found inUser preferences for colors ([CSS2], section 18.2).

The format of an RGB value in hexadecimal notation is a "#" immediately followed by either three or six hexadecimal characters. The three-digit RGB notation (#rgb) is converted into six-digit form (#rrggbb) by replicating digits, not by adding zeros. For example, #fb0 expands to #ffbb00. This ensures that white (#ffffff) can be specified with the short notation (#fff) and removes any dependencies on the color depth of the display. The format of an RGB value in the functional notation is an RGB start-function followed by a comma-separated list of three numerical values (either three integer values or three percentage values) followed by ")". An RGB start-function is the case-insensitive string "rgb(", for example "RGB(" or "rGb(". For compatibility, the all-lowercase form "rgb(" is preferred. The integer value 255 corresponds to 100%, and to F or FF in the hexadecimal notation: rgb(255,255,255) = rgb(100%,100%,100%) = #FFF. White space characters are allowed around the numerical values. All RGB colors are specified in the sRGB color space [SRGB]. Using sRGB provides an unambiguous and objectively measurable definition of the color, which can be related to international standards (see [COLORIMETRY]).

color ::= "#" hexdigit hexdigit hexdigit (hexdigit hexdigit hexdigit)? | "rgb(" wsp* integer comma integer comma integer wsp* ")" | "rgb(" wsp* integer "%" comma integer "%" comma integer "%" wsp* ")" | color-keyword hexdigit ::= [0-9A-Fa-f] comma ::= wsp* "," wsp*

where color-keyword matches (case insensitively) one of the color keywords listed in Recognized color keyword names below, or one of the system color keywords listed inUser preferences for colors ([CSS2], section 18.2).

The corresponding SVG DOM interface definitions for are defined inDocument Object Model CSS; in particular, see RGBColor ([DOM2STYLE], section 2.2). SVG's extension to color, including the ability to specify ICC-based colors, are represented using DOM interface SVGColor.

A is 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). Its syntax is the same as that for.

coordinate ::= length

Within the SVG DOM, a is represented as an SVGLength or an SVGAnimatedLength.

Frequency values are used with aural properties. As defined in CSS2, a frequency value is a immediately followed by a frequency unit identifier. The frequency unit identifiers are:

Frequency values may not be negative.

In the SVG DOM, values are represented using the CSSPrimitiveValue interface defined in Document Object Model CSS ([DOM2STYLE], section 2.2).

Functional notation for an IRI: "url(" ")".

An is an ICC color specification. In SVG 1.1, an ICC color specification is given by a name, which references a ‘color-profile’ element, and one or more color component values. The grammar is as follows:

icccolor ::= "icc-color(" name (comma-wsp number)+ ")" name ::= [^,()#x20#x9#xD#xA] /* any char except ",", "(", ")" or wsp */

The corresponding SVG DOM interface for isSVGICCColor.

An is specified as an optional sign character ("+" or "-") followed by one or more digits "0" to "9":

integer ::= [+-]? [0-9]+

If the sign character is not present, the number is non-negative.

Unless stated otherwise for a particular attribute orproperty, the range for an encompasses (at a minimum) -2147483648 to 2147483647.

Within the SVG DOM, an is represented as along or anSVGAnimatedInteger.

An Internationalized Resource Identifier (see IRI). For the specification of IRI references in SVG, seeIRI references.

A length is a distance measurement, given as a number along with a unit which may be optional. Lengths are specified in one of two ways depending upon whether they are used in CSS property syntax or SVGpresentation attribute syntax:

In the SVG DOM, values are represented usingSVGLength or SVGAnimatedLength objects.

A is a list of font family names using the same syntax as the ‘font-family’ property, excluding the and 'inherit' values.

A consists of a separated sequence of s. String lists are white space-separated, where white space is defined as one or more of the following consecutive characters: "space" (U+0020), "tab" (U+0009), "line feed" (U+000A) and "carriage return" (U+000D).

The following is an EBNF grammar describing the syntax:

list-of-strings ::= string | string wsp list-of-strings string ::= [^#x9#xA#xD#x20]* wsp ::= [#x9#xA#xD#x20]+

(Where T is a type other than and .) A list consists of a separated sequence of values. Unless explicitly described differently, lists within SVG's XML attributes can be either comma-separated, with optional white space before or after the comma, or white space-separated.

White space in lists is defined as one or more of the following consecutive characters: "space" (U+0020), "tab" (U+0009), "line feed" (U+000A), "carriage return" (U+000D) and "form-feed" (U+000C).

The following is a template for an EBNF grammar describing the syntax:

list-of-Ts ::= T | T comma-wsp list-of-Ts comma-wsp ::= (wsp+ ","? wsp) | ("," wsp) wsp ::= (#x20 | #x9 | #xD | #xA)

Within the SVG DOM, values of a type are represented by an interface specific for the particular type T. For example, a is represented in the SVG DOM using an SVGLengthList or SVGAnimatedLengthList object.

A name, which is a string where a few characters of syntactic significance are disallowed.

name ::= [^,()#x20#x9#xD#xA] /* any char except ",", "(", ")" or wsp */

Real numbers are specified in one of two ways. When used in a style sheet, a is defined as follows:

number ::= integer | [+-]? [0-9]* "." [0-9]+

This syntax is the same as the definition in CSS ([CSS2], section 4.3.1).

When used in an SVG attribute, a is defined differently, to allow numbers with large magnitudes to be specified more concisely:

number ::= integer ([Ee] integer)? | [+-]? [0-9]* "." [0-9]+ ([Ee] integer)?

Within the SVG DOM, a is represented as afloat, SVGNumber or aSVGAnimatedNumber.

A pair of s, where the second is optional.

number-optional-number ::= number | number comma-wsp number

In the SVG DOM, a is represented using a pair of SVGAnimatedInteger or SVGAnimatedNumber objects.

The values for properties ‘fill’ and ‘stroke’ are specifications of the type of paint to use when filling or stroking a given graphics element. The available options and syntax for are described inSpecifying paint.

Within the SVG DOM, values are represented usingSVGPaint objects.

Percentages are specified as a number followed by a "%" character:

percentage ::= number "%"

Note that the definition of depends on whether the percentage is specified in a style sheet or in an attribute that is not also a presentation attribute.

Percentage values are always relative to another value, for example a length. Each attribute or property that allows percentages also defines the reference distance measurement to which the percentage refers.

Within the SVG DOM, a is represented using an SVGNumber or SVGAnimatedNumber object.