SVG Tiny 1.2 - 20060721

A The SVG Micro DOM (uDOM)

Contents

During the later stages of the SVG Mobile 1.1 specification it became obvious that there was a requirement to subset the SVG and XML DOM in order to reduce the burden on implementations. SVGT 1.2 adds new features to the uDOM, allowing for as much necessary functionality as possible, still being suitable for SVG Tiny implementations.

Furthermore, it should be possible to implement the uDOM on devices that support SVG Tiny 1.1 although, in this case, the scripting would be external to the SVG document (since SVG Tiny 1.1 does not support inline scripting).

The goal of the uDOM definition is to provide an API that allows access to initial and computed attribute and property values, to reduce the number of interfaces compared to the traditional SVG DOM, to reduce run-time memory footprint using necessary features of the core XML DOM, as well as the most useful SVG features (such as transformation matrices). A subset of the uDOM (corresponding to SVG Tiny 1.1) is already successfully implemented by various implementations of JSR-226. One goal of the uDOM is to keep compatibility with the JSR-226 uDOM subset.

The IDL definition for the uDOM is provided.

A.1 Introduction

This appendix consists of the following parts:

A.2 Overview of the SVG uDOM

The following sections provides an informative overview of the SVG uDOM's key features and constraints.

Note: Like other W3C DOM definitions, the SVG uDOM is programming-language independent. Although this appendix only contain ECMAScript and Javatm language examples, the SVG uDOM is compatible with other programming languages.

A.2.1 Document Access

The SVG uDOM offers access to a Document object which is the root for accessing other features. The way the Document object becomes available depends on the usage context. One way to gain access to the Document object is to implement the EventListenerInitializer2 interface. The SVG Tiny user agent will invoke the implementation's initializeEventListeners method once the programming logic has been loaded and is ready to bind to the document. The Document object is sometimes accessible through other means, for example as the global document variable in ECMAScript.

A.2.2 Tree Navigation

SVG uDOM only allows navigation of the element nodes in the DOM tree. Two options are available for navigating the hierarchy of elements:

The ElementTraversal interface provides firstElementChild, lastElementChild, previousElementSibling and nextElementSibling, which are particularly suitable for constrained devices. These traversal mechanisms skip over intervening nodes between element nodes, such as text nodes which might only contain spaces, tabs and newlines.

A.2.3 Element Creation

SVG uDOM allows creation of new Elements.

Example: Element creation (Java)
String svgNS = "http://www.w3.org/2000/svg";
Element myRect = document.createElementNS(svgNS, "rect");

A.2.4 Element Insertion

Element insertion is the ability to insert new elements to a document tree.

SVG uDOM allows the insertion of an Element.

Example: Element insertion (ECMAScript)
var svgNS = "http://www.w3.org/2000/svg";
// Create a new <rect> element
var myRect = document.createElementNS(svgNS, "rect");
// Set the various <rect> properties before appending
...

// Add element to the root of the document
var svgRoot = document.documentElement;
svgRoot.appendChild(myRect);

// Create a new <ellipse> element
var myEllipse = document.createElementNS(svgNS, "ellipse");

// Set the various <ellipse> properties before insertion
...

// Insert the ellipse before the rectangle
svgRoot.insertBefore(myEllipse, myRect);

A.2.5 Element Removal

Element removal is the ability to remove an element from a document tree. SVG uDOM allows removal of Elements.

Example: Element removal (ECMAScript)
var myRect = ...; // See Element creation
var myGroup = document.getElementById("myGroup");
myGroup.appendChild(myRect);
...
myGroup.removeChild(myRect);

A.2.6 Attribute and Property Access

SVGT 1.2 uDOM supports two ways of accessing XML attributes and CSS properties; the standard way via getAttributeNS and setAttributeNS on the Element interface and via a new concept called Traits.

A trait is the typed value (e.g. a number, not just a string), associated with an element by an XML attribute or a CSS property. The trait facilities in the SVG uDOM allow for strongly-typed access to certain attribute and property values. For example, there is a getFloatTrait(...) method for getting an attribute or property value directly as a float. This contrasts the getAttributeNS method which always returns a string. The trait facilities in the SVG uDOM are available on the TraitAccess interface.

Example: Trait Access (Java)
float width = myRect.getFloatTrait('width');
width += 10;
myRect.setFloatTrait('width', width);

An important difference between getTraitNS (and all other variants of getTrait methods) and getAttributeNS is that getTraitNS returns the computed attribute value but getAttributeNS returns the specified attribute value (which might not exactly match the original specified value due to the possibility of user agent value normalization as described in Attribute Normalization).

Example: Difference between traits and getAttributeNS (Java)
<g fill="red">

<rect id="r1" x="1" y="1" width="5" height="5"/>

<rect id="r2" fill="inherit" x="1" y="1" width="5" height="5"/>

</g>

r1.getTraitNS(null, "fill") returns "red" (or equivalent normalized form, see Attribute/Property Normalization).

r2.getTraitNS(null, "fill") returns "red" (or equivalent normalized form, see Attribute/Property Normalization).

r1.getAttributeNS(null, "fill") returns "".

r2.getAttributeNS(null, "fill") returns "inherit".

A trait may be animated. To access the animated value, use getPresentationTrait.

A.2.7 Event Listener Registration and Removal

Event Listener Registration and Removal is the ability to add and remove new event listeners from a Document. SVG uDOM allows adding and removing EventListeners.

Example: Event Listeners (Java)
class MyEventListener implements EventListener {
    public void handleEvent(Event evt) {
        // Do whatever is needed here
    }
}
...
EventListener l = new MyEventListener();

SVGElement myRect = (SVGElement)document.getElementById("myRect");
//Listen to click events, during the bubbling phase
myRect.addEventListenerNS("http://www.w3.org/2001/xml-events", "click", l, false, null);
...

// Remove the click listener
myRect.removeEventListenerNS("http://www.w3.org/2001/xml-events","click", l, false);

A.2.8 Animation

SVG uDOM allows code to start or end timed elements (i.e. elements implementing SVGTimedElement).

Example: animation (ECMAScript)
var animateColor = document.getElementById("myAnimation");

// Start the animation 2.5 seconds from now.
animateColor.beginElementAt(2.5);

