firstDaisy Diff compare report.
Click on the changed parts for a detailed description. Use the left and right arrow keys to walk through the modifications.
last 

5.8 Conditional processing

5.8.1 Conditional processing overview

SVG contains a 'switch' element along with attributes 'requiredFeatures', 'requiredExtensions' and 'systemLanguage' to provide an ability to specify alternate viewing depending on the capabilities of a given user agent or the user's language.


<!ENTITY % SVG.Conditional.extra.attrib "" >
<!ENTITY % SVG.Conditional.attrib
    "requiredFeatures %FeatureList.datatype; #IMPLIED
     requiredExtensions %ExtensionList.datatype; #IMPLIED
     systemLanguage %LanguageCodes.datatype; #IMPLIED
     %SVG.Conditional.extra.attrib;"
>

Attributes requiredFeatures, requiredExtensions and systemLanguage Attributes 'requiredFeatures', 'requiredExtensions' and 'systemLanguage' act as tests and return either true or false results. The 'switch' renders the first of its children for which all of these attributes test true. If the given attribute is not specified, then a true value is assumed.

Similar to the 'display' property, conditional processing attributes only affect the direct rendering of elements and do not prevent elements from being successfully referenced by other elements (such as via a 'use').

In consequence:

5.8.2 The 'switch' element

'switch'
Categories:
None
Content model:
Any number of the following elements, in any order:
Attributes:
DOM Interfaces:

The 'switch' element evaluates the 'requiredFeatures', 'requiredExtensions' and 'systemLanguage' attributes on its direct child elements in order, and then processes and renders the first child for which these attributes evaluate to true. All others will be bypassed and therefore not rendered. If the child element is a container element such as a 'g', then the entire subtree is either processed/rendered or bypassed/not rendered.

Note that the values of properties 'display' and 'visibility' have no effect on 'switch' element processing. In particular, setting 'display' to none on a child of a 'switch' element has no effect on true/false testing associated with 'switch' element processing.

 

<!ENTITY % SVG.switch.extra.content "" >
<!ENTITY % SVG.switch.element "INCLUDE" >
<![%SVG.switch.element;[
<!ENTITY % SVG.switch.content
    "(( %SVG.Description.class; )*, ( %SVG.svg.qname; | %SVG.g.qname;
      | %SVG.use.qname; | %SVG.text.qname; | %SVG.Animation.class;
        %SVG.Conditional.class; %SVG.Image.class; %SVG.Shape.class;
        %SVG.Hyperlink.class; %SVG.Extensibility.class;
        %SVG.switch.extra.content; )*)"