A.2.9 Java package naming

The SVG uDOM will use the same Java package names as the upcoming SVG 1.2 Full DOM (e.g. org.w3c.dom,org.w3c.dom.events, org.w3c.dom.svg). This allows Java applications which restrict themselves to the features in the SVG uDOM to also run in implementations that support the SVG 1.2 Full DOM.

A.3 Conforming to the SVG uDOM

This section and all the following are normative. Conforming SVG User Agents must support all constants, attributes and methods of all the interfaces defined in the SVG uDOM unless an interface explicitly allows for exceptions to this rule.

A.3.1 Attribute/Property Normalization

A viewer implementing the uDOM is allowed to return normalized attribute values (defined in DOM 3) from getAttributeNS and the various getTrait methods (getTrait, getTraitNS, getFloatTrait, ...) and getPresentationTrait methods (getPresentationTrait, getPresentationTraitNS, getFloatPresentationTrait, ...). Following is a list of possible attribute normalizations:

Color normalization
"red" may be returned as "rgb(255,0,0)", "#ff0000", or other semantically identical form.
Out-of-range normalization
Values that are only of relevance within a certain range may be returned as a value clamped to that range. E.g. fill-opacity="1.3" may be returned as "1".
Numerical precision
"3.0" may be returned as "3", "3.00" or other semantically identical form.
Whitespace normalization
" 3.0 " may be returned as "3.0". Whitespace normalization also includes unquoted font names in the css font-family property: Font family names containing whitespace should be quoted. If quoting is omitted, any whitespace characters before and after the font name may be ignored and any sequence of whitespace characters inside the font name may be converted to a single space.
font-weight normalization
"normal" may be returned as "400", "bold" may be returned as "700".
Transform normalization
Any transform value may be returned as the corresponding matrix. E.g. "scale(2,2)" may be returned as "matrix(2,0,0,2,0,0)", and "scale(2,2) translate(10,5) rotate(45)" may be returned as "matrix(1.4142, 1.4142, -2.5857, 1.4142, 20, 10)".
Path normalization
The full set of 'd'/'path' commands may be mapped down on a smaller set of commands.
Display normalization
All possible 'display' values may be mapped to 'none', 'inline' or 'inherit' since they cover all the possible 'display' outputs for a pure SVGT1.2 viewer. E.g. "block" may be returned as "inline". For viewers in multiple namespaces, e.g. a CDF viewer, the different 'display' properties are of importance and therefore an SVGT1.2 viewer intended for use in a multiple namespace environment is strongly recommended to keep the full range of 'display' values.

A.3.2 Text Content Access

In the SVG uDOM, there are two alternative ways to access an element's textual content. Text access via the TraitAccess interface is available on all SVGElements. This was available in the SVG Tiny 1.1 uDOM (used in the JSR-226 specification) and is still available in order to keep backward compability. The SVG Tiny 1.2 uDOM specification introduces the textContent attribute on the Node interface as a more generic text access mechanism.

To access or set the text string value for an element via traits you invoke getTrait() or setTrait() on that element and pass #text as the name of the trait you want to get or set. For example, MyTextElement.setTrait("#text", "Hello"); Text access via the #text mechanism must be supported on Text Content, 'desc', 'title' and 'metadata' elements. Text access to other elements defined within this specification (see list of elements) is not supported and an implementation should ignore any text on these elements.

The result of getting and setting text content via the #text mechanism is exactly the same as when using the textContent attribute. Therefore the user should be aware of the fact that styling by child 'tspan' elements (i.e. 'tspan' elements that are children of the element which text content is retrieved) will be lost if a text string is retrieved from an element and then set back again.

The #text trait is included for compatibility with JSR-226. It is recommended that where compatibility with JSR-226 implementations is not required content developers use textContent instead as it is more generally applicable and supports better compatibility with DOM Level 3 Core [DOM3].

A.4 Module: dom

A.4.1 DOMException

Exceptions as defined by the relevant DOM Level 3 Core section. Note that since the uDOM is a subset of DOM Level 3 Core some of the exception codes defined for this exception may never occur (e.g. INUSE_ATTRIBUTE_ERR, VALIDATION_ERR). However, in the interest of facilitating implementations that support both the uDOM and the complete DOM Level 3 Core none of the exception codes are removed.
IDL Definition
exception DOMException
{
	unsigned short code;
};

// ExceptionCode
const unsigned short      INDEX_SIZE_ERR                 = 1;
const unsigned short      DOMSTRING_SIZE_ERR             = 2;
const unsigned short      HIERARCHY_REQUEST_ERR          = 3;
const unsigned short      WRONG_DOCUMENT_ERR             = 4;
const unsigned short      INVALID_CHARACTER_ERR          = 5;
const unsigned short      NO_DATA_ALLOWED_ERR            = 6;
const unsigned short      NO_MODIFICATION_ALLOWED_ERR    = 7;
const unsigned short      NOT_FOUND_ERR                  = 8;
const unsigned short      NOT_SUPPORTED_ERR              = 9;
const unsigned short      INUSE_ATTRIBUTE_ERR            = 10;
const unsigned short      INVALID_STATE_ERR              = 11;
const unsigned short      SYNTAX_ERR                     = 12;
const unsigned short      INVALID_MODIFICATION_ERR       = 13;
const unsigned short      NAMESPACE_ERR                  = 14;
const unsigned short      INVALID_ACCESS_ERR             = 15;
const unsigned short      VALIDATION_ERR                 = 16;
const unsigned short      TYPE_MISMATCH_ERR              = 17;
Constants
INDEX_SIZE_ERR
See definition
DOMSTRING_SIZE_ERR
See definition
HIERARCHY_REQUEST_ERR
See definition
WRONG_DOCUMENT_ERR
See definition
INVALID_CHARACTER_ERR
See definition
NO_DATA_ALLOWED_ERR
See definition
NO_MODIFICATION_ALLOWED_ERR
See definition
NOT_FOUND_ERR
See definition
NOT_SUPPORTED_ERR
See definition
INUSE_ATTRIBUTE_ERR
See definition
INVALID_STATE_ERR
See definition
SYNTAX_ERR
See definition
INVALID_MODIFICATION_ERR
See definition
NAMESPACE_ERR
See definition
INVALID_ACCESS_ERR
See definition
VALIDATION_ERR
See definition
TYPE_MISMATCH_ERR
See definition
No defined attributes
No defined methods

A.4.2 Node

The Node interface describes generic nodes in an SVG document tree.

This interface is a subset of the Node interface defined in DOM Level 3 Core. Node types that must be supported in the uDOM are Element nodes and Document nodes.

This subset does not support the NodeType and DocumentPosition definition groups, since the nodeType field and the compareDocumentPosition are not members of the subsetted interface.

Concerning textContent, there is no requirement to create a Text node on setting since this subset has no interface representing Text nodes. However, the behaviour of textContent must be as if the Text node described in the the definition of textContent had indeed been created.

An alternate way of accessing text content on elements defined within the SVG specification is via the getTrait("#text") syntax.

IDL Definition
interface Node
{
	readonly attribute DOMString namespaceURI;
	readonly attribute DOMString localName;
	readonly attribute Node parentNode;
	readonly attribute Document ownerDocument;
	attribute DOMString textContent;
	Node appendChild(in Node newChild) 
		raises(DOMException);
	Node insertBefore(in Node newChild, in Node refChild) 
		raises(DOMException);
	Node removeChild(in Node oldChild) 
		raises(DOMException);
	Node cloneNode(in boolean deep);
};
No defined constants
Attributes
namespaceURI
See namespaceURI
localName
See localName
parentNode
See parentNode
ownerDocument
See ownerDocument
textContent
See textContent
Methods
appendChild
See appendChild
insertBefore
See insertBefore
removeChild
See removeChild
cloneNode
See cloneNode

A.4.3 Element

The Element interface describes generic elements in an SVG document tree.

This interface is a subset of the Element interface defined in DOM Level 3 Core.

Concerning setAttributeNS, there is no requirement to take the prefix into account since neither the prefix field nor the Attr interface are supported.

IDL Definition
interface Element : Node
{
	DOMString getAttributeNS(in DOMString namespaceURI, in DOMString localName) 
		raises(DOMException);
	void setAttributeNS(in DOMString namespaceURI, in DOMString qualifiedName, in DOMString value) 
		raises(DOMException);
};
No defined constants
No defined attributes
Methods
getAttributeNS
See getAttributeNS
setAttributeNS
See setAttributeNS

A.4.4 Document

The Document interface represents XML documents.

This interface is a subset of the Document interface defined in DOM Level 3 Core.

IDL Definition
interface Document : Node
{
	readonly attribute DOMImplementation implementation;
	Element createElementNS(in DOMString namespaceURI, in DOMString qualifiedName) 
		raises(DOMException);
	readonly attribute Element documentElement;
	Element getElementById(in DOMString elementId);
};
No defined constants
Attributes
implementation
See implementation
documentElement
See documentElement
Methods
createElementNS
See createElementNS
getElementById
See getElementById

A.4.5 DOMImplementation

The DOMImplementation interface provides methods for performing operations that are independent of any particular instance of the document object model.

This interface is a subset of the DOMImplementation interface defined in DOM Level 3 Core.

IDL Definition
interface DOMImplementation
{
};
No defined constants
No defined attributes
No defined methods

A.5 Module: events

A.5.1 EventTarget

The EventTarget interface is implemented by objects that can notify listeners about events and allows registration and removal of EventListener objects.

This interface is a subset of the EventTarget interface defined in DOM Level 3 Events.

Please note that SVG Tiny 1.2 user-agents are not required to support the capture phase, conformant SVG Tiny 1.2 content must not make use of it. If an attempt to specify event operations on the capture phase is made an SVG Tiny user-agent that does not support it must ignore them as if addEventListener had not been called.

Refer to the DOM Events Level 3 specification or the XML Events specification introduction for an explanation of the SVG event flow and the meaning of event targets, event current target, bubble and capture.

IDL Definition
interface EventTarget
{
	void addEventListener(in DOMString type, in EventListener listener, in boolean useCapture);
	void removeEventListener(in DOMString type, in EventListener listener, in boolean useCapture);
	void addEventListenerNS(in DOMString namespaceURI, in DOMString type, in EventListener listener, 
	                        in boolean useCapture, in DOMObject evtGroup);
	void removeEventListenerNS(in DOMString namespaceURI, in DOMString type, in EventListener listener, 
	                           in boolean useCapture);
};
No defined constants
No defined attributes
Methods
addEventListener
See addEventListener
removeEventListener
See removeEventListener
addEventListenerNS
See addEventListenerNS
removeEventListenerNS
See removeEventListenerNS

A.5.2 EventListener

The EventListener interface is the primary way for handling events. Users implement the it and register their event listener on an EventTarget.

This interface is identical to the EventListener interface defined in DOM Level 3 Events.

IDL Definition
interface EventListener
{
	void handleEvent(in Event evt);
};
No defined constants
No defined attributes
Methods
handleEvent
See handleEvent

A.5.3 Event

The Event interface is used to provide contextual information about an event to the handler processing the event.

This interface is a subset of the Event interface defined in DOM Level 3 Events. This subset does not support the PhaseType definition group.

For a list of supported event types see the Supported Events chapter.

IDL Definition
interface Event
{
	readonly attribute EventTarget target;
	readonly attribute EventTarget currentTarget;
	readonly attribute DOMString type;
	readonly attribute DOMString namespaceURI;
	readonly attribute boolean cancelable;
	readonly attribute boolean defaultPrevented;
	void stopPropagation();
	void preventDefault();
};
No defined constants
Attributes
target
See target
currentTarget
See currentTarget
type
See type
namespaceURI
See namespaceURI
cancelable
See cancelable
defaultPrevented
See defaultPrevented
Methods
stopPropagation
See stopPropagation
preventDefault
See preventDefault

A.5.4 MouseEvent

Event that provides specific contextual information associated with pointing device events.

Event types that are MouseEvents: click, mousedown, mouseup, mouseover, mousemove, mouseout, WheelEvent.

This interface is a subset of the MouseEvent interface defined in DOM Level 3 Events.