>
<!ELEMENT %SVG.switch.qname; %SVG.switch.content; >
<!-- end of SVG.switch.element -->]]>
<!ENTITY % SVG.switch.attlist "INCLUDE" >
<![%SVG.switch.attlist;[
<!ATTLIST %SVG.switch.qname;
    %SVG.Core.attrib;
    %SVG.Conditional.attrib;
    %SVG.Style.attrib;
    %SVG.Presentation.attrib;
    %SVG.GraphicalEvents.attrib;
    %SVG.External.attrib;
    transform %TransformList.datatype; #IMPLIED
>

For more information and an example, see Embedding foreign object types.

5.8.3 The 'requiredFeatures' attribute

Definition of requiredFeatures:

requiredFeatures = list-of-features
The value is a list of feature strings, with the individual values separated by white space. Determines whether all of the named features are supported by the user agent. Only feature strings defined in the Feature String appendix are allowed. If all of the given features are supported, then the attribute evaluates to true; otherwise, the current element and its children are skipped and thus will not be rendered.
Animatable: no.

If the attribute is not present, then its implicit return value is "true". If a null string or empty string value is given to attribute 'requiredFeatures', the attribute returns "false".

'requiredFeatures' is often used in conjunction with the 'switch' element. If the 'requiredFeatures' is used in other situations, then it represents a simple switch on the given element whether to render the element or not.

5.8.4 The 'requiredExtensions' attribute

The 'requiredExtensions' attribute defines a list of required language extensions. Language extensions are capabilities within a user agent that go beyond the feature set defined in this specification. Each extension is identified by a URI reference.

Definition of requiredExtensions:

requiredExtensions = list-of-extensions
The value is a list of URI references which identify the required extensions, with the individual values separated by white space. Determines whether all of the named extensions are supported by the user agent. If all of the given extensions are supported, then the attribute evaluates to true; otherwise, the current element and its children are skipped and thus will not be rendered.
Animatable: no.

If a given URI reference contains white space within itself, that white space must be escaped.

If the attribute is not present, then its implicit return value is "true". If a null string or empty string value is given to attribute 'requiredExtensions', the attribute returns "false".

'requiredExtensions' is often used in conjunction with the 'switch' element. If the 'requiredExtensions' is used in other situations, then it represents a simple switch on the given element whether to render the element or not.

The URI names for the extension should include versioning information, such as "http://example.org/SVGExtensionXYZ/1.0", so that script writers can distinguish between different versions of a given extension.

5.8.5 The 'systemLanguage' attribute

The attribute value is a comma-separated list of language names as defined in Tags for the Identification of Languages [RFC3066].

Evaluates to "true" if one of the languages indicated by user preferences exactly equals one of the languages given in the value of this parameter, or if one of the languages indicated by user preferences exactly equals a prefix of one of the languages given in the value of this parameter such that the first tag character following the prefix is "-".

Evaluates to "false" otherwise.

Note: This use of a prefix matching rule does not imply that language tags are assigned to languages in such a way that it is always true that if a user understands a language with a certain tag, then this user will also understand all languages with tags for which this tag is a prefix.

The prefix rule simply allows the use of prefix tags if this is the case.

Implementation note: When making the choice of linguistic preference available to the user, implementers should take into account the fact that users are not familiar with the details of language matching as described above, and should provide appropriate guidance. As an example, users may assume that on selecting "en-gb", they will be served any kind of English document if British English is not available. The user interface for setting user preferences should guide the user to add "en" to get the best matching behavior.

Multiple languages MAY be listed for content that is intended for multiple audiences. For example, content that is presented simultaneously in the original Maori and English versions, would call for:

<text systemLanguage="mi, en"><!-- content goes here --></text>

However, just because multiple languages are present within the object on which the 'systemLanguage' test attribute is placed, this does not mean that it is intended for multiple linguistic audiences. An example would be a beginner's language primer, such as "A First Lesson in Latin," which is clearly intended to be used by an English-literate audience. In this case, the 'systemLanguage' test attribute should only include "en".

Authoring note: Authors should realize that if several alternative language objects are enclosed in a 'switch', and none of them matches, this may lead to situations where no content is displayed. It is thus recommended to include a "catch-all" choice at the end of such a 'switch' which is acceptable in all cases.

For the 'systemLanguage' attribute: Animatable: no.

If the attribute is not present, then its implicit return value is "true". If a null string or empty string value is given to attribute 'systemLanguage', the attribute returns "false".

'systemLanguage' is often used in conjunction with the 'switch' element. If the 'systemLanguage' is used in other situations, then it represents a simple switch on the given element whether to render the element or not.

5.8.6 Applicability of

Test Attributes

test attributes

The following list describes the applicability of the test attributes to the elements that do not directly produce rendering.

5.9 Specifying whether external resources are required for proper rendering

Documents often reference and use the contents of other files (and other Web resources) as part of their rendering. In some cases, authors want to specify that particular resources are required for a document to be considered correct.

Attribute 'externalResourcesRequired' is available on all container elements and to all elements which potentially can reference external resources. It specifies whether referenced resources that are not part of the current document are required for proper rendering of the given container element or graphics element.

Attribute definition:

externalResourcesRequired = "false | true"
false
(The default value.) Indicates that resources external to the current document are optional. Document rendering can proceed even if external resources are unavailable to the current element and its descendants.
true
Indicates that resources external to the current document are required. If an external resource is not available, progressive rendering is suspended, the document's SVGLoad event is not fired and the animation timeline does not begin until that resource and all other required resources become available, have been parsed and are ready to be rendered. If a timeout event occurs on a required resource, then the document goes into an error state (see Error processing). The document remains in an error state until all required resources become available.

This attribute applies to all types of resource references, including style sheets, color profiles (see Color profile descriptions) and fonts specified by a URI reference using a 'font-face' element or a CSS @font-face specification. In particular, if an element sets externalResourcesRequired="true", then all style sheets must be available since any style sheet might affect the rendering of that element.

Attribute 'externalResourcesRequired' is not inheritable (from a sense of attribute value inheritance), but if set on a container element, its value will apply to all elements within the container.

Because setting externalResourcesRequired="true" on a container element can have the effect of disabling progressive display of the contents of that container, tools that generate SVG content are cautioned against using simply setting externalResourcesRequired="true" on the outermost 'svg' element on a universal basis. Instead, it is better to specify externalResourcesRequired="true" on those particular graphics elements or container elements which specify need the availability of external resources in order to render properly.

For 'externalResourcesRequired': Animatable: no.

5.10 Common attributes

5.10.1 Attributes common to all elements: 'id' and 'xml:base'

The 'id' and 'xml:base' attributes are available on all SVG elements:

Attribute definitions:

id = "name"
Standard XML attribute for assigning a unique name to an element. Refer to the "Extensible Markup Language (XML) 1.0" Recommendation [XML10].
Animatable: no.
xml:base = "<uri>"
Specifies a base URI other than the base URI of the document or external entity. Refer to the "XML Base" specification [XML-BASE].
Animatable: no.

5.10.2 The 'xml:lang' and 'xml:space' attributes

Elements that might contain character data content have attributes 'xml:lang' and 'xml:space:

<!ENTITY % SVG.id.attrib
    "id ID #IMPLIED"
>
<!ENTITY % SVG.base.attrib
    "xml:base %URI.datatype; #IMPLIED"
>
<!ENTITY % SVG.lang.attrib
    "xml:lang %LanguageCode.datatype; #IMPLIED"
>
<!ENTITY % SVG.space.attrib
    "xml:space ( default | preserve ) #IMPLIED"
>
<!ENTITY % SVG.Core.extra.attrib "" >
<!ENTITY % SVG.Core.attrib
    "%SVG.id.attrib;
     %SVG.base.attrib;
     %SVG.lang.attrib;
     %SVG.space.attrib;
     %SVG.Core.extra.attrib;"
>

'.

Attribute definitions:

xml:lang = "languageID"
Standard XML attribute to specify the language (e.g., English) used in the contents and attribute values of particular elements. Refer to the "Extensible Markup Language (XML) 1.0" Recommendation [XML10].
Animatable: no.
xml:space = "{default | preserve}"
Standard XML attribute to specify whether white space is preserved in character data. The only possible values are 'default' and 'preserve'. Refer to the "Extensible Markup Language (XML) 1.0" Recommendation [XML10] and to the discussion white space handling in SVG.
Animatable: no.

5.11

Core Attribute Module

The Core Attribute Module defines the attribute set Core.attrib that is the core set of attributes that can be present on any element.

Collection NameAttributes in Collection
Core.attribid, xml:base, xml:lang, xml:space
5.12 Structure Module
ElementsAttributesContent Model
svgCore.attrib, Conditional.attrib, Style.attrib, x, y, width, height, viewBox, preserveAspectRatio, zoomAndPan, version, baseProfile, contentScriptType, contentStyleType, External.attrib, Presentation.attrib, GraphicalEvents.attrib, DocumentEvents.attrib(Description.class | Structure.class | Shape.class | Image.class | View.class | Conditional.class | Hyperlink.class | Text.class | Script.class | Style.class | Marker.class | Clip.class | Mask.class | Gradient.class | Pattern.class | Filter.class | Cursor.class | Font.class | Animation.class | ColorProfile.class)*
gCore.attrib, Conditional.attrib, Style.attrib, External.attrib, Presentation.attrib, GraphicalEvents.attrib, transform(Description.class | Structure.class | Shape.class | Image.class | View.class | Conditional.class | Hyperlink.class | Text.class | Script.class | Style.class | Marker.class | Clip.class | Mask.class | Gradient.class | Pattern.class | Filter.class | Cursor.class | Font.class | Animation.class | ColorProfile.class)*
defsCore.attrib, Conditional.attrib, Style.attrib, External.attrib, Presentation.attrib, GraphicalEvents.attrib, transform(Description.class | Structure.class | Shape.class | Image.class | View.class | Conditional.class | Hyperlink.class | Text.class | Script.class | Style.class | Marker.class | Clip.class | Mask.class | Gradient.class | Pattern.class | Filter.class | Cursor.class | Font.class | Animation.class | ColorProfile.class)*
descCore.attrib, Style.attrib(PCDATA)*
titleCore.attrib, Style.attrib(PCDATA)*
metadataCore.attrib(PCDATA)*
symbolCore.attrib, Style.attrib, External.attrib, viewBox, preserveAspectRatio, Presentation.attrib, GraphicsElementEventAttrs(Description.class | Structure.class | Shape.class | Image.class | View.class | Conditional.class | Hyperlink.class | Text.class | Script.class | Style.class | Marker.class | Clip.class | Mask.class | Gradient.class | Pattern.class | Filter.class | Cursor.class | Font.class | Animation.class | ColorProfile.class)*
useCore.attrib, Style.attrib, Conditional.attrib, transform, x, y, width, height, XLinkEmbed.attrib, Presentation.attrib, GraphicsElementEventAttrs(Description.class | Animation.class)*
5.12.1 Structure Content Sets

The Structure Module defines the Description.class, Structure.class and Use.class content sets.

Content Set NameElements in Content Set
Description.classdesc, title, metadata
Use.classuse
Structure.classsvg, g, defs, symbol, Use.class
5.13 Basic Structure Module
ElementsAttributesContent Model
svgCore.attrib, Conditional.attrib, Style.attrib, x, y, width, height, viewBox, preserveAspectRatio, zoomAndPan, version, baseProfile, External.attrib, Presentation.attrib, GraphicalEvents.attrib, DocumentEvents.attrib(Description.class | Structure.class | Shape.class | Image.class | View.class | Conditional.class | Hyperlink.class | Text.class | Script.class | Style.class | Marker.class | Clip.class | Mask.class | Gradient.class | Pattern.class | Filter.class | Cursor.class | Font.class | Animation.class | ColorProfile.class)*
gCore.attrib, Conditional.attrib, Style.attrib, External.attrib, Presentation.attrib, GraphicalEvents.attrib, transform(Description.class | Structure.class | Shape.class | Image.class | View.class | Conditional.class | Hyperlink.class | Text.class | Script.class | Style.class | Marker.class | Clip.class | Mask.class | Gradient.class | Pattern.class | Filter.class | Cursor.class | Font.class | Animation.class | ColorProfile.class)*
defsCore.attrib, Conditional.attrib, Style.attrib, External.attrib, Presentation.attrib, GraphicalEvents.attrib, transform(Description.class | Structure.class | Shape.class | Image.class | View.class | Conditional.class | Hyperlink.class | Text.class | Script.class | Style.class | Marker.class | Clip.class | Mask.class | Gradient.class | Pattern.class | Filter.class | Cursor.class | Font.class | Animation.class | ColorProfile.class)*
descCore.attrib, Style.attrib(PCDATA)*
titleCore.attrib, Style.attrib(PCDATA)*
metadataCore.attrib(PCDATA)*
useCore.attrib, Style.attrib, Conditional.attrib, transform, x, y, width, height, XLinkEmbed.attrib, Presentation.attrib, GraphicsElementEventAttrs(Description.class | Animation.class)*
5.13.1 Basic Structure Content Sets

The Basic Structure Module defines the Description.class, Structure.class and Use.class content sets.

Content Set NameElements in Content Set
Description.classdesc, title, metadata
Use.classuse
Structure.classsvg, g, defs, Use.class
5.14 Container Attribute Module

The Container Attribute Module defines the Container.attrib attribute set.

Collection NameAttributes in Collection
Container.attribenable-background
5.15 Conditional Processing Module
ElementsAttributesContent Model
switchCore.attrib, Conditional.attrib, External.attrib, Style.attrib, transform, Presentation.attrib, GraphicalEvents.attrib(Description.class | Shape.class | Text.class | Structure.class | Image.class | Hyperlink.class | Extensibility.class | Animation.class)*
5.15.1 Conditional Processing Content Set

The Conditional Processing Module defines the Conditional.class content set.

Content Set NameElements in Content Set
Conditional.classswitch
5.15.2 Conditional Processing Attribute Set

The Conditional Processing Module defines the Conditional.attrib attribute set.

Collection NameAttributes in Collection
Conditional.attribrequiredFeatures, requiredExtensions, systemLanguage
5.16 Image Module
ElementsAttributesContent Model
imageCore.attrib, XLinkEmbed.attrib, Conditional.attrib, Style.attrib, External.attrib, GraphicalEvents.attrib, preserveAspectRatio, Paint.attrib, Opacity.attrib, Graphics.attrib, Cursor.attrib, Filter.attrib, Mask.attrib, GraphicalEvents.attrib, Clip.attrib, Profile.attrib, Viewport.attrib, transform, x, y, width, height(Description.class | Animation.class)*
5.16.1 Image Content Set

The Image Module defines the Image.class content set.

Content Set NameElements in Content Set
Image.classimage
5.17 DOM interfaces

The following interfaces are defined below: SVGDocument, SVGSVGElement, SVGGElement, SVGDefsElement, SVGDescElement, SVGTitleElement, SVGSymbolElement, SVGUseElement, SVGElementInstance, SVGElementInstanceList, SVGImageElement, SVGSwitchElement, GetSVGDocument.

DOM interfaces

5.11.1 Interface SVGDocument

When an 'svg' element is embedded inline as a component of a document from another namespace, such as when an 'svg' element is embedded inline within an XHTML document [XHTML], then an SVGDocument object will not exist; instead, the root object in the document object hierarchy will be a Document object of a different type, such as an HTMLDocument object.

However, an SVGDocument object will indeed exist when the root element of the XML document hierarchy is an 'svg' element, such as when viewing a stand-alone SVG file (i.e., a file with MIME type "image/svg+xml"). In this case, the SVGDocument object will be the root object of the document object model hierarchy.

In the case where an SVG document is embedded by reference, such as when an XHTML document has an 'object' element whose 'href' attribute references an SVG document (i.e., a document whose MIME type is "image/svg+xml" and whose root element is thus an 'svg' element), there will exist two distinct DOM hierarchies. The first DOM hierarchy will be for the referencing document (e.g., an XHTML document). The second DOM hierarchy will be for the referenced SVG document. In this second DOM hierarchy, the root object of the document object model hierarchy is an SVGDocument object.

The SVGDocument interface contains a similar list of attributes and methods to the HTMLDocument interface described in the Document Object Model (HTML) Level 1 chapter of the [DOM1] specification.

IDL Definition
interface SVGDocument : Document,
                
Document,
        
events::
DocumentEvent {
  
readonly attribute DOMString 
title;
  readonly attribute DOMString 
referrer;
  readonly attribute DOMString 
domain;
  readonly attribute DOMString 
URL;
  readonly attribute SVGSVGElement rootElement;
};
Attributes:
title (readonly DOMString
title
)
The title of a document as specified by the 'title' sub-element of the 'svg' root element (i.e., <svg><title>Here is the title</title>...</svg>)
referrer (readonly DOMString
referrer
)
Returns the URI of the page that linked to this page. The value is an empty string if the user navigated to the page directly (not through a link, but, for example, via a bookmark).
domain (readonly DOMString
domain
)
The domain name of the server that served the document, or a null string if the server cannot be identified by a domain name.
URL (readonly DOMString
URL
)
The complete URI of the document.
rootElement (readonly SVGSVGElement
rootElement
)
The root 'svg'
element
in the document hierarchy.

5.11.2 Interface SVGSVGElement

A key interface definition is the SVGSVGElement interface, which is the interface that corresponds to the 'svg' element. This interface contains various miscellaneous commonly-used utility methods, such as matrix operations and the ability to control the time of redraw on visual rendering devices.

SVGSVGElement extends ViewCSS and DocumentCSS to provide access to the computed values of properties and the override style sheet as described in DOM2.

IDL Definition

DOM Level 2 Style [DOM2STYLE].

interface SVGSVGElement : SVGElement,
                
SVGElement,
          SVGTests,
      
SVGTests,
                    SVGLangSpace,
                
SVGExternalResourcesRequired,
          SVGExternalResourcesRequired,
      
SVGStylable,
                 
SVGLocatable
   SVGStylable,
                
SVGFitToViewBox,
          SVGLocatable,
      
SVGZoomAndPan,
                 
events::EventTarget
   SVGFitToViewBox,
                
events::DocumentEvent,
          SVGZoomAndPan,
      
css::ViewCSS,
                 
css::DocumentCSS
 
{
  EventTarget,
 
readonly
 
attribute
 
SVGAnimatedLength
 
x;
   
readonly
 
attribute
 
SVGAnimatedLength
 
y;
   
readonly
 
attribute
 
SVGAnimatedLength
 
width;
   
readonly
 
attribute
 
SVGAnimatedLength
 
height;
    DocumentEvent,
       
attribute
 
DOMString
         
contentScriptType;
         ViewCSS,
              
//
 
raises
 
DOMException
 
on
 
setting
        DocumentCSS {

 
attribute
 
DOMString
readonly attribute SVGAnimatedLength x;
  readonly attribute SVGAnimatedLength 
contentStyleType
y;
  readonly attribute SVGAnimatedLength width;
  readonly attribute SVGAnimatedLength height;
           
//
attribute 
raises
DOMString contentScriptType setraises(DOMException);

on
 
setting
   
readonly
 
attribute
 
SVGRect
     attribute DOMString contentStyleType setraises(DOMException);
  readonly attribute SVGRect viewport;
  readonly attribute float pixelUnitToMillimeterX;
  readonly attribute float pixelUnitToMillimeterY;
  readonly attribute float screenPixelToMillimeterX;
  readonly attribute float screenPixelToMillimeterY;
           attribute boolean useCurrentView
; // raises DOMException on setting
 setraises(DOMException);
  readonly attribute SVGViewSpec currentView;
           attribute float currentScale
; // raises DOMException on setting
 setraises(DOMException);
  readonly attribute SVGPoint currentTranslate;

  unsigned long suspendRedraw
(
in unsigned long max_wait_milliseconds
);
  void 
unsuspendRedraw
(
in unsigned long suspend_handle_id
) 
raises(
DOMException
);
  void 
unsuspendRedrawAll
(
);
  void 
forceRedraw
(
);
  void 
pauseAnimations
(
);
  void 
unpauseAnimations
(
);
  boolean 
animationsPaused
(
);
  float 
getCurrentTime
(
);
  void 
setCurrentTime
(
in float seconds
);
  NodeList 
getIntersectionList
(
in SVGRect rect, in SVGElement referenceElement
);
  NodeList 
getEnclosureList
(
in SVGRect rect, in SVGElement referenceElement
);
  boolean 
checkIntersection
(
in SVGElement element, in SVGRect rect
);
  boolean 
checkEnclosure
(
in SVGElement element, in SVGRect rect
);
  void 
deselectAll
(
);
  SVGNumber 
createSVGNumber
(
);
  SVGLength 
createSVGLength
(
);
  SVGAngle 
createSVGAngle
(
);
  SVGPoint 
createSVGPoint
(
);
  SVGMatrix 
createSVGMatrix
(
);
  SVGRect 
createSVGRect
(
);
  SVGTransform 
createSVGTransform
(
);
  SVGTransform 
createSVGTransformFromMatrix
(
in SVGMatrix matrix
);
  Element 
getElementById
(
in DOMString elementId
);
};
Attributes:
x (readonly SVGAnimatedLength
x
)
Corresponds to attribute 'x' on the given 'svg' element.
y (readonly SVGAnimatedLength
y
)
Corresponds to attribute 'y' on the given 'svg' element.
width (readonly SVGAnimatedLength
width
)
Corresponds to attribute 'width' on the given 'svg' element.
height (readonly SVGAnimatedLength
height
)
Corresponds to attribute 'height' on the given 'svg' element.
contentScriptType (DOMString
contentScriptType
)
Corresponds to attribute 'contentScriptType' on the given 'svg' element.
Exceptions on setting
DOMException
NO
, code NOT_
MODIFICATION
SUPPORTED_
ALLOWED_
ERR
:
Raised on an attempt to change the value of a readonly attribute.
contentStyleType (DOMString
contentStyleType
)
Corresponds to attribute 'contentStyleType' on the given 'svg' element.
Exceptions on setting
DOMException
NO
, code NOT_
MODIFICATION
SUPPORTED_
ALLOWED_
ERR
:
Raised on an attempt to change the value of a readonly attribute.
viewport (readonly SVGRect
viewport
)

The position and size of the viewport (implicit or explicit) that corresponds to this 'svg' element. When the user agent is actually rendering the content, then the position and size values represent the actual values when rendering. The position and size values are unitless values in the coordinate system of the parent element. If no parent element exists (i.e., 'svg' element represents the root of the document tree), if this SVG document is embedded as part of another document (e.g., via the HTML 'object' element), then the position and size are unitless values in the coordinate system of the parent document. (If the parent uses CSS or XSL layout, then unitless values represent pixel units for the current CSS or XSL viewport, as described in the

CSS2

CSS 2 specification.) If the parent element does not have a coordinate system, then the user agent should provide reasonable default values for this attribute.

The object itself and its contents are both readonly.

pixelUnitToMillimeterX (readonly float
pixelUnitToMillimeterX
)
Size of a pixel units (as defined by
CSS2
CSS 2) along the x-axis of the viewport, which represents a unit somewhere in the range of 70dpi to 120dpi, and, on systems that support this, might actually match the characteristics of the target medium. On systems where it is impossible to know the size of a pixel, a suitable default pixel size is provided.
pixelUnitToMillimeterY (readonly float
pixelUnitToMillimeterY
)
Corresponding size of a pixel unit along the y-axis of the viewport.
screenPixelToMillimeterX (readonly float
screenPixelToMillimeterX
)
User interface (UI) events in DOM Level 2 indicate the screen positions at which the given UI event occurred. When the user agent actually knows the physical size of a "screen unit", this attribute will express that information; otherwise, user agents will provide a suitable default value such as .28mm.
screenPixelToMillimeterY (readonly float
screenPixelToMillimeterY
)
Corresponding size of a screen pixel along the y-axis of the viewport.
useCurrentView (boolean
useCurrentView
)
The initial view (i.e., before magnification and panning) of the current innermost SVG document fragment can be either the "standard" view (i.e., based on attributes on the 'svg' element such as
fitBoxToViewport
'viewBox') or to a "custom" view (i.e., a hyperlink into a particular 'view' or other element - see Linking into SVG content: URI fragments and SVG views). If the initial view is the "standard" view, then this attribute is false. If the initial view is a "custom" view, then this attribute is true.
Exceptions on setting
DOMException, code NO_MODIFICATION_ALLOWED_ERR
:
Raised on an attempt to change the value of a readonly attribute.
currentView (readonly SVGViewSpec
currentView
)

The definition of the initial view (i.e., before magnification and panning) of the current innermost SVG document fragment. The meaning depends on the situation:

The object itself and its contents are both readonly.

currentScale (float
currentScale
)
This attribute indicates the current scale factor relative to the initial view to take into account user magnification and panning operations, as described under Magnification and panning. DOM attributes currentScale and currentTranslate are equivalent to the 2x3 matrix [
a b c d e f
a b c d e f] = [
currentScale 0 0 currentScale currentTranslate.x currentTranslate
currentScale 0 0 currentScale currentTranslate.x currentTranslate.y]. If "magnification" is enabled (i.e., zoomAndPan="magnify"), then the effect is as if an extra transformation were placed at the outermost level on the SVG document fragment (i.e., outside the outermost 'svg' element).
Exceptions on setting
DOMException, code NO_MODIFICATION_ALLOWED_ERR
:
Raised on an attempt to change the value of a readonly attribute.
currentTranslate (readonly SVGPoint
currentTranslate
)
The corresponding translation factor that takes into account user "magnification".
Methods
suspendRedraw
Operations:
unsigned long suspendRedraw(in unsigned long max_wait_milliseconds)
Takes a time-out value which indicates that redraw shall not occur until: (a) the corresponding unsuspendRedraw(suspend_handle_id) call has been made, (b) an unsuspendRedrawAll() call has been made, or (c) its timer has timed out. In environments that do not support interactivity (e.g., print media), then redraw shall not be suspended. suspend_handle_id = suspendRedraw(max_wait_milliseconds) and unsuspendRedraw(suspend_handle_id) must be packaged as balanced pairs. When you want to suspend redraw actions as a collection of SVG DOM changes occur, then precede the changes to the SVG DOM with a method call similar to suspend_handle_id = suspendRedraw(max_wait_milliseconds) and follow the changes with a method call similar to unsuspendRedraw(suspend_handle_id). Note that multiple suspendRedraw calls can be used at once and that each such method call is treated independently of the other suspendRedraw method calls.
Parameters
in unsigned long
  1. unsigned long max_wait_milliseconds
    The amount of time in milliseconds to hold off before redrawing the device. Values greater than 60 seconds will be truncated down to 60 seconds.
Return value
Returns
A number which acts as a unique identifier for the given suspendRedraw() call. This value must be passed as the parameter to the corresponding unsuspendRedraw() method call.
No Exceptions
unsuspendRedraw
void unsuspendRedraw(in unsigned long suspend_handle_id)
Cancels a specified suspendRedraw() by providing a unique suspend_handle_id.
Parameters
in
  1. unsigned long suspend_handle_id
    A number which acts as a unique identifier for the desired suspendRedraw() call. The number supplied must be a value returned from a previous call to suspendRedraw()
No Return Value
Exceptions
DOMException, code NOT_FOUND_ERR
This method will raise a DOMException with value NOT_FOUND_ERR if an invalid value (i.e., no such suspend_handle_id is active) for suspend_handle_id is provided.
void unsuspendRedrawAll()
Cancels all currently active suspendRedraw() method calls. This method is most useful at the very end of a set of SVG DOM calls to ensure that all pending suspendRedraw() method calls have been cancelled.
No Parameters
No Return Value
No Exceptions
forceRedraw
void forceRedraw()
In rendering environments supporting interactivity, forces the user agent to immediately redraw all regions of the viewport that require updating.
No Parameters
No Return Value
No Exceptions
pauseAnimations
void pauseAnimations()
Suspends (i.e., pauses) all currently running animations that are defined within the SVG document fragment corresponding to this 'svg' element, causing the animation clock corresponding to this document fragment to stand still until it is unpaused.
No Parameters
No Return Value
No Exceptions
unpauseAnimations
void unpauseAnimations()
Unsuspends (i.e., unpauses) currently running animations that are defined within the SVG document fragment, causing the animation clock to continue from the time at which it was suspended.
No Parameters
No Return Value
No Exceptions
animationsPaused
Return value
boolean
boolean animationsPaused()
Returns true if this SVG document fragment is in a paused state.
No Parameters
Returns
Boolean indicating whether this SVG document fragment is in a paused state.
No Exceptions
float getCurrentTime()
Returns the current time in seconds relative to the start time for the current SVG document fragment.
No Parameters
Return value
float
Returns
The current time in seconds.
No Exceptions
setCurrentTime
void setCurrentTime(in float seconds)
Adjusts the clock for this SVG document fragment, establishing a new current time.
Parameters
in
  1. float seconds
    The new current time in seconds relative to the start time for the current SVG document fragment.
No Return Value
No Exceptions
getIntersectionList
NodeList getIntersectionList(in SVGRect rect, in SVGElement referenceElement)
Returns the list of graphics elements whose rendered content intersects the supplied rectangle, honoring the 'pointer-events' property value on each candidate graphics element.
Parameters
in
  1. SVGRect rect
    The test rectangle. The values are in the initial coordinate system for the current 'svg' element.
in NodeList
  1. SVGElement referenceElement
    If not null, then only return elements whose drawing order has them below the given reference element.
Return value
Returns
A list of Elements whose content intersects the supplied rectangle.
No Exceptions
getEnclosureList
NodeList getEnclosureList(in SVGRect rect, in SVGElement referenceElement)
Returns the list of graphics elements whose rendered content is entirely contained within the supplied rectangle, honoring the 'pointer-events' property value on each candidate graphics element.
Parameters
in
  1. SVGRect rect
    The test rectangle. The values are in the initial coordinate system for the current 'svg' element.
in NodeList
  1. SVGElement referenceElement
    If not null, then only return elements whose drawing order has them below the given reference element.
Return value
Returns
A list of Elements whose content is enclosed by the supplied rectangle.
No Exceptions
checkIntersection
boolean checkIntersection(in SVGElement element, in SVGRect rect)
Returns true if the rendered content of the given element intersects the supplied rectangle, honoring the 'pointer-events' property value on each candidate graphics element.
Parameters
in
  1. SVGElement element
    The element on which to perform the given test.
in boolean
  1. SVGRect rect
    The test rectangle. The values are in the initial coordinate system for the current 'svg' element.
Return value
Returns
True or false, depending on whether the given element intersects the supplied rectangle.
No Exceptions
checkEnclosure
boolean checkEnclosure(in SVGElement element, in SVGRect rect)
Returns true if the rendered content of the given element is entirely contained within the supplied rectangle, honoring the 'pointer-events' property value on each candidate graphics element.
Parameters
in
  1. SVGElement element
    The element on which to perform the given test.
in boolean
  1. SVGRect rect
    The test rectangle. The values are in the initial coordinate system for the current 'svg' element.
Return value
Returns
True or false, depending on whether the given element is enclosed by the supplied rectangle.
No Exceptions
void deselectAll()
Unselects any selected objects, including any selections of text strings and type-in bars.
No Parameters
No Return Value
No Exceptions
createSVGNumber
Return value
SVGNumber
SVGNumber createSVGNumber()
Creates an SVGNumber object outside of any document trees. The object is initialized to a value of zero.
No Parameters
Returns
An SVGNumber object.
No Exceptions
Return value
SVGLength
SVGLength createSVGLength()
Creates an SVGLength object outside of any document trees. The object is initialized to the value of 0 user units.
No Parameters
Returns
An SVGLength object.
No Exceptions
Return value
SVGAngle
SVGAngle createSVGAngle()
Creates an SVGAngle object outside of any document trees. The object is initialized to the value 0 degrees (unitless).
No Parameters
Returns
An SVGAngle object.
No Exceptions
Return value
SVGPoint
SVGPoint createSVGPoint()
Creates an SVGPoint object outside of any document trees. The object is initialized to the point (0,0) in the user coordinate system.
No Parameters
Returns
An SVGPoint object.
No Exceptions
Return value
SVGMatrix
SVGMatrix createSVGMatrix()
Creates an SVGMatrix object outside of any document trees. The object is initialized to the identity matrix.
No Parameters
Returns
An SVGMatrix object.
No Exceptions
Return value
SVGRect
SVGRect createSVGRect()
Creates an SVGRect object outside of any document trees. The object is initialized such that all values are set to 0 user units.
No Parameters
Returns
An SVGRect object.
No Exceptions
Return value
SVGTransform
SVGTransform createSVGTransform()
Creates an SVGTransform object outside of any document trees. The object is initialized to an identity matrix transform (SVG_TRANSFORM_MATRIX).
No Parameters
Returns
An SVGTransform object.
No Exceptions
createSVGTransformFromMatrix
SVGTransform createSVGTransformFromMatrix(in SVGMatrix matrix)
Creates an SVGTransform object outside of any document trees. The object is initialized to the given matrix transform (i.e., SVG_TRANSFORM_MATRIX).
Parameters
in SVGTransform
  1. SVGMatrix matrix
    The transform matrix.
Return value
Returns
An SVGTransform object.
No Exceptions
getElementById
Element getElementById(in DOMString elementId)
Searches this SVG document fragment (i.e., the search is restricted to a subset of the document tree) for an Element whose id is given by elementId. If an Element is found, that Element is returned. If no such element exists, returns null. Behavior is not defined if more than one element has this id.
Parameters
in Element
  1. DOMString elementId
    The unique id value for an element.
Return value
Returns
The matching element.
No Exceptions

5.11.3 Interface SVGGElement

The SVGGElement SVGSVGElement interface corresponds to the 'g' element. IDL Definition
interface SVGGElement : SVGElement,
                
SVGElement,
        SVGTests,
        
SVGTests,
                
SVGLangSpace,
                        SVGExternalResourcesRequired,
                        SVGStylable,
                        SVGTransformable,
                
events::
        EventTarget {
};

5.11.4 Interface SVGDefsElement

The SVGDefsElement interface corresponds to the 'defs' element. IDL Definition
interface SVGDefsElement : SVGElement,
                
SVGElement,
           SVGTests,
     
SVGTests,
                      SVGLangSpace,
                           SVGExternalResourcesRequired,
                           SVGStylable,
                           SVGTransformable,
                
events::
           EventTarget {
};

5.11.5 Interface SVGDescElement

The SVGDescElement interface corresponds to the 'desc' element. IDL Definition
interface SVGDescElement : SVGElement,
                
SVGElement,
           SVGLangSpace,
     
SVGLangSpace,
                      SVGStylable {
};

5.11.6 Interface SVGTitleElement

The SVGTitleElement interface corresponds to the 'title' element. IDL Definition
interface SVGTitleElement : SVGElement,
                
SVGElement,
            SVGLangSpace,
    
SVGLangSpace,
                        SVGStylable {
};

5.11.7 Interface SVGSymbolElement

The SVGSymbolElement interface corresponds to the 'symbol' element. IDL Definition
interface SVGSymbolElement : SVGElement,
                
SVGElement,
             SVGLangSpace,
   
SVGLangSpace,
                          SVGExternalResourcesRequired,
                             SVGStylable,
                             SVGFitToViewBox,
                
events::
             EventTarget {
};

5.11.8 Interface SVGUseElement

The SVGUseElement interface corresponds to the 'use' element. IDL Definition
interface SVGUseElement : SVGElement,
                
SVGElement,
          SVGURIReference,
      
SVGURIReference,
                    SVGTests,
                          SVGLangSpace,
                          SVGExternalResourcesRequired,
                          SVGStylable,
                          SVGTransformable,
                
events::
          EventTarget {
  
readonly attribute SVGAnimatedLength 
x;
  readonly attribute SVGAnimatedLength 
y;
  readonly attribute SVGAnimatedLength 
width;
  readonly attribute SVGAnimatedLength 
height;
  readonly attribute SVGElementInstance instanceRoot;
  readonly attribute SVGElementInstance animatedInstanceRoot;
};
Attributes:
x (readonly SVGAnimatedLength
x
)
Corresponds to attribute 'x' on the given 'use' element.
y (readonly SVGAnimatedLength
y
)
Corresponds to attribute 'y' on the given 'use' element.
width (readonly SVGAnimatedLength
width
)
Corresponds to attribute 'width' on the given 'use' element.
height (readonly SVGAnimatedLength
height
)
Corresponds to attribute 'height' on the given 'use' element.
instanceRoot (readonly SVGElementInstance
instanceRoot
)
The root of the "instance tree". See description of SVGElementInstance for a discussion on the instance tree.
animatedInstanceRoot (readonly SVGElementInstance
animatedInstanceRoot
)
If the 'xlink:href' attribute is being animated, contains the current animated root of the "instance tree". If the 'xlink:href' attribute is not currently being animated, contains the same value as
'
instanceRoot
'
.
The root of the "instance tree".
See description of SVGElementInstance for a discussion on the instance tree.

5.11.9 Interface SVGElementInstance

For each 'use' element, the SVG DOM maintains a shadow tree (the "instance tree") of objects of type SVGElementInstance. A An SVGElementInstance represents a single node in the instance tree. The root object in the instance tree is pointed to by the instanceRoot attribute on the SVGUseElement object for the corresponding 'use' element.

If the 'use' element references a simple graphics element such as a 'rect', then there is only a single SVGElementInstance object, and the correspondingElement attribute on this SVGElementInstance object is the SVGRectElement that corresponds to the referenced 'rect' element.

If the 'use' element references a 'g' which contains two 'rect' elements, then the instance tree contains three SVGElementInstance objects, a root SVGElementInstance object whose correspondingElement is the SVGGElement object for the 'g', and then two child SVGElementInstance objects, each of which has its correspondingElement that is an SVGRectElement object.

If the referenced object is itself a 'use', or if there are 'use' subelements within the referenced object, the instance tree will contain recursive expansion of the indirect references to form a complete tree. For example, if a 'use' element references a 'g', and the 'g' itself contains a 'use', and that 'use' references a 'rect', then the instance tree for the original (outermost) 'use' will consist of a hierarchy of SVGElementInstance objects, as follows:


SVGElementInstance #1 (parentNode=null, firstChild=#2, correspondingElement is the 'g')
  SVGElementInstance #2 (parentNode=#1, firstChild=#3, correspondingElement is the other 'use')
    SVGElementInstance #3 (parentNode=#2, firstChild=null, correspondingcorrespondingElement Element is the 'rect')
IDL Definition
interface SVGElementInstance : 
events::
EventTarget {
  
readonly attribute SVGElement correspondingElement;
  readonly attribute SVGUseElement correspondingUseElement;
  readonly attribute SVGElementInstance parentNode;
  readonly attribute SVGElementInstanceList childNodes;
  readonly attribute SVGElementInstance firstChild;
  readonly attribute SVGElementInstance lastChild;
  readonly attribute SVGElementInstance previousSibling;
  readonly attribute SVGElementInstance nextSibling;
};
Attributes:
correspondingElement (readonly SVGElement
correspondingElement
)
The corresponding element to which this object is an instance. For example, if a 'use' element references a 'rect' element, then an SVGElementInstance is created, with its correspondingElement being the SVGElementInstance object for the 'rect' element.
correspondingUseElement (readonly SVGUseElement
correspondingUseElement
)
The corresponding 'use' element to which this SVGElementInstance object belongs. When 'use' elements are nested (e.g., a 'use' references another 'use' which references a graphics element such as a 'rect'), then the correspondingUseElement is the outermost 'use' (i.e., the one which indirectly references the 'rect', not the one with the direct reference).
parentNode (readonly SVGElementInstance
parentNode
)
The parent of this SVGElementInstance within the instance tree. All SVGElementInstance objects have a parent except the SVGElementInstance which corresponds to the element which was directly referenced by the 'use' element, in which case parentNode is null.
childNodes (readonly SVGElementInstanceList
childNodes
)
An SVGElementInstanceList that contains all children of this SVGElementInstance within the instance tree. If there are no children, this is an SVGElementInstanceList containing no entries (i.e., an empty list).
firstChild (readonly SVGElementInstance
firstChild
)
The first child of this SVGElementInstance within the instance tree. If there is no such SVGElementInstance, this returns null.
lastChild (readonly SVGElementInstance
lastChild
)
The last child of this SVGElementInstance within the instance tree. If there is no such SVGElementInstance, this returns null.
previousSibling (readonly SVGElementInstance
previousSibling
)
The SVGElementInstance immediately preceding this SVGElementInstance. If there is no such SVGElementInstance, this returns null.
nextSibling (readonly SVGElementInstance
nextSibling
)
The SVGElementInstance immediately following this SVGElementInstance. If there is no such SVGElementInstance, this returns null.

5.11.10 Interface SVGElementInstanceList

The SVGElementInstanceList interface provides the abstraction of an ordered collection of SVGElementInstance objects, without defining or constraining how this collection is implemented. IDL Definition
interface SVGElementInstanceList {

  readonly attribute unsigned long length;

  SVGElementInstance item
(
in unsigned long index
);
};
Attributes:
length (readonly unsigned long
length
)
The number of SVGElementInstance objects in the list. The range of valid child indices is 0 to length
-1
−1 inclusive.
Methods
item
Operations:
SVGElementInstance item(in unsigned long index)
Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.
Parameters
in SVGElementInstance
  1. unsigned long index
    Index into the collection.
Return value
Returns
The SVGElementInstance object at the indexth position in the SVGElementInstanceList, or null if that is not a valid index.
No Exceptions

5.11.11 Interface SVGImageElement

The SVGImageElement interface corresponds to the 'image' element. IDL Definition
interface SVGImageElement : SVGElement,
                
SVGElement,
            SVGURIReference,
    
SVGURIReference,
                        SVGTests,
                            SVGLangSpace,
                            SVGExternalResourcesRequired,
                            SVGStylable,
                            SVGTransformable,
                
events::
            EventTarget {
  
readonly attribute SVGAnimatedLength x;
  readonly attribute SVGAnimatedLength y;
  readonly attribute SVGAnimatedLength width;
  readonly attribute SVGAnimatedLength height;
  readonly attribute SVGAnimatedPreserveAspectRatio preserveAspectRatio;
};
Attributes:
x (readonly SVGAnimatedLength
x
)
Corresponds to attribute 'x' on the given 'image' element.
y (readonly SVGAnimatedLength
y
)
Corresponds to attribute 'y' on the given 'image' element.
width (readonly SVGAnimatedLength
width
)
Corresponds to attribute 'width' on the given 'image' element.
height (readonly SVGAnimatedLength
height
)
Corresponds to attribute 'height' on the given 'image' element.
preserveAspectRatio (readonly SVGAnimatedPreserveAspectRatio
preserveAspectRatio
)
Corresponds to attribute 'preserveAspectRatio' on the given 'image' element.

5.11.12 Interface SVGSwitchElement

The SVGSwitchElement interface corresponds to the 'switch' element. IDL Definition
interface SVGSwitchElement : SVGElement,
                
SVGElement,
             SVGTests,
   
SVGTests,
                          SVGLangSpace,
                             SVGExternalResourcesRequired,
                             SVGStylable,
                             SVGTransformable,
                
events::
             EventTarget {
};

5.11.13 Interface GetSVGDocument

In the case where an SVG document is embedded by reference, such as when an XHTML document has an 'object' element whose 'href' (or equivalent) attribute references an SVG document (i.e., a document whose MIME type is "image/svg+xml" and whose root element is thus an 'svg' element), the SVG user agent is required to implement the GetSVGDocument interface for the element which references the SVG document (e.g., the HTML 'object' or comparable referencing elements). IDL Definition
interface GetSVGDocument {
  
SVGDocument getSVGDocument
(
) 
raises(
DOMException
);
};
Methods
getSVGDocument
Return value
SVGDocument
Operations:
SVGDocument getSVGDocument()
Returns the SVGDocument object for the referenced SVG document.
No Parameters
Returns
The SVGDocument object for the referenced SVG document.
Exceptions
DOMException, code NOT_SUPPORTED_ERR
:
No SVGDocument object is available.
SVG 1.1 (Second Edition) – 16 May 2009