IDL Definition
interface MouseEvent : UIEvent
{
	readonly attribute long screenX;
	readonly attribute long screenY;
	readonly attribute long clientX;
	readonly attribute long clientY;
	readonly attribute unsigned short button;
};
No defined constants
Attributes
screenX
See screenX
screenY
See screenY
clientX
See clientX
clientY
See clientY
button
See button
No defined methods

A.5.5 WheelEvent

Many devices today have a rotational input method, such as the wheel on a mouse or the "jog dial" of a phone or PDA.

The SVGMousewheel event is triggered when the user rotates the rotational input device. Listeners for this event may only be attached to the Element node that is the Document node's documentElement. If a listener for this event is attached to another node in the document, the user agent must not trigger it when the event occurs.

Event type that is a WheelEvent: SVGMousewheel.

IDL Definition
interface WheelEvent : MouseEvent
{
	readonly attribute long wheelDelta;
};
No defined constants
Attributes
wheelDelta
Indicates the number of "clicks" the wheel has been rotated. A positive value indicates that the wheel has been rotated away from the user (or in a right-hand manner on horizontally aligned devices) and a negative value indicates that the wheel has been rotated towards the user (or in a left-hand manner on horizontally aligned devices).

A "click" is defined to be a unit of rotation. On some devices this is a finite physical step. On devices with smooth rotation, a "click" becomes the smallest measurable amount of rotation.

No defined methods

A.5.6 TextEvent

Event type that is a TextEvent: textInput.

This interface is a subset of the TextEvent interface defined in DOM Level 3 Events.

IDL Definition
interface TextEvent : UIEvent
{
	readonly attribute DOMString data;
};
No defined constants
Attributes
data
See data
No defined methods

A.5.7 KeyboardEvent

Provides specific contextual information associated with keyboard devices. Each KeyboardEvent references a key using an identifier.

Event types that are KeyboardEvents: keydown, keyup.

This interface is a subset of the KeyboardEvent interface defined in DOM Level 3 Events.

IDL Definition
interface KeyboardEvent : UIEvent
{
	readonly attribute DOMString keyIdentifier;
};
No defined constants
Attributes
keyIdentifier
See keyIdentifier
No defined methods

A.5.8 TimeEvent

This interface is a subset of the TimeEvent interface defined in smil animation.

Event that is fired by all Timed Elements.

Event types that are TimeEvents: beginEvent, endEvent, repeatEvent.

IDL Definition
interface TimeEvent : Event
{
	readonly attribute long detail;
};
No defined constants
Attributes
detail
Specifies detailed information about the TimeEvent, the information depends on the type of event. For beginEvent and endEvent the detail field is not used. For repeatEvent the detail field contains the current repeat iteration.
No defined methods

A.5.9 UIEvent

The UIEvent interface provides specific contextual information associated with User Interface events.

Event types that are UIEvents: DOMFocusIn, DOMFocusOut, DOMActivate, MouseEvent, TextEvent, KeyboardEvent,

This interface is a subset of the UIEvent interface defined in DOM Level 3 Events.

IDL Definition
interface UIEvent : Event
{
	readonly attribute long detail;
};
No defined constants
Attributes
detail
See detail
No defined methods

A.5.10 ProgressEvent

Many resources, such as raster images, movies and complex SVG content can take a substantial amount of time to download. In some use cases the author would prefer to delay the display of content or the beginning of an animation until the entire content of a file has been downloaded. In other cases, the author may wish to give the viewer some feedback that a download is in progress (e.g. a loading progress screen).

The ProgressEvent occurs when the user agent makes progress loading a resource (local or external) referenced by an xlink:href attribute.

The user agent must dispatch a ProgressEvent at the beginning of a load operation (i.e. just before starting to access the resource). This event is of type SVGPreload.

The user agent must dispatch a ProgressEvent at the end of a load operation (i.e. after load is complete and the user agent is ready to render the corresponding resource). This event is of type SVGPostload.

The user agent may dispatch ProgressEvents between the SVGPreload event and the SVGPostload events. Such events are of type SVGLoadProgress.

Event types that are ProgressEvents: SVGLoadProgress, SVGPreload, SVGPostload.

IDL Definition
interface ProgressEvent : Event
{
	readonly attribute boolean lengthComputable;
	readonly attribute unsigned long loaded;
	readonly attribute unsigned long total;
};
No defined constants
Attributes
lengthComputable
If false the total number of bytes (total) cannot be computed and the value of total should be ignored. This might occur if the size of the downloaded resource is unknown or if the data has already arrived.
loaded
Specifies the number of bytes downloaded since the beginning of the download. This value is ignored for a SVGPreload or SVGPostload event.
total
Specifies the expected total number of bytes expected in a load operation. For a SVGLoadProgress event, it should specify the total number of bytes expected.
No defined methods
Example: ProgressEvent
<svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny"
xmlns:xlink="http://www.w3.org/1999/xlink">

<script type="application/ecmascript"><![CDATA[
function showImage(imageHref) {
var image = document.getElementById('myImage');
image.setTraitNS("http://www.w3.org/1999/xlink", "href", imageHref);
}

function imageLoadStart (evt) {
progressBar.setFloatTrait("width", 0);
var loadingAnimation = document.getElementById('loadingAnimation');
loadingAnimation.beginElement();
}

function imageLoadProgress (evt) {
if ( evt.lengthComputable )
{
var progressBar = document.getElementById('progressBar');
progressBar.setFloatTrait("width", 100*(evt.loaded/evt.total));
progressBar.setTrait( "visibility", "visible" );
}
}

function imageLoadComplete (evt) {
var progressBar = document.getElementById('progressBar');
progressBar.setTrait( "visibility", "hidden" );
var loadingAnimation = document.getElementById('loadingAnimation');
loadingAnimation.endElement();
}

]]></script>

<image xml:id="myImage" xlink:href="imageA.png" width="300" height="400">
<handler type="application/ecmascript" ev:event="preload">
imageLoadStart(evt);
</handler>

<handler type="application/ecmascript" ev:event="loadProgress">
imageLoadProgress(evt);
</handler>

<handler type="application/ecmascript" ev:event="postload">
imageLoadComplete(evt);
</handler>
</image>

<rect width="120" height="30" y="400">
<handler type="application/ecmascript" ev:event="click">
showImage('imageB.png');
</handler>
</rect>

<animate xml:id="loadingAnimation" ... />

<rect visibility="hidden" xml:id="progressBar" ... />
</svg>

A.5.11 ConnectionEvent

The ConnectionEvent is used to represent all events that may occur during the processing of connections, as described in the Connection interface. These events represent not only data received through a connection, but also the establishment and closing of a connection, as well as error conditions that may occur.

Event types that are ConnectionEvents: SVGConnectionConnected, SVGConnectionDataSent, SVGConnectionDataReceived, SVGConnectionClosed, SVGConnectionError.

IDL Definition
interface ConnectionEvent : Event
{
	const unsigned short NO_ERR = 0;
	const unsigned short NETWORK_ERR = 1;
	readonly attribute unsigned short errorCode;
	readonly attribute sequence<octet> receivedData;
};
Constants
NO_ERR
When a connection event is dispatched and does not represent an error, its errorCode field is set to this value so that it can be distinguished from error related events.
NETWORK_ERR
When an error occurs during the lifetime of a connection, an event is dispatched with its errorCode field set to this value.
Attributes
errorCode
When an event indicating that an error has occurred is dispatched, this field contains the corresponding error constant. In all other situations this field is set to NO_ERR.
receivedData
When an event indicating that data has been successfully received is dispatched, this field contains the sequence of octets that represents that data. In all other situations this field is null.
No defined methods

A.6 Module: smil

A.6.1 ElementTimeControl

This interface defines common methods for elements which define animation behaviors compatible with SMIL (Timed Elements and the svg element).
IDL Definition
interface ElementTimeControl
{
	void beginElementAt(in float offset);
	void beginElement();
	void endElementAt(in float offset);
	void endElement();
};
No defined constants
No defined attributes
Methods
beginElementAt
Creates a begin instance time for the current time plus or minus the passed offset. The new instance time is added to the begin instance times list.
Parameters
in float offset The offset in seconds at which to begin the element.
No Return value
No Exceptions
beginElement
Creates a begin instance time for the current time. The new instance time is added to the begin instance times list. This is equivalent to beginElementAt(0).
No Parameters
No Return value
No Exceptions
endElementAt
Creates an end instance time for the current time plus or minus the passed offset. The new instance time is added to the end instance times list.
Parameters
in float offset The offset in seconds at which to end the element.
No Return value
No Exceptions
endElement
Creates an end instance time for the current time. The new instance time is added to the end instance times list. This is equivalent to endElementAt(0).
No Parameters
No Return value
No Exceptions

A.6.2 TimeEvent

IDL Definition
interface TimeEvent : Event
{
	readonly attribute long detail;
};
No defined constants
Attributes
detail
No description provided.
No defined methods

A.7 Module: global

A.7.1 Global

The Global interface is designed to be the parent interface for language specific window objects. It is currently defined to be empty.
IDL Definition
interface Global
{
};
No defined constants
No defined attributes
No defined methods

A.7.2 GlobalException

An exception thrown for problems occurring with methods in the global space.
IDL Definition
exception GlobalException
{
	unsigned short code;
};

// ExceptionCode
const unsigned short NOT_CONNECTED_ERR = 1;
const unsigned short ENCODING_ERR = 2;
const unsigned short DENIED_ERR = 3;
const unsigned short UNKNOWN_ERR = 4;
Constants
NOT_CONNECTED_ERR
Occurs when one attempts to send data over a closed connection, or a connection fails to be established.
ENCODING_ERR
Occurs when encoding or decoding a string fails.
DENIED_ERR
Occurs when the user-agent refuses to perform a requested task, for instance for security reasons.
UNKNOWN_ERR
Occurs when an error of an unknown nature happens.
No defined attributes
No defined methods

A.7.3 Connection

The Connection interface provides an API for socket-level communication. The socket must be set up to use the TCP protocol. A Connection object is created using the SVGGlobal interface method createConnection().

Since it inherits from the EventTarget interface, it is possible to register event listeners on the Connection interface in order to handle the various types of ConnectionEvent that are dispatched during the processing of connections.

After a connection has been established the Connection object must dispatch a ConnectionEvent with the type SVGConnectionConnected to event handlers registered on that Connection object.

After data has been successfully sent, the Connection object must dispatch a ConnectionEvent with the type SVGConnectionDataSent to event handlers registered on that Connection object. The event is dispatched exactly once for each call to send().

When data has been received, the Connection object must dispatch a ConnectionEvent with the type SVGConnectionDataReceived to event handlers registered on that Connection object.

In the circumstance that the connection is closed by any peer, a ConnectionEvent with the type SVGConnectionClosed must be dispatched to event handlers registered on that Connection object.

If an error occurs, a ConnectionEvent with the type SVGConnectionError must be dispatched to event handlers registered on that Connection object. This must cause the connection to be closed.

Data must be sent and received over the connection as a binary stream of octets.

The connect() and send() methods work asynchronously (non-blocking). Multiple calls to send() can be made in sequence without waiting for the SVGConnectionDataSent event to have been dispatched. Each set of data must be queued and sent, in FIFO order, by the UA. Each send() will result in a SVGConnectionDataSent event except when an error occurs. A user-agent may arbitrary limit the size of the queue of events that it can hold at any one time. Should more events require to be queued than the user-agent's limit a GlobalException of type DENIED_ERR must be raised, the entirety of the queue discarded, and the connection closed.

The send() method must raise an GlobalException of type NOT_CONNECTED_ERR exception if the connection is not open at the time the call is made. All other errors are treated asynchronously, in the form of connectionError events.

IDL Definition
interface Connection : EventTarget
{
	readonly attribute boolean connected;
	void connect(in DOMString host, in unsigned short port) 
		raises(GlobalException);
	void send(in sequence<octet> data) 
		raises(GlobalException);
	void close();
};
No defined constants
Attributes
connected
This boolean field will be true if a connection is currently open, and false otherwise.
Methods
connect

Cause a connection to be open to the provided host and port, where the host may be either a domain name or an IP address. If the connection fails to be established, a GlobalException of type NOT_CONNECTED_ERR MUST be raised. Once the connection is established, the connected field must be set to true.

For security reasons, user-agents are strongly encouraged to restrict the ways in which a connection can be established both for both host and ports. If the user-agent elects to deny the connection based on these restrictions, a GlobalException of type DENIED_ERR MUST be raised.

Parameters
in DOMString host A domain name or IP address that the TCP connection is to be established to.
in unsigned short port The port to which the TCP connection is being established.
No Return value
Exceptions
GlobalException
NOT_CONNECTED_ERR: Raised if the connection fails.
send

This method sends the data over the connection. It transmits a sequence of octets without modifying it in any way. A string can be transmitted after having been converted to a sequence of octets using the stringToBinary method on the SVGGlobal interface.

Parameters
in sequence<octet> data data The data to send.
No Return value
Exceptions
GlobalException
NOT_CONNECTED_ERR: Raised if the connection is not open when send is called.
close

This method causes the connection to be closed. It is asynchronous and any data queued for transmission using the send() method but not yet successfully transmitted must be sent before the connection is effectively closed. However, any call to send() occurring after close() has been called will raise an exception as if the connection had already been closed, and the connected field must be set to false immediately.

No Parameters
No Return value
No Exceptions

A.7.4 Timer

The Timer interface provides an API for scheduling a one time or repetitive event. A Timer object is always either in the running (attribute running is true) or waiting (attribute running is false) state. After each interval of the timer, an Event of type SVGTimer is triggered.

SVGTimer events are triggered only when the timer is in the running state. The SVGTimer event is limited to the target phase. Since Timer is an EventTarget, EventListeners can be registered on it using addEventListener with SVGTimer as the event type. Event listeners can access their corresponding Timer object through the event object's target property.

Timer instances are created using the createTimer method of the SVGGlobalinterface.

IDL Definition
interface Timer : events::EventTarget
{
	attribute long delay;
	attribute long repeatInterval;
	readonly attribute boolean running;
	void start();
	void stop();
};
No defined constants
Attributes
delay

This attribute specifies the time remaining in milliseconds until the next event is fired. When the Timer is in the running state this attribute is dynamically updated to reflect the remaining time in the current interval. When the Timer is waiting the delay reflects the time that remained when stopped. Getting the delay attribute returns the current value, i.e. a snapshot value of the remaining delay. After delay period has passed while the object is in the running state, the Timer object will trigger an Event of type SVGTimer. The delay will then be updated with the repeatInterval value and a new count down will start. Setting the delay resets the current interval to the new value. If this attribute is 0, it means that the event will be triggered as soon as possible. Assigning a negative value is equivalent to calling the stop() method. The initial value is set through the initialInterval parameter in the createTimer method on the SVGGlobalinterface, and defines the first interval of the Timer.

repeatInterval

This attribute specifies in milliseconds the interval for each repeat of the Timer, i.e. each timer interval subsequent to the initial interval. The initial value of this attribute is set through the repeatInterval parameter in the createTimer method on the SVGGlobal interface. Assigning a negative value disables the repetitive triggering of the event making it a one time timer which triggers an event after the delay.

running

Timer state. Value is true if the timer is running, false if the timer is waiting. Note that the repeatInterval and delay properties can be non-negative if the timer is stopped (but if delay is negative, the timer is stopped).

Methods
start

Changes the Timer state into running. If the timer is already in the running state, it has no effect. Initially the timer is waiting, and must be started with this method. If the timer delay had a negative value when started, for example if the time had been stopped by setting the delay to a negative value, the delay value is reset to repeatInterval when the this method is called.

No Parameters
No Return value
No Exceptions
stop

Changes the Timer state into waiting. If the timer is already in the waiting state, calling this method has no effect.

No Parameters
No Return value
No Exceptions

A.8 Module: svg

A.8.1 SVGException

An exception thrown for SVG-specific errors.

This interface is identical to SVGException interface defined in SVG 1.1.

IDL Definition
exception SVGException
{
	unsigned short code;
};

// ExceptionCode
const unsigned short SVG_WRONG_TYPE_ERR         = 0;
const unsigned short SVG_INVALID_VALUE_ERR      = 1;
const unsigned short SVG_MATRIX_NOT_INVERTABLE  = 2;
Constants
SVG_WRONG_TYPE_ERR
See definition
SVG_INVALID_VALUE_ERR
See definition
SVG_MATRIX_NOT_INVERTABLE
See definition
No defined attributes
No defined methods

A.8.2 SVGDocument

IDL Definition
interface SVGDocument : Document, EventTarget
{
	readonly attribute SVGGlobal global;
};
No defined constants
Attributes
global
Access to the SVGGlobal object.
No defined methods

A.8.3 SVGElementInstance

For each 'use' element, the uDOM represents the referenced content with a shadow tree of SVGElementInstance objects.

This interface is a subset of the SVGElementInstance interface defined in SVG 1.1.

IDL Definition
interface SVGElementInstance : EventTarget
{
	readonly attribute SVGElement correspondingElement;
	readonly attribute SVGElement correspondingUseElement;
};
No defined constants
Attributes
correspondingElement
See correspondingElement
correspondingUseElement
See correspondingUseElement
No defined methods
Example: ECMAScript usage of the SVGElementInstance interface.

In this example, three 'use' elements use the same 'rect' element. Each 'use' has different 'fill' properties that are inherited down to the used 'rect'. The result is three 'rect' elements with different 'fill' colors. Clicking one of these three 'rect' elements will cause a fourth 'rect' to change color to match the clicked one. Worth noticing is that if the original 'rect' had not been in the 'defs' element the script would go into error when the original 'rect' is clicked. This is because the 'currentTarget' attribute would return an 'SVGElement' that doesn't have the 'correspondingUseElement' attribute.
<svg version="1.2" baseProfile="tiny" width="640" height="480"
viewBox="0 0 640 480" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:ev="http://www.w3.org/2001/xml-events">
<defs>
<rect xml:id="r1" width="90" height="65"/>
</defs>

<use xlink:href="#r1" x="50" y="200" fill="red"/>
<use xlink:href="#r1" x="250" y="200" fill="blue"/>
<use xlink:href="#r1" x="450" y="200" fill="green"/>

<rect xml:id="r2" x="250" y="50" width="90" height="65"/>

<ev:listener observer="r1" event="ev:click" handler="#handler"/>

<handler xml:id="handler" type="application/ecmascript">changeColor(evt);</handler>

<script type="application/ecmascript">
<![CDATA[
var target = document.getElementById("r2");

function changeColor(evt)
{
var useElement = evt.currentTarget.correspondingUseElement;
target.setRGBColorTrait("fill", useElement.getRGBColorTrait("fill"));
}
]]>
</script>
</svg>

A.8.4 SVGSVGElement

This interface represents the 'svg' element in the (SVG) document tree.

User Agent Transforms

The uDOM attributes currentScale, currentRotate and currentTranslate are combined to form a user agent transformation which is applied at the outermost level on the SVG document (i.e. outside the 'svg' element) if "magnification" is enabled (i.e. 'zoomAndPan' attribute is set to magnify). Their values can potentially be modified through user-agent specific UI. User agent transformation can be obtained by multiplying the matrix

[currentScale      0       currentTranslate.x]         [cos(currentRotate) -sin(currentRotate 0]
[     0      currentScale  currentTranslate.y]  by     [sin(currentRotate) cos(currentRotate) 0]
[     0            0               1         ]         [         0                  0         1]

i.e. (translate, then scale, then rotate the coordinate system). The reference point for scale and rotate operations is the origin (0, 0).

IDL Definition
interface SVGSVGElement : SVGLocatableElement, SVGTimedElement
{
	const unsigned short NAV_AUTO           = 1;
	const unsigned short NAV_NEXT           = 2;
	const unsigned short NAV_PREV           = 3;
	const unsigned short NAV_UP             = 4;
	const unsigned short NAV_UP_RIGHT       = 5;
	const unsigned short NAV_RIGHT          = 6;
	const unsigned short NAV_DOWN_RIGHT     = 7;
	const unsigned short NAV_DOWN           = 8;
	const unsigned short NAV_DOWN_LEFT      = 9;
	const unsigned short NAV_LEFT           = 10;
	const unsigned short NAV_UP_LEFT        = 11;
	attribute float currentScale;
	attribute float currentRotate;
	readonly attribute SVGPoint currentTranslate;
	readonly attribute SVGRect viewport;
	float getCurrentTime();
	void setCurrentTime( in float seconds );
	SVGMatrix createSVGMatrixComponents(in float a, in float b, in float c, in float d, in float e, 
	                                    in float f);
	SVGRect createSVGRect();
	SVGPath createSVGPath();
	SVGRGBColor createSVGRGBColor(in long red, in long green, in long blue) 
		raises(SVGException);
	void moveFocus(in unsigned short motionType) 
		raises(DOMException);
	void setFocus(in DOMObject object) 
		raises(DOMException);
	EventTarget getCurrentFocusedObject();
};
Constants
NAV_AUTO
Indicates that focus must move to the next focusable object according to the User Agent's own algorithm.
NAV_NEXT
Indicates that focus must move to the next focusable object according to current nav-next value.
NAV_PREV
Indicates that focus must move to the previous focusable object according to current nav-prev value.
NAV_UP
Indicates a request that focus must move in the given direction.
NAV_UP_RIGHT
Indicates a request that focus must move in the given direction.
NAV_RIGHT
Indicates a request that focus must move in the given direction.
NAV_DOWN_RIGHT
Indicates a request that focus must move in the given direction.
NAV_DOWN
Indicates a request that focus must move in the given direction.
NAV_DOWN_LEFT
Indicates a request that focus must move in the given direction.
NAV_LEFT
Indicates a request that focus must move in the given direction.
NAV_UP_LEFT
Indicates a request that focus must move in the given direction.
Attributes
currentScale
On read : Returns the current user agent scale (zoom) coefficient. The initial value for currentScale is 1.

On write : Sets the current user agent scale (zoom) coefficient.
Exceptions
DOMException
INVALID_ACCESS_ERR: Raised if the scale value is set to zero.
currentRotate
On read : Returns the current user agent rotation angle in degrees. The initial value for currentRotate is 0.

On write : Sets the current user agent rotate coefficient in degrees.
currentTranslate
Current user agent translation used for scrolling or panning (The returned SVGPoint object is "live" and setting its x and y components will change the user agent's translation). The initial values for currentTranslate is SVGPoint(0,0).
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.

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 specification.) If the parent element does not have a coordinate system, then the user agent should provide reasonable default values for this attribute.

For stand-alone SVG documents, both 'x' and 'y' must be zero, the 'width' must be the width of the viewport which the host environment provides to the SVG user agent into which it can render its content, and the 'height' must be the height of the viewport, with all values expressed in the pixel coordinate system from the host environment, preferably such that this pixel coordinate system matches the same pixel coordinate system presented to HTML and matches the model for pixel coordinates described in the CSS2 specification.

Note that "pixel coordinate systems" are host-specific. Two possible approaches that hosts might use for pixel coordinate systems are actual device pixels or (particularly for high-resolution devices) pseudo device pixels which exactly match SVG and CSS's "px" coordinates.

The object itself and its contents are both readonly. A DOMException with error code NO_MODIFICATION_ALLOWED_ERR is raised if attempt is made to modify it. The returned SVGRect object is "live", i.e. its x, y, width, height is automatically updated if viewport size or position changes.

Methods
getCurrentTime
Returns the document time in seconds.

setCurrentTime
Sets the document time (in seconds). This API is required to support seeking forwards and backwards in the timeline. After a seek, animation continues to play (forwards) from the new time.
createSVGMatrixComponents
Creates a new SVGMatrix object. This object can be used to modify the value of traits which are compatible with the SVGMatrix type using the setMatrixTrait method. The internal representation of the matrix is as follows:
[  a  c  e  ]
[  b  d  f  ]
[  0  0  1  ]
Parameters
in float a The 'a' component of the matrix to be set.
in float b The 'b' component of the matrix to be set.
in float c The 'c' component of the matrix to be set.
in float d The 'd' component of the matrix to be set.
in float e The 'e' component of the matrix to be set.
in float f The 'f' component of the matrix to be set.
Return value
SVGMatrix The created SVGMatrix object.
No Exceptions
createSVGRect
Creates a new SVGRect object. This object can be used to modify the value of traits which are compatible with the SVGRect type using the setRectTrait method. The initial values for x, y, width, height of this new SVGRect are zero.
No Parameters
Return value
SVGRect The created SVGRect.
No Exceptions
createSVGPath
Creates a new SVGPath object. This object can be used to modify the value of traits which are compatible with the SVGPath type using the setPathTrait method.
No Parameters
Return value
SVGPath The created SVGPath.
No Exceptions
createSVGRGBColor
Creates a new SVGRGBColor object. This object can be used to modify the value of traits which are compatible with the SVGRGBColor type using the setRGBColorTrait method. The parameters are floats, one per color component. 0.0 represents zero intensity and 255.0 represents full intensity of a given color component. Colors originally in the rgb(%,%,%) syntax may have fractional components. Out of gamut colors may have component values less than 0.0 or greater than 255.0.
Parameters
in float red The red component of the SVGRGBColor.
in float green The green component of the SVGRGBColor.
in float blue The blue component of the SVGRGBColor.
Return value
SVGRGBColor The created SVGRGBColor.
No Exceptions
moveFocus
Moves current focus to a different object based on the value of motionType. The User Agent must take into account the currently focused object in the document in order to find the new focused object.

If this method succeeds :
  • A DOMFocusOut event must be dispatched which has the previously focused object as the event target.
  • After that, a DOMFocusIn event must dispatched which has the the new focused object as the event target.
A reference to the new focused object can be obtained using the EventTarget interface of the generated DOMFocusIn event.

Refer to the navigation section to see how navigation is managed. The behavior for this method must be the same as if an equivalent move was done by the end user (using joystick or TAB keys) and not by scripting.

Whenever the method fails (i.e. a DOMException is raised), focus must stay on the currently focused object and no DOMFocusOut/DOMFocusIn event is dispatched.

Note: For stand-alone SVG documents, the User Agent must always have a currently focused object. At the beginning, the SVGDocument has focus.
Parameters
in short motionType The type of motion.
No Return value
Exceptions
DOMException
NOT_SUPPORTED_ERROR: Raised if the requested motion type is not supported (i.e. not one of the interface constants).
DOMException
INVALID_ACCESS_ERR: Raised if the currently focused object doesn't have a nav-* value corresponding to the requested motion type. For instance, if a moveFocus(NAV_UP) is called on an element which has no 'nav-up' attribute.
DOMException
INVALID_STATE_ERR: Raised if the currently focused object has a nav-* value corresponding to the requested motion type but the target indicated in this attribute can not be found or is not a focusable object. For instance, if a moveFocus(NAV_UP) is called on an object which has a 'nav-up' attribute but the value of this attribute references an element which is not focusable.
setFocus
A request to put the focus on the given object.

If this method succeeds:
  • A DOMFocusOut event must be dispatched which has the previously focused object as the event target.
  • After that, a DOMFocusIn event must be dispatched which has the the new focused object as the event target.
A reference to the new focused object can be obtained using the EventTarget interface of the generated DOMFocusIn event.

Whenever the method fails (i.e. a DOMException is raised), focus must stay on the currently focused object and no DOMFocusOut/DOMFocusIn event is dispatched.

Note: For stand-alone SVG documents, the User Agent must always have a currently focused object. At the beginning, the SVGDocument has focus.
Parameters
in DOMObject object The object which should receive focus.
No Return value
Exceptions
DOMException
NOT_SUPPORTED_ERROR: Raised if the requested element is not focusable (i.e. its ''focusable' attribute does not evaluate to true).
getCurrentFocusedObject
Returns a reference to the object which has the focus. This returns an EventTarget.

No Parameters
Return value
EventTarget The currently focused object.
No Exceptions

A.8.5 SVGRGBColor

This interface represents an SVGRGBColor datatype made up of red, green, and blue components. It can be used to read properties that store color values (getRGBColorTrait) such as 'fill', 'stroke', and 'color'.
IDL Definition
interface SVGRGBColor
{
	attribute unsigned long red;
	attribute unsigned long green;
	attribute unsigned long blue;
};
No defined constants
Attributes
red
Returns the red component of the SVGRGBColor.
green
Returns the green component of the SVGRGBColor.
blue
Returns the blue component of the SVGRGBColor.
No defined methods

A.8.6 SVGRect

This interface represents an SVGRect datatype, consisting of a minimum X, minimum Y, width and height values.

This interface is identical to SVGRect interface defined in SVG 1.1.

IDL Definition
interface SVGRect
{
	attribute float x;
	attribute float y;
	attribute float width;
	attribute float height;
};
No defined constants
Attributes
x
See x
y
See y
width
See width
height
See height
No defined methods

A.8.7 SVGPoint

Represents an SVGPoint datatype, identified by its x and y components.

This interface is a subset of the SVGPoint interface defined in SVG 1.1.

IDL Definition
interface SVGPoint
{
	attribute float x;
	attribute float y;
};
No defined constants
Attributes
x
See x
y
See y
No defined methods

A.8.8 SVGPath

This interface represents an SVGPath datatype used to define the path geometry.

Path data created or modified using this interface must be normalized as per the rules given in Path Normalization.

IDL Definition
interface SVGPath
{
	const unsigned short MOVE_TO = 77;
	const unsigned short LINE_TO = 76;
	const unsigned short CURVE_TO = 67;
	const unsigned short QUAD_TO = 81;
	const unsigned short CLOSE = 90;
	readonly attribute unsigned long numberOfSegments;
	unsigned short getSegment(in unsigned long cmdIndex) 
		raises(DOMException);
	float getSegmentParam(in unsigned long cmdIndex, in unsigned long paramIndex) 
		raises(DOMException);
	void moveTo(in float x, in float y);
	void lineTo(in float x, in float y);
	void quadTo(in float x1, in float y1, in float x2, in float y2);
	void curveTo(in float x1, in float y1, in float x2, in float y2, in float x3, in float y3);
	void close();
};
Constants
MOVE_TO
Numeric value is Unicode value of the letter 'M'.
LINE_TO
Numeric value is Unicode value of the letter 'L'.
CURVE_TO
Numeric value is Unicode value of the letter 'C'.
QUAD_TO
Numeric value is Unicode value of the letter 'Q'.
CLOSE
Numeric value is Unicode value of the letter 'Z'.
Attributes
numberOfSegments
Retur