SVG Tiny 1.2 - 20051207

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, 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).

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 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 must offer 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 (in dom::Element scriptElement) 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 must allow 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 Addition

Node addition is the ability to add new elements to a document tree.

SVG uDOM must allow addition and insertion of a Node.

Example: Element addition (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

Node removal is the ability to remove an element from a document tree. SVG uDOM must allow removal of element Nodes.

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 a potentially animatable parameter associated with an element. Trait is the typed value (e.g. a number, not just a string) that gets assigned through an XML attribute or a CSS property. Traits can be thought of as a unification and generalization of some of the notions of XML attributes and CSS properties. 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 (witch 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 below).

r2.getTraitNS(null, "fill") returns "red" (or equivalent normalized form, see below).

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

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

A.2.7 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:

A.2.8 Text Node Access

In the SVG uDOM, text node access is available in two alternative ways. 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 'tspan' elements will be lost if she gets a text string from the model and sets it 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.2.9 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 must allow 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);

The SVG uDOM only supports the bubble phase. Any attempt to specify event operations on the capture phase must raise a DOMException of type NOT_SUPPORTED_ERR.

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.

A.2.10 Animation

SVG uDOM allows code to start or end animation elements (i.e. elements implementing SVGAnimationElement).

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

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

A.2.11 Java package naming

The SVG uDOM will use the same Java package names as the 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 Module: dom

A.3.1 DOMException

IDL Definition
exception DOMException
{
	unsigned short code;
};

// ExceptionCode
const unsigned short INDEX_SIZE_ERR = 1;
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_MODIFICATION_ALLOWED_ERR = 7;
const unsigned short NOT_FOUND_ERR = 8;
const unsigned short NOT_SUPPORTED_ERR = 9;
const unsigned short INVALID_STATE_ERR = 11;
const unsigned short INVALID_MODIFICATION_ERR = 13;
const unsigned short NAMESPACE_ERR = 14;
const unsigned short INVALID_ACCESS_ERR = 15;
const unsigned short TYPE_MISMATCH_ERR = 17;
Constants
INDEX_SIZE_ERR
If index or size is negative, or greater than the allowed value.
HIERARCHY_REQUEST_ERR
If any Node is inserted somewhere it doesn't belong.
WRONG_DOCUMENT_ERR
If a Node is used in a different document than the one that created it (that doesn't support it).
INVALID_CHARACTER_ERR
If an invalid or illegal character is specified, such as in an XML name.
NO_MODIFICATION_ALLOWED_ERR
If an attempt is made to modify an object where modifications are not allowed.
NOT_FOUND_ERR
If an attempt is made to reference a Node in a context where it does not exist. See insertBefore for example.
NOT_SUPPORTED_ERR
If the implementation does not support the requested type of object or operation.
INVALID_STATE_ERR
If an attempt is made to use an object that is not, or is no longer, usable.
INVALID_MODIFICATION_ERR
If an attempt is made to modify the type of the underlying object.
NAMESPACE_ERR
If an attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
INVALID_ACCESS_ERR
If a parameter or an operation is not supported by the underlying object.
TYPE_MISMATCH_ERR
If the type of an object is incompatible with the expected type of the parameter associated to the object.
No defined attributes
No defined methods

A.3.2 Node

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

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

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
Returns the namespace URI of the Node.
localName
Returns the local part of the qualified name of this Node. If the Node is of type Element, this returns the tag name without a prefix. But, if the Node is of type Document then null is returned.
parentNode
Returns the parent Node of this Node.
ownerDocument
The Document object associated with this Node.
textContent
This attribute returns the text content of this Node and its descendants. When it is defined to be null, setting it has no effect. On setting, any possible children this Node may have are removed and, if it the new string is not empty or null, replaced by a single text node containing the string this attribute is set to. On getting, no serialization is performed, the returned string does not contain any markup. No whitespace normalization is performed and the returned string does not contain the white spaces in element content. Similarly, on setting, no parsing is performed either, the input string is taken as pure textual content.

textContent must be supported on all non-svg elements. For elements defined within this specification (see list of elements) textContent must be supported on the Text Content, 'desc', 'title' and 'metadata' elements. textContent on elements that do not support textContent is null. Setting textContent on an element that do not support textContent has no effect.

textContent on the Document node is always null.

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

For further details see DOM3 textContent.

Methods
appendChild
Appends a child to this Node.
Parameters
in Node newChild The Node to be appended to this Node. This is equivalent to insertBefore(newChild,null).
Return value
Node The Node added.
Exceptions
DOMException
HIERARCHY_REQUEST_ERR: Raised if this Node is of a type that does not allow children of the type of the newChild node, or if the node to append is one of this node's ancestors or this node itself, or if this Node is of type Document and the uDOM application attempts to append a second Element node.
DOMException
WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that created this Node.
DOMException
NOT_SUPPORTED_ERR: Raised if the newChild node is a child of the Document node or if the child is of a type that cannot be created with createElementNS.
DOMException
INVALID_STATE_ERR: Raised if the newChild node would cause the document to go into error.
insertBefore
Inserts newChild before refChild in the child list for this Node. If refChild is null, newChild is inserted at the end of the list. If the newChild is already part of the tree, it is first removed.
Parameters
in Node newChild The child to add.
in Node refChild The child before which the new child is added.
Return value
Node The Node being inserted.
Exceptions
DOMException
HIERARCHY_REQUEST_ERR: Raised if this Node is of a type that does not allow children of the type of the newChild node, or if the Node to append is one of this node's ancestors or this Node itself, or if this Node is of type Document and the uDOM application attempts to append a second Element node.
DOMException
WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that created this Node.
DOMException
NOT_FOUND_ERR: Raised if refChild is not a child of this Node.
DOMException
NOT_SUPPORTED_ERR: Raised if the newChild node is a child of the Document node or if the child is of a type that cannot be created with createElementNS.
DOMException
INVALID_STATE_ERR: if the newChild node would cause the document to go into error.
removeChild
Removes the specified child associated with this Node.
Parameters
in Node oldChild The Node that is to be removed.
Return value
Node The Node removed.
Exceptions
DOMException
NOT_FOUND_ERR: Raised if oldChild is not a child of this Node.
DOMException
NOT_SUPPORTED_ERR: Raised if this Node is of type Document or if the child, or any of its descendants, is of a type that cannot be created with the Document method createElementNS.
cloneNode

Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. The duplicate node has no parent (parentNode is null).

Cloning an Element copies all attributes and their values, including those generated by the XML processor to represent defaulted attributes, but this method does not copy any children it contains unless it is a deep clone. This includes text contained in an the Element.

Note: Cloning an element that has an ID will clone it as well, and thus the ID should be changed before the cloned element is inserted into the tree as duplicate IDs produce implementation-dependent results.

Note: Document nodes is implementation dependent.

Parameters
in boolean feature If true, recursively clone the subtree under the specified node; if false, clone only the node itself (and its attributes, if it is an Element).
Return value
Node The duplicate node.
No Exceptions

A.3.3 Element

Represents an Element in the document. A user agent is allowed to store normalized attribute values internally as described in DOM 3.
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
Retrieves an attribute value by local name and namespace IRI. Per [XML Namespaces], applications must use the value null as the namespaceURI parameter for methods if they wish to have no namespace.

An SVGT1.2 user agent must support getAttributeNS for certain types of attributes and may support getAttributeNS for other types of attributes. An SVGT1.2 user agent must support getAttributeNS for:

In order to allow for implementation efficiency on small devices, an SVGT1.2 user agent is not required to support getAttributeNS for other types of attributes.

Note: Because it is not required that user agents support getAttributeNS on every possible type of attribute, conforming SVGT1.2 content must use getAttributeNS only on those types of attributes which SVGT1.2 user agents must support, as described above.

A viewer implementing the uDOM is allowed to return normalized values in getAttributeNS as defined in Attribute Normalization.

Parameters
in DOMString namespaceURI The namespace URI of the attribute to retrieve.
in DOMString localName The local name of the attribute to retrieve.
Return value
DOMString The attribute value.
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if getAttributeNS tries to get an unsupported attribute.
setAttributeNS
Adds/sets a new attribute. The value to set is a simple string; it is not parsed as it is being set. So any markup is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. Per [XML Namespaces], applications must use the value null as the namespaceURI parameter for methods if they wish to have no namespace.

A uDOM implementation must support setAttributeNS for all attributes.

Parameters
in DOMString namespaceURI The namespace URI of the attribute to create or alter.
in DOMString qualifiedName The local name of the attribute to create or alter.
in DOMString value The value to set in string form.
No Return value
Exceptions
DOMException

NOT_SUPPORTED_ERR: Raised if setAttributeNS tries to set an unsupported attribute.

NO_MODIFICATION_ALLOWED_ERR: Raised if the attribute cannot be modified.

INVALID_CHARACTER_ERR: Raised if the specified local name is not an XML name.

NAMESPACE_ERR: Raised if the qualifiedName is malformed per the Namespaces in XML specification, if the qualifiedName has a prefix and the namespaceURI is null, if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from "http://www.w3.org/XML/1998/namespace", if the qualifiedName or its prefix is "xmlns" and the namespaceURI is different from "http://www.w3.org/2000/xmlns/", or if the namespaceURI is "http://www.w3.org/2000/xmlns/" and neither the qualifiedName nor its prefix is "xmlns".

A.3.4 Document

The Document interface represents an XML Document.

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

Note: The behavior of the following attributes and methods from the Node interface when called on a Document object:

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
The DOMImplementation object that handles this document.
documentElement
Return a child element of this document node which corresponds to the root-most element in the XML document. For SVG documents it must be SVGSVGElement, but return type is Element for DOM Core compatibility and to allow for future extensions.
Methods
createElementNS
Create a new Element based on the specified (qualified) tag name.
Parameters
in DOMString namespaceURI The namespace uri for the newly created element.
in DOMString qualifiedName The qualified name for the newly created element (For example: "rect", to create a 'rect' element).
Return value
Element The newly created Element.
Exceptions
DOMException

NOT_SUPPORTED_ERR: Raised if the type of element is not supported by the implementation.

INVALID_CHARACTER_ERR: Raised if the specified local name is not an XML name.

NAMESPACE_ERR: Raised if the qualifiedName is malformed per the Namespaces in XML specification, if the qualifiedName has a prefix and the namespaceURI is null, if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from "http://www.w3.org/XML/1998/namespace", if the qualifiedName or its prefix is "xmlns" and the namespaceURI is different from "http://www.w3.org/2000/xmlns/", or if the namespaceURI is "http://www.w3.org/2000/xmlns/" and neither the qualifiedName nor its prefix is "xmlns".

getElementById
Return the Element in the current document with the given unique ID.
Parameters
in DOMString elementId The ID of the object to be retrieved.
Return value
Element The Element in the current document with the given unique ID. If no such element exists, this returns null.
No Exceptions

A.3.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 the DOM Level 3 Core.

IDL Definition
interface DOMImplementation
{
	boolean hasFeature(in DOMString feature, in DOMString version);
};
No defined constants
No defined attributes
Methods
hasFeature
Test if the DOM implementation implements a specific feature and version. Supports both DOM Features and SVG's feature strings.
Parameters
in DOMString feature The name of the feature to test.
in DOMString version This is the version number of the feature to test.
Return value
boolean Will be true if the feature is implemented in the specified version, false otherwise.
No Exceptions

A.4 Module: events

A.4.1 EventTarget

This interface represents an event target, and is a subset of the EventTarget interface defined in the DOM Level 3 Event model.

This interface is implemented by an object (SVGElement, SVGDocument, SVGElementInstance) that can notify listeners about events and allows registration and removal of EventListener objects.
IDL Definition
interface EventTarget
{
	void addEventListener(in DOMString type, in EventListener listener, in boolean useCapture) raises(DOMException);
	void removeEventListener(in DOMString type, in EventListener listener, in boolean useCapture) raises(DOMException);
	void addEventListenerNS(in DOMString namespaceURI, in DOMString type, in EventListener listener, in boolean useCapture, in DOMObject evtGroup) raises(DOMException);
	void removeEventListenerNS(in DOMString namespaceURI, in DOMString type, in EventListener listener, in boolean useCapture) raises(DOMException);
};
No defined constants
No defined attributes
Methods
addEventListener
This method registers the specified listener with the event target. If an EventListener is added to an EventTarget while it is processing an event, it will not be triggered by the current actions. If multiple identical EventListeners are registered on the same EventTarget with the same parameters the duplicate instances are discarded. They do not cause the EventListener to be called twice and since they are discarded they do not need to be removed with the removeEventListener method.
Parameters
in DOMString type The type of event to listen to.
in EventListener listener Will be notified when an event of the desired type happens on this target or one of its descendant.
in boolean useCapture This must be 'false' since capture phase is not supported.
No Return value
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if useCapture is true since capture phase is not required in SVG Tiny and implementations may not support registering listeners for the capture phase.
removeEventListener
This method removes the specified listener from the event target. If an EventListener is removed from an EventTarget while it is processing an event, it will not be triggered by the current actions. Calling removeEventListener with arguments which do not identify any currently registered EventListener on the EventTarget has no effect.
Parameters
in DOMString type The type of event that was listened to.
in EventListener listener The listener that was previously registered.
in boolean useCapture This can only be 'false' since capture phase is not supported.
No Return value
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if useCapture is true since capture phase is not required in SVG Tiny and implementations may not support registering listeners for the capture phase.
addEventListenerNS
This method registers the specified listener with the event target. If an EventListener is added to an EventTarget while it is processing an event, it will not be triggered by the current actions. If multiple identical EventListeners are registered on the same EventTarget with the same parameters the duplicate instances are discarded. They do not cause the EventListener to be called twice and since they are discarded they do not need to be removed with the removeEventListenerNS method.
Parameters
in DOMString namespaceURI The namespace URI of the event.
in DOMString type The type of event to listen to.
in EventListener listener Will be notified when an event of the desired type happens on this target or one of its descendant.
in boolean useCapture This must be 'false' since capture phase is not supported.
in DOMObject evtGroup For compatibility with DOM Level 3. In SVGT1.2 this parameter must be null.
No Return value
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if useCapture is true since capture phase is not required in SVG Tiny and implementations may not support registering listeners for the capture phase.
removeEventListenerNS
This method removes the specified listener from the event target. If an EventListener is removed from an EventTarget while it is processing an event, it will not be triggered by the current actions. Calling removeEventListenerNS with arguments which do not identify any currently registered EventListener on the EventTarget has no effect.
Parameters
in DOMString namespaceURI The namespace URI of the event.
in DOMString type The type of event that was listened to.
in EventListener listener The listener that was previously registered.
in boolean useCapture This must be 'false' since capture phase is not supported.
No Return value
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if useCapture is true since capture phase is not required in SVG Tiny and implementations may not support registering listeners for the capture phase.

A.4.2 EventListener

This interface represents an event listener, and is a subset of the EventListener interface defined in the DOM Level 3 Event model.

This interface must be implemented and registered on an EventTarget using the addEventListenerNS method to be notified about events that occur on or bubble through the event target.

IDL Definition
interface EventListener
{
	void handleEvent(in Event evt);
};
No defined constants
No defined attributes
Methods
handleEvent
This method is called whenever an event occurs of the type for which the EventListener interface was registered. The Event object contains the necessary information pertaining to the event, such as its target and type.
Parameters
in Event evt The Event object containing necessary event information.
No Return value
No Exceptions

A.4.3 Event

The Event interface is used to provide contextual information about an event to the handler processing the event. An object which implements the Event interface is passed as the first parameter to the handleEvent call. If an event target is an element instance (see SVGElementInstance), the currentTarget is an implementation of EventTarget that does not implement the Node interface. In profiles of SVG that support the SVGElementInstance interface, the currentTarget is an SVGElementInstance.
IDL Definition
interface Event
{
	readonly attribute EventTarget target;
	readonly attribute EventTarget currentTarget;
	readonly attribute DOMString type;
	readonly attribute DOMString namespaceURI;
	readonly attribute boolean cancelable;
	boolean isDefaultPrevented();
	void stopPropagation();
	void preventDefault();
};
No defined constants
Attributes
target
Used to indicate the event target. This attribute contains the target node when used with the DOM event flow.
currentTarget
Used to indicate the EventTarget whose EventListeners are currently being processed. In SVG Tiny, this is always an object to which event listener was attached.
type
This method returns the event type information. The name of the event is case-sensitive. For a list of supported event types see the Supported Events chapter.
namespaceURI
The namespace associated with this event at creation time, or null if it is unspecified.
cancelable
Used to indicate whether or not an event can have its default action prevented (see also Default actions and cancelable events in DOM Events). If the default action can be prevented the value is true, otherwise the value is false.
Methods
isDefaultPrevented
This method will return true if the method preventDefault() has been called for this event, false otherwise.
No Parameters
Return value
boolean true if preventDefault() has been called for this event.
No Exceptions
stopPropagation
This method is used to prevent event listeners of the same group to be triggered but its effect is deferred until all event listeners attached on the currentTarget have been triggered (see Event propagation and event groups in DOM Events). Once it has been called, further calls to that method have no additional effect.

Note: This method does not prevent the default action from being invoked; use preventDefault() for that effect.
No Parameters
No Return value
No Exceptions
preventDefault
If an event is cancelable, the preventDefault() method is used to signify that the event is to be canceled, meaning any default action normally taken by the implementation as a result of the event will not occur (see also Default actions and cancelable events in DOM Events), and thus independently of event groups. Calling this method for a non-cancelable event has no effect.

Note: This method does not stop the event propagation; use stopPropagation() for that effect.
No Parameters
No Return value
No Exceptions

A.4.4 OriginalEvent

OriginalEvent is supported on events going through the following element types: 'animation' and 'foreignObject' (when 'foreignObject' has an 'xlink:href' attribute).
IDL Definition
interface OriginalEvent
{
	readonly attribute Event originalEvent;
};
No defined constants
Attributes
originalEvent
For the supported element ('animation' and 'foreignObject'), events can be dispatched to the SVGElementInstance objects corresponding to the content referenced by the supported element. UI events that are dispatched to these SVGElementInstance objects can bubble up to the supported element. Upon bubbling to the supported element, the User Agent must manufacture new Event and OriginalEvent objects. The new Event object must be of the same type and carry the same information as the original event object but which has the supported element as the "target". The new OriginalEvent object must set the originalEvent attribute to the original event object.
No defined methods

A.4.5 MouseEvent

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

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

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
The horizontal coordinate at which the event occurred relative to the origin of the screen coordinate system.
screenY
The vertical coordinate at which the event occurred relative to the origin of the screen coordinate system.
clientX
The horizontal coordinate at which the event occurred relative to the uDOM implementation's client area.
clientY
The vertical coordinate at which the event occurred relative to the uDOM implementation's client area.
button
During mouse events caused by the depression or release of a mouse button, this is used to indicate which mouse button changed state. The values for button range from zero to indicate the left button of the mouse, one to indicate the middle button if present, and two to indicate the right button. For mice configured for left handed use in which the button actions are reversed the values are instead read from right to left.
No defined methods

A.4.6 TextEvent

One or more characters have been entered.

Event type that is a TextEvent: textInput.

IDL Definition
interface TextEvent : UIEvent
{
	readonly attribute DOMString data;
};
No defined constants
Attributes
data
Holds the value of the characters generated by the character device. This may be a single Unicode character or a non-empty sequence of Unicode characters. This attribute must not be null or contain the empty string.
No defined methods

A.4.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.

IDL Definition
interface KeyboardEvent : UIEvent
{
	readonly attribute DOMString keyIdentifier;
};
No defined constants
Attributes
keyIdentifier
Holds the identifier of the key.
No defined methods

A.4.8 TimeEvent

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.4.9 UIEvent

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

Event types that are UIEvents: focusin, focusout, activate, MouseEvent, TextEvent, KeyboardEvent, WheelEvent.

IDL Definition
interface UIEvent : Event
{
	readonly attribute long detail;
};
No defined constants
Attributes
detail
Specifies detailed information about the UIEvent, the information depends on the type of event. For focusin and focusout the detail field is not used. For activate the detail field indicates the type of activation that occurs: 1 for a simple activation (e.g. a simple click or Enter), 2 for hyperactivation (for instance a double click or Shift Enter).
No defined methods

A.4.10 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 "wheel" 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: wheel.

IDL Definition
interface WheelEvent : UIEvent
{
	readonly attribute unsigned 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.4.11 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 preload.

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 postload.

The user agent may dispatch ProgressEvents between the preload event and the postload events. Such events are of type loadProgress.

Event types that are ProgressEvents: loadProgress, preload, postload.

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 'preload' or 'postload' event.
total
Specifies the expected total number of bytes expected in a load operation. For a 'loadProgress' 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) {
var progressBar = document.getElementById('progressBar');
progressBar.setFloatTrait("width", 0);
var loadAnimation = document.getElementById('loadAnimation');
loadAnimation.beginElement();
}

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

function imageLoadComplete (evt) {
var progressBar = document.getElementById('progressBar');
progressBar.setFloatTrait("width", 100);
var loadAnimation = document.getElementById('loadAnimation');
loadAnimation.endElement();
}
]]></script>

<image 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 id="loadAnimation" ... />

<rect id="progressBar" ... />
</svg>

A.4.12 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: connectionConnected, connectionDataSent, connectionDataReceived, connectionClosed, connectionError.

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.5 Module: smil

A.5.1 ElementTimeControl

This interface defines common methods for elements which define animation behaviors compatible with SMIL Animation (Timed Elements and the svg element).
IDL Definition
interface ElementTimeControl
{
	void beginElementAt(in float offset);
	void beginElement();
	void endElementAt(in float offset);
	void endElement();
	void pauseElement();
	void resumeElement();
	readonly attribute boolean isPaused;
};
No defined constants
Attributes
isPaused
true if the animation is paused. false otherwise. See Paused element and the active duration.

Note: An element that is stopped (has reached the end of its active duration) is not paused.
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
pauseElement
Pauses the timed element. See Paused element and the active duration.
No Parameters
No Return value
No Exceptions
resumeElement
Resumes the timed element. See Paused element and the active duration.
No Parameters
No Return value
No Exceptions

A.6 Module: global

A.6.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.6.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;
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.
No defined attributes
No defined methods

A.6.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 'connectionConnected' to event handlers registered on that Connection object.

After data has been successfully sent, the Connection object must dispatch a ConnectionEvent with the type 'connectionDataSent' 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 'connectionDataReceived' to event handlers registered on that Connection object.

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

If an error occurs, a ConnectionEvent with the type 'connectionError' 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 connectionDataSent 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 connectionDataSent event except when an error occurs.

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, an GlobalException of type NOT_CONNECTED_ERR MUST be raised. Once the connection is established, the connected field must be set to true.

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.6.4 Timer

The Timer interface provides an API for scheduling execution. A Timer object is always either in the running (attribute running is true) or waiting (attribute running is false) state. After each iteration of the timer, an Event of type 'timer' is triggered.
IDL Definition
interface Timer : events::EventTarget
{
	attribute long delay;
	attribute long interval;
	readonly attribute boolean running;
	void start();
	void stop();
};
No defined constants
Attributes
delay
Initial delay before the first execution is fired, 0 meaning fire as soon as possible.
interval
The period between each execution, if -1, no additional execution will be fired.
running
The current state of the timer: true if the timer is running, false if the timer isn't running.
Methods
start
Starts the timer.
No Parameters
No Return value
No Exceptions
stop
Stops the timer.
No Parameters
No Return value
No Exceptions

A.7 Module: svg

A.7.1 SVGException

An exception thrown for SVG-specific errors, such as noninvertable matrix in inverse.
IDL Definition
exception SVGException
{
	unsigned short code;
};

// ExceptionCode
const unsigned short SVG_INVALID_VALUE_ERR = 1;
const unsigned short SVG_MATRIX_NOT_INVERTABLE = 2;
Constants
SVG_INVALID_VALUE_ERR
Value passed to an SVG-specific method is invalid, such as out of range color component in createSVGRGBColor.
SVG_MATRIX_NOT_INVERTABLE
Matrix that has a determinant equal to zero, and therefore not invertable.
No defined attributes
No defined methods

A.7.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.7.3 SVGElementInstance

For each 'use' element, the uDOM represents the referenced content with a shadow tree of SVGElementInstance objects (the "instance tree") of type SVGElementInstance. An SVGElementInstance represents a single Node in the instance tree.

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 SVGElement 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 SVGElement object for the 'g', and then two child SVGElementInstance objects, each of which has its correspondingElement that is an SVGElement object representing the 'rect'. Note however that the uDOM does not provide methods to navigate between an SVGElementInstance and its children SVGElementInstances.

IDL Definition
interface SVGElementInstance : EventTarget
{
	readonly attribute SVGElement correspondingElement;
	readonly attribute SVGElement correspondingUseElement;
};
No defined constants
Attributes
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 SVGElement object for the 'rect' element.
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).
No defined methods
Example: Ecma script 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 becouse the 'currentTarget' attribute would return an 'SVGElement' that doesen'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 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 id="r2" x="250" y="50" width="90" height="65"/>

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

<handler id="handler" type="application/ecma">changeColor(evt);</handler>

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

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

A.7.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 potentialy 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, SVGAnimationElement
{
	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;
	attribute float currentTime;
	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);
	DOMObject 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 either exactly match SVG and CSS's "px" coordinates or utilize a similar approach.

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.

currentTime
On read : Returns the current animation timeline time in seconds.

On write : Sets the current animation timeline 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.
Methods
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 intial 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.
Parameters
in long red The red component of the SVGRGBColor.
in long green The green component of the SVGRGBColor.
in long blue The blue component of the SVGRGBColor.
Return value
SVGRGBColor The created SVGRGBColor.
Exceptions
SVGException
SVG_INVALID_VALUE_ERR: Raised if any of the parameters are not in the 0 to 255 range.
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 a DOMObject because the currently focused object may be an object outside the SVG namespace. If the currently focused object is in the SVG namespace, it should be cast to events::EventTarget.

In the case of standalone SVG documents, this method should never return null because for standalone SVG documents a User Agent must always have a currently focused object.
No Parameters
Return value
DOMObject The currently focused object.
No Exceptions

A.7.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
{
	readonly attribute unsigned long red;
	readonly attribute unsigned long green;
	readonly 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.7.6 SVGRect

This interface represents an SVGRect datatype, consisting of a minimum X, minimum Y, width and height values.
IDL Definition
interface SVGRect
{
	attribute float x;
	attribute float y;
	attribute float width;
	attribute float height;
};
No defined constants
Attributes
x
On read : Returns the minimum X value for this SVGRect.

On write : Sets the minimum X value of this SVGRect to the specified value.
y
On read : Returns the minimum Y value for this SVGRect.

On write : Sets the minimum Y value of this SVGRect to the specified value.
width
On read : Returns the width for this SVGRect.

On write : Sets the width of this SVGRect to the specified value.
height
On read : Returns the height for this SVGRect.

On write : Sets the height of this SVGRect to the specified value.
No defined methods

A.7.7 SVGPoint

This interface represents an SVGPoint datatype, identifiend by its x and y components.
IDL Definition
interface SVGPoint
{
	attribute float x;
	attribute float y;
};
No defined constants
Attributes
x
On read : Returns the x component of the SVGPoint.

On write : Sets the x component of the SVGPoint to the specified float value.
y
On read : Returns the y component of the SVGPoint.

On write : Sets the y component of the SVGPoint to the specified float value.
No defined methods

A.7.8 SVGPath

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

Path data passing through 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 ASCII code of the letter 'M'.
LINE_TO
Numeric value is ASCII code of the letter 'L'.
CURVE_TO
Numeric value is ASCII code of the letter 'C'.
QUAD_TO
Numeric value is ASCII code of the letter 'Q'.
CLOSE
Numeric value is ASCII code of the letter 'Z'.
Attributes
numberOfSegments
Return number of segments in this path.
Methods
getSegment
Returns segment command by zero-based command index.
Parameters
in unsigned long cmdIndex The command index for the segment command to retrieve.
Return value
unsigned short The segment command. One of MOVE_TO, LINE_TO, CURVE_TO, QUAD_TO or CLOSE
Exceptions
DOMException
INDEX_SIZE_ERR: Raised if segment index is out of bounds or param index is out of bounds for this segment's type.
getSegmentParam
Returns segment parameter by zero-based command index and zero-based parameter index.
Parameters
in float cmdIndex The command index for the segment command.
in float paramIndex The parameter index to retrieve.
Return value
float The segment parameter.
Exceptions
DOMException
INDEX_SIZE_ERR: Raised if segment index out of bounds or param index out of bounds for this segment's type.
moveTo
Appends an 'M' (absolute move) segment to the path with the specified coordinates.
Parameters
in float x The x-axis coordinate for the specified point.
in float y The y-axis coordinate for the specified point.
No Return value
No Exceptions
lineTo
Appends an 'L' (absolute line) segment to the path with the specified coordinates.
Parameters
in float x The x-axis coordinate for the specified point.
in float y The y-axis coordinate for the specified point.
No Return value
No Exceptions
quadTo
Appends a 'Q' (absolute quadratic curve) segment to the path.
Parameters
in float x1 The x-axis coordinate of the first control point.
in float y1 The y-axis coordinate of the first control point.
in float x2 The x-axis coordinate of the final end point.
in float y2 The y-axis coordinate of the final end point.
No Return value
No Exceptions
curveTo
Appends a 'C' (absolute cubic curve) segment to the path.
Parameters
in float x1 The x-axis coordinate of the first control point.
in float y1 The y-axis coordinate of the first control point.
in float x2 The x-axis coordinate of the second end point.
in float y2 The y-axis coordinate of the second end point.
in float x3 The x-axis coordinate of the final end point.
in float y3 The y-axis coordinate of the final end point.
No Return value
No Exceptions
close
Numeric value is ASCII code of the letter 'Z'.

A.7.9 SVGMatrix

This interface represents an SVGMatrix datatype, identified by an affine transform. It can be used to read and modify the values of the 'transform' attribute.

Note: The mTranslate, inverse, mMultiply, mScale and mRotate methods in this interface mutate the SVGMatrix object and return a reference to the SVGMatrix instance itself, after performing the necessary matrix operation.

This matrix transforms source coordinates (x, y) into destination coordinates (x', y') by considering them to be a column vector and multiplying the coordinate vector by the matrix according to the following process:

[ x' ]    [  a  c  e  ]   [ x ]    [ a.x + c.y + e ]
[ y' ] =  [  b  d  f  ]   [ y ] =  [ b.x + d.y + f ]
[ 1  ]    [  0  0  1  ]   [ 1 ]    [        1      ]
IDL Definition
interface SVGMatrix
{
	float getComponent(in unsigned long index) raises(DOMException);
	SVGMatrix mMultiply(in SVGMatrix secondMatrix);
	SVGMatrix inverse() raises(SVGException);
	SVGMatrix mTranslate(in float x, in float y);
	SVGMatrix mScale(in float scaleFactor);
	SVGMatrix mRotate(in float angle);
};
No defined constants
No defined attributes
Methods
getComponent
Returns a component of the matrix by the component's zero-based index. getComponent(0) is a, getComponent(1) is b, etc.
Parameters
in unsigned long index The index of the matrix component to retrieve.
Return value
float The matrix component.
Exceptions
DOMException
INDEX_SIZE_ERR: Raised if the index is invalid.
mMultiply
Performs matrix multiplication. This matrix is post-multiplied by another matrix, returning the resulting current matrix.
Parameters
in SVGMatrix secondMatrix The matrix to post-multiply with.
Return value
SVGMatrix The resulting current matrix.
No Exceptions
inverse
Returns a new instance of SVGMatrix containing the inverse of the current matrix.
No Parameters
Return value
SVGMatrix The inverse of the current matrix.
Exceptions
SVGException
SVG_MATRIX_NOT_INVERTABLE: Raised when determinant of this matrix is zero.
mTranslate
Post-multiplies a translation transformation on the current matrix and returns the resulting current matrix. This is equivalent to calling multiply(T), where T is an SVGMatrix object represented by the following matrix:
[   1    0    x  ]
[   0    1    y  ]
[   0    0    1  ]
Parameters
in float x The distance by which coordinates are translated in the X axis direction.
in float y The distance by which coordinates are translated in the Y axis direction.
Return value
SVGMatrix The resulting current matrix.
No Exceptions
mScale
Post-multiplies a uniform scale transformation on the current matrix and returns the resulting current matrix. This is equivalent to calling multiply(S), where S is an SVGMatrix object represented by the following matrix:
[   scaleFactor      0          0   ]
[   0          scaleFactor      0   ]
[   0                0          1   ]
Parameters
in float scaleFactor The factor by which coordinates are scaled along the X and Y axis.
Return value
SVGMatrix The resulting current matrix.
No Exceptions
mRotate
Post-multiplies a rotation transformation on the current matrix and returns the resulting current matrix. This is equivalent to calling multiply(R), where R is an SVGMatrix object represented by the following matrix:
[ cos(angle) -sin(angle) 0 ]
[ sin(angle)  cos(angle) 0 ]
[ 0           0          1 ]
Parameters
in float angle The angle of rotation in degrees.
Return value
SVGMatrix The resulting current matrix.
No Exceptions

A.7.10 SVGLocatable

Interface for getting information about the location of elements. Note: Animations will have an effect on the values of bounding box.
IDL Definition
interface SVGLocatable
{
	SVGRect   getBBox();
	SVGMatrix getScreenCTM();
	SVGRect   getScreenBBox();
};
No defined constants
No defined attributes
Methods
getBBox
Returns the tight bounding box in current user coordinate space (i.e. after application of the 'transform' attribute or the viewbox). Tight bounding box is the smallest possible rectangle that includes the geometry of all contained graphics elements excluding stroke. The calculation is done in the user coordinate space of the element. When the bounding box is calculated elements with the 'display' property (trait) set to none are ignored.
No Parameters
Return value
SVGRect The tight bounding box in current user coordinate space. The returned object is a copy of the current bounding box value and will not change if the corresponding bounding box changes.
No Exceptions
getScreenCTM
Returns the transformation matrix from current user units to the initial viewport coordinate system. DOM MouseEvent clientX and clientY coordinates are in the initial viewport coordinate system. Note that null is returned if this element is not hooked into the document tree. This method would have been more aptly named as getClientCTM, but the name getScreenCTM is kept for historical reasons.
No Parameters
Return value
SVGMatrix The transformation matrix. The returned object is a copy of the current screen CTM value and will not change if the corresponding screen CTM changes.
No Exceptions
getScreenBBox
Returns the tight bounding box in screen coordinate space. Tight bounding box is the smallest possible rectangle that includes the geometry of all contained graphics elements excluding stroke. The box coordinates are in the initial viewport coordinate system, which is connected to the current user coordinate space by the matrix returned by the SVGLocatable::getScreenCTM method.

Note: null is returned if this element is not hooked into the document tree.
No Parameters
Return value
SVGRect The tight bounding box in screen coordinate space. The returned object is a copy of the current screen bounding box value and will not change if the corresponding screen bounding box changes.
No Exceptions

The following examples further clarify the behavior of the getBBox() method. The examples have a short explanation, an SVG fragment and are followed by a set of bounding box values which have the following format:



[elementId] : {x, y, width, height} | {null}




where x, y, width and height define the values of the SVGRect object's returned from a getBBox call on the element with the specified id. There are a few cases where the bounding box may be null (see example 6).



Example #1: Simple groups and bounds

This first example shows the values returned by the getBBox method for various simple basic shapes and groups. In particular, it shows that the transform, on an element, does not change the value of its user space bounding box.
<g id="group1" transform="translate(10, 20)" fill="red">
<rect id="rect1" transform="scale(2)" x="10" y="10" width="50" height="50"/>
<rect id="rect2" x="10" y="10" width="100" height="100"/>
<g id="group2" transform="translate(10, 20)">
<rect id="rect3" x="0" y="10" width="150" height="50"/>
<circle id="circle1" cx="20" cy="20" r="100" />
</g>
</g>

Result:

[group1] : {-70.0, -60.0, 230.0, 200.0}

[rect1] : {10.0, 10.0, 50.0, 50.0}

[rect2] : {10.0, 10.0, 100.0, 100.0}

[group2] : {-80.0, -80.0, 230.0, 200.0}

[rect3] : {0.0, 10.0, 150.0, 50.0}

[circle1] : {-80.0, -80.0, 200.0, 200.0}



Example #2: Bounding box on zero width or height rectangle

This example illustrates that the bounding box on elements is based on the element's geometry coordinates. For example, the bounding box on a zero-width rectangle is defined (see below), even though the rectangle is not rendered.
<g id="group1" transform="translate(10, 20)" fill="red">
<rect id="rect2" x="10" y="10" width="400" height="0"/>
<g id="group2" transform="translate(10, 20)">
<rect id="rect3" x="0" y="10" width="150" height="50"/>
</g>
</g>

Result:

[group1] : {10.0, 10.0, 400.0, 70.0}

[rect2] : {10.0, 10.0, 400.0, 0.0}

[group2] : {0.0, 10.0, 150.0, 50.0}

[rect3] : {0.0, 10.0, 150.0, 50.0}



Example #3: Bounding Box on zero radius ellipses.

This is another example of how bounding boxes are based on the element's geometry. Here, the bounding box of an ellipse with a zero x-axis radius is still defined, even though the ellipse is not rendered.
<svg id="mySVG" version="1.2" baseProfile="tiny" width="10" height="20">
<g id="group1" transform="translate(10, 20)" fill="red">
<rect id="rect1" x="10" y="10" width="100" height="100"/>
<ellipse id="ellipse1" cx="20" cy="20" rx="0" ry="70" />
</g>
</svg>

Result:

[mySVG] : {20.0, -30.0, 100.0, 160.0}

[group1] : {10.0, -50.0, 100.0, 160.0}

[rect1] : {10.0, 10.0, 100.0, 100.0}

[ellipse1] : {20.0, -50.0, 0.0, 140.0}



Example #4: Viewports do not clip bounding boxes

This example shows that no matter what the viewport is on the root SVG element, the bounding boxes, based on the geometry, are still defined. Here, even though the root svg has a zero width, the bounding boxes for the root itself and its children is precisely defined.
<svg id="mySVG" version="1.2" baseProfile="tiny" width="0" height="50">
<g id="group1" transform="translate(10, 20)" fill="red" >
<rect id="rect1" x="10" y="10" width="50" height="50"/>
<g id="group2" transform="translate(10, 20)">
<rect id="rect2" x="0" y="10" width="150" height="0"/>
<circle id="circle1" cx="20" cy="20" r="500"/>
</g>
</g>
</svg>

Result:

[mySVG] : {-460.0, -440.0, 1000.0, 1000.0}

[group1] : {-470.0, -460.0, 1000.0, 1000.0}

[rect1] : {10.0, 10.0, 50.0, 50.0}

[group2] : {-480.0, -480.0, 1000.0, 1000.0}

[rect2] : {0.0, 10.0, 150.0, 0.0}

[circle1] : {-480.0, -480.0, 1000.0, 1000.0}



Example #5: getBBox on <use>

This example shows that the bounding box for a 'use' element accounts for the x and y attributes defined on the element, just like the x and y attributes impact the bounding box computation on a 'rect' or on an 'image' element.
<svg version="1.2" baseProfile="tiny">
<defs>
<rect id="myRect" x="0" y="0" width="60" height="40"/>
</defs>
<use id="myUse" xlink:href="#myRect" x="-30" y="-20"/>
</svg>

Result:

[myRect] : {0.0, 0.0, 60.0, 40.0}

[myUse] : {-30.0, -20.0, 60.0, 40.0}



Example #6: Empty group

This example shows that the bounding box for an empty group is null. By the same token, the bounding box of a 'path' with an empty SVGPath (i.e. one with no path commands, which may happen after creating a new 'path' element with a createElementNS call) is also null.
<g id="emptyG"/>

Result:

[emptyG] : {null}



Example #7: Impact of display='none' and visibility='hidden'

This example shows how the bounding box of children with display='none' are not accounted for in the computation of their parent's bounding box. This reflects the definition of the 'display' property and its impact on rendering and bounding box computation. The example also shows that elements with a 'hidden' 'visibility' still contribute to their parent's bounding box computation.
<g id="g1">
<g id="g1.1.display.none" display="none">
<rect id="rect1" x="10" y="10" width="40" height="40"/>
<g/>
<rect id="rect2.visibility.hidden" visibility="hidden" x="30" y="60" width="10" height="20"/>
</g>

Result:

[g1] : {30.0, 60.0, 10.0, 20.0}

[g1.1.display.none] : {10.0, 10.0, 40.0, 40.0}

[rect1] : {10.0, 10.0, 40.0, 40.0}

[rec2.visibility.hidden] : {30.0, 60.0, 10.0, 20.0}



Example #8: Concatenating bounding boxes in the container's user space

This example shows how the concatenation and computation of bounding boxes for container element happens in the container's user space.
<g id="g1">
<line id="line1" x2="100" y2="100" transform="rotate(-45)"/>
</g>

Result:

[g1] : {0.0, 0.0, 141.42136, 0}

[line1] : {0.0, 0.0, 100.0, 100.0}



Example #9: No influence of stroke-width

This example illustrates that stroking has no impact on the computation of bounding boxes.
<g>
<line id="thickLine" stroke-width="10" x2="100" y2="0"/>
</g>

Result:

[thickLine] : {0.0, 0.0, 100.0, 0.0}



Example #10: No influence of viewBox

This example illustrates that the viewBox has no impact on the computation of bounding boxes.
<svg id="rootSvg" version="1.2" baseProfile="tiny" width="500" height="300" viewBox="0 0 200 100">
<rect x="-100" y="-200" width="500" height="100"/>
</svg>

Result:

[rootSVG] : {-100, -200, 500, 100}

A.7.11 SVGLocatableElement

This interface represents an element that has a physical location on the screen.

This interface is implemented by: 'rect', 'circle', 'ellipse', 'line', 'path', 'use', 'image', 'text', 'textArea', 'tspan', 'svg', 'a', 'video', 'animation', 'switch', 'foreignObject', 'polygon', 'polyline' and 'g'.
IDL Definition
interface SVGLocatableElement : SVGElement, SVGLocatable
{
};
No defined constants
No defined attributes
No defined methods

A.7.12 TraitAccess

Trait manipulation interface. This interface is used read and manipulate the value of "traits" associated with an SVGElement. Each trait corresponds to an attribute or property, which is parsed and understood by the element and in most cases animatable. Unlike attributes, each element has a well-defined set of traits and attempting to access an undefined trait may throw an exception. Also unlike attributes traits are typed and their values are normalized; for instance SVG 'path' specification is parsed and all path commands are converted to their absolute variants, it is not possible to say through the value of the trait if a path command was absolute or relative. When getting and setting trait values, accessor of the correct type must be used or exception will be thrown.

Initial trait values come from parsing corresponding attributes. If a value is not specified, but a corresponding attribute (or property for environments where styling is supported) is inherited, inherited value is returned as a result of the trait query method. If it is not inherited, default value is returned. Default values are also returned in the case when there is no parent to inherit from, for ex: when you create a new element, set a trait value to 'inherit', but there is no parent for inheritance. The different getTrait methods (getTrait, getTraitNS, getFloatTrait, ...) always returns a base value (i.e. before animation is applied), and this is true for both static and animated content. The different getPresentationTrait methods (getPresentationTrait, getPresentationTraitNS, getFloatPresentationTrait, ...) return either the current animated value if the given trait is currently being animated (per the SMIL specification) or the base value if the given trait is not currently being animated. Not all attributes are accessible by traits, see the table of supported attributes.

Setting a trait value has the same effect as changing a corresponding attribute, but trait setters can operate on typed values. The value which is modified is always a base value. For inheritable traits the trait value can always be set to 'inherit' (but querying the value will always return the actual inherited value as explained above).

Note about invalid/unsupported trait values: There are two situations where the various trait setter methods (such as setTrait, setFloatTrait or setPathTrait methods) consider a value invalid and throw a DOMException with the INVALID_ACCESS_ERR code.

The trait methods will consider the value to be invalid if its 'in error'.

The second situation is when the trait value is invalid with regards to animations currently applied to the trait. The value is considered invalid because it would put the animation, and therefore the document, in an error state. For example, if a 'path' element has animations on its 'd' attribute, trying to change the 'd' attribute to a value incompatible with the animations will cause the exception to happen.

The trait setter methods will consider a value unsupported when it complies with the definition for an 'unsupported value'. This will result in a DOMException thrown with the NOT_SUPPORTED_ERR code. For example, trying to set the 'stroke-linejoin' trait to 'foo' would cause this exception.

IDL Definition
interface TraitAccess
{
	DOMString getTrait(in DOMString name) raises(DOMException);
	DOMString getTraitNS(in DOMString namespaceURI, in DOMString name) raises(DOMException);
	float getFloatTrait(in DOMString name) raises(DOMException);
	SVGMatrix getMatrixTrait(in DOMString name) raises(DOMException);
	SVGRect getRectTrait(in DOMString name) raises(DOMException);
	SVGPath getPathTrait(in DOMString name) raises(DOMException);
	SVGRGBColor getRGBColorTrait(in DOMString name) raises(DOMException);
	DOMString getPresentationTrait(in DOMString name) raises(DOMException);
	DOMString getPresentationTraitNS(in DOMString namespaceURI, in DOMString name) raises(DOMException);
	float getFloatPresentationTrait(in DOMString name) raises(DOMException);
	SVGMatrix getMatrixPresentationTrait(in DOMString name) raises(DOMException);
	SVGRect getRectPresentationTrait(in DOMString name) raises(DOMException);
	SVGPath getPathPresentationTrait(in DOMString name) raises(DOMException);
	SVGRGBColor getRGBColorPresentationTrait(in DOMString name) raises(DOMException);
	void setTrait(in DOMString name, in DOMString value) raises(DOMException);
	void setTraitNS(in DOMString namespaceURI, in DOMString name, in DOMString value) raises(DOMException);
	void setFloatTrait(in DOMString name, in float value) raises(DOMException);
	void setMatrixTrait(in DOMString name, in SVGMatrix matrix) raises(DOMException);
	void setRectTrait(in DOMString name, in SVGRect rect) raises(DOMException);
	void setPathTrait(in DOMString name, in SVGPath path) raises(DOMException);
	void setRGBColorTrait(in DOMString name, in SVGRGBColor color) raises(DOMException);
};
No defined constants
No defined attributes
Methods
getTrait
Returns the trait value (possibly normalized) as a DOMString. In SVG Tiny only certain traits can be obtained as a DOMString value. Syntax of the returned DOMString matches the syntax of the corresponding attribute. This element is exactly equivalent to getTraitNS with namespaceURI set to null.
Parameters
in DOMString name The name of the trait to retrieve.
Return value
DOMString The trait value.
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null.
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to a DOMString (SVG Tiny only).
getTraitNS
Same as getTrait, but for namespaced traits. Parameter name must be a non-qualified trait name, i.e. without prefix.
Parameters
in DOMString namespaceURI The namespace of the trait to retrieve.
in DOMString name The name of the trait to retrieve.
Return value
DOMString The trait value.
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null.
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to a DOMString (SVG Tiny only).
getFloatTrait
Get the trait value as a float.
Parameters
in DOMString name The name of the trait to retrieve.
Return value
float The trait value as a float.
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null.
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to a float.
getMatrixTrait
Returns the trait value as an SVGMatrix. The returned object is a copy of the actual trait value and will not change if the corresponding trait changes.
Parameters
in DOMString name The name of the trait to retrieve.
Return value
SVGMatrix The trait value as an SVGMatrix.
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null.
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to an SVGMatrix.
getRectTrait
Returns the trait value as an SVGRect. The returned object is a copy of the actual trait value and will not change if the corresponding trait changes.
Parameters
in DOMString name The name of the trait to retrieve.
Return value
SVGRect The trait value as an SVGRect.
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null.
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to an SVGRect.
getPathTrait
Returns the trait value as an SVGPath. The returned object is a copy of the actual trait value and will not change if the corresponding trait changes.
Parameters
in DOMString name The name of the trait to retrieve.
Return value
SVGPath The trait value as an SVGPath.
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null.
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to an SVGPath.
getRGBColorTrait
Returns the trait value as an SVGRGBColor. The returned object is a copy of the trait value and will not change if the corresponding trait changes. If the actual trait value is not an SVGRGBColor, i.e. 'none' or a link to a paint server (e.g. to a gradient or a solid-color), this method must raise a DOMException with error code TYPE_MISMATCH_ERR.
Parameters
in DOMString name The name of the trait to retrieve.
Return value
SVGRGBColor The trait value as an SVGRGBColor.
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null.
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to an SVGRGBColor.
getPresentationTrait
Returns the trait presentation value as a DOMString. In SVG Tiny only certain traits can be obtained as a DOMString value. Syntax of the returned DOMString matches the syntax of the corresponding attribute. This element is exactly equivalent to getPresentationTraitNS with namespaceURI set to null.
Parameters
in DOMString name The name of the trait to retrieve.
Return value
DOMString The trait presentation value.
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null.
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to a DOMString (SVG Tiny only).
getPresentationTraitNS
Same as getPresentationTrait, but for namespaced traits. The parameter name must be a non-qualified trait name, i.e. without prefix.
Parameters
in DOMString namespaceURI The namespace of the trait to retrieve.
in DOMString name The name of the trait to retrieve.
Return value
DOMString The trait presentation value.
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null.
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to a DOMString (SVG Tiny only).
getFloatPresentationTrait
Get the trait presentation value as a float.
Parameters
in DOMString name The name of the trait to retrieve.
Return value
float The trait presentation value as a float.
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null.
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to a float.
getMatrixPresentationTrait
Returns the trait presentation value as an SVGMatrix. The returned object is a copy of the actual trait value and will not change if the corresponding trait changes or as animation continue to affect the trait presentation value.
Parameters
in DOMString name The name of the trait to retrieve.
Return value
SVGMatrix The trait presentation value as an SVGMatrix.
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null.
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to an SVGMatrix.
getRectPresentationTrait
Returns the trait presentation value as an SVGRect. The returned object is a copy of the actual trait value and will not change if the corresponding trait changes or as animation continue to affect the trait presentation value.
Parameters
in DOMString name The name of the trait to retrieve.
Return value
SVGRect The trait presentation value as an SVGRect.
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null.
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to an SVGRect.
getPathPresentationTrait
Returns the trait presentation value as an SVGPath. The returned object is a copy of the actual trait value and will not change if the corresponding trait changes or as animation continue to affect the trait presentation value.
Parameters
in DOMString name The name of the trait to retrieve.
Return value
SVGPath The trait presentation value as an SVGPath.
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null.
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to an SVGPath.
getRGBColorPresentationTrait
Returns the trait presentation value as an SVGRGBColor. The returned object is a copy of the trait value and will not change if the corresponding trait changes or as animation continue to affect the trait presentation value. If the actual trait presentation value is not an RGBColor (i.e. "none"), this method will return null.
Parameters
in DOMString name The name of the trait to retrieve.
Return value
SVGRGBColor The trait presentation value as an SVGRGBColor.
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null.
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to an SVGRGBColor.
setTrait
Set the trait value as a DOMString. In SVG Tiny only certain traits can be set through a DOMString value. The syntax of the DOMString that should be given as a value must be the same as syntax of the corresponding XML attribute value. Exactly equivalent to setTraitNS with the namespaceURI attribute set to null.
Parameters
in DOMString name The name of the trait to be set.
in DOMString value The value of the trait.
No Return value
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or an attempt has been made to set an unsupported value.
DOMException
TYPE_MISMATCH_ERR: Raised if the requested trait's value cannot be specified as a DOMString.
DOMException
INVALID_ACCESS_ERR: Raised if the input value is an invalid value for the given trait or null is specified.
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised if attempt is made to change a readonly trait.
setTraitNS
Same as setTrait, but for namespaced traits. The parameter name must be a non-qualified trait name, i.e. without prefix.
Parameters
in DOMString namespaceURI The namespace of the trait to be set.
in DOMString name The name of the trait to be set.
in DOMString value The value of the trait.
No Return value
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or an attempt has been made to set an unsupported value.
DOMException
TYPE_MISMATCH_ERR: Raised if the requested trait's value cannot be specified as a DOMString.
DOMException
INVALID_ACCESS_ERR: Raised if the input value is an invalid value for the given trait or null is specified. This error is also thrown when the 'use' element is hooked into the document tree and the the value of 'xlink:href' is set invalid.
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised if attempt is made to change a readonly trait.
setFloatTrait
Set the trait value as a float.
Parameters
in DOMString name The name of the trait to be set.
in float value The value of the trait.
No Return value
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element.
DOMException
TYPE_MISMATCH_ERR: Raised if the requested trait's value cannot be specified as a float.
DOMException
INVALID_ACCESS_ERR: Raised if the input value is an invalid value for the given trait or null is specified.
setMatrixTrait
Set the trait value as an SVGMatrix. Values in SVGMatrix are copied in the trait so subsequent changes to the given SVGMatrix have no effect on the value of the trait.
Parameters
in DOMString name The name of the trait to be set.
in SVGMatrix value The value of the trait.
No Return value
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element.
DOMException
TYPE_MISMATCH_ERR: Raised if the requested trait's value cannot be specified as an SVGMatrix.
DOMException
INVALID_ACCESS_ERR: Raised if the input value is null.
setRectTrait
Set the trait value as an SVGRect. Values in SVGRect are copied in the trait so subsequent changes to the given SVGRect have no effect on the value of the trait.
Parameters
in DOMString name The name of the trait to be set.
in SVGRect value The value of the trait.
No Return value
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element.
DOMException
TYPE_MISMATCH_ERR: Raised if the requested trait's value cannot be specified as an SVGRect.
DOMException
INVALID_ACCESS_ERR: Raised if the input value is an invalid value for the given trait or null is specified. An SVGRect is invalid if the width or height values are set to negative..
setPathTrait
Set the trait value as an SVGPath. Values in SVGPath are copied in the trait so subsequent changes to the given SVGPath have no effect on the value of the trait.
Parameters
in DOMString name The name of the trait to be set.
in SVGPath value The value of the trait.
No Return value
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element.
DOMException
TYPE_MISMATCH_ERR: Raised if the requested trait's value cannot be specified as an SVGPath.
DOMException
INVALID_ACCESS_ERR: Raised if the input value is an invalid value for the given trait or null is specified. An SVGPath is invalid if it begins with any segment other than MOVE_TO segment.

Note: An empty SVGPath is still a valid value.
setRGBColorTrait
Set the trait value as an SVGRGBColor. Values in SVGRGBColor are copied in the trait so subsequent changes to the given SVGRGBColor have no effect on the value of the trait.
Parameters
in DOMString name The name of the trait to be set.
in SVGRGBColor value The value of the trait.
No Return value
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element.
DOMException
TYPE_MISMATCH_ERR: Raised if the requested trait's value cannot be specified as an SVGRGBColor.
DOMException
INVALID_ACCESS_ERR: Raised if the input value is null.

Traits supported in this specification, SVG Tiny 1.2 uDOM

Trait access is not required on all of the SVG Tiny attributes and properties. The table below shows the attributes and properties that SVG Tiny DOM 1.2 implementations must support trait access to. Each attribute row lists the allowed getter and setter(s). The 'Default Values' column specifies the default values that must be used for each attribute or property. If a 'Default Values' column entry is empty, there is no default value. Unless explicitly stated in the 'Comments' column, a supported attribute is accessible on all elements it can belong to. See the attribute section for a list of attributes and which elements they belong to.

Implementations that support multiple versions of svg must allow trait access to the most extensive set and support the types supported by each trait in the most extensive set. However, content relying on traits or trait types available in future versions may not work in all conformant SVG Tiny 1.2 uDOM implementations.

For 'REQUIRED' attributes, there are two cases:

The User Agent must raise a NOT_SUPPORTED_ERR whenever there is an attempt to use trait methods for traits which are not supported by the UA.

Note: For some of the attributes and data types additional rules apply. These rules are defined below the table.

Note: In the table below:

Attribute Trait Getter Trait Setter Default Values Comments
accumulate getTrait [none | sum] setTrait [none | sum] none
additive getTrait [replace | sum] setTrait [replace | sum] replace
attributeName getTrait setTrait
audio-level getFloatTrait [value >= 0 && value <= 1] setFloatTrait [value >= 0 && value <= 1]

setTrait [inherit]
1.0f
baseProfile getTrait Not available (readonly) "tiny"
begin N/A setTrait
calcMode getTrait [discrete | linear | paced | spline] setTrait [discrete | linear | paced | spline] linear (except for animateMotion)

paced (for animateMotion)
color getRGBColorTrait [SVGRGBColor]

getTrait [SVGRGBColor]
setRGBColorTrait [SVGRGBColor]

setTrait [inherit | SVGRGBColor]
rgb(0,0,0) -See RGB access rule.
cx getFloatTrait setFloatTrait 0.0f
cy getFloatTrait setFloatTrait 0.0f
d getPathTrait [SVGPath] setPathTrait [SVGPath] REQUIRED(Empty SVGPath)
display getTrait [inline | none ] setTrait [inline | none | inherit ] "inline" -See Display access rule.
dur N/A setTrait
editable getTrait [true | false] setTrait [true | false] "false"
fill getRGBColorTrait [SVGRGBColor]

getTrait [none | SVGRGBColor]
setRGBColorTrait [SVGRGBColor]

setTrait [none | currentColor | inherit | SVGRGBColor]
rgb(0,0,0) -See RGB access rule.

-Attribute defining the fill-color.
fill getTrait[freeze | remove] setTrait[freeze | remove] "remove" -Attribute defining the fill behavior of a smil animation element.
fill-opacity getFloatTrait [value >= 0 && value <= 1] setFloatTrait [value >= 0 && value <= 1]

setTrait[inherit]
1.0f
fill-rule getTrait [nonzero | evenodd] setTrait [nonzero | evenodd | inherit] "nonzero"
focusable getTrait [true | false] setTrait [true | false | auto]
nav-right getTrait [auto | url(<Local IRI Reference>) | self] setTrait [url(<Local IRI Reference>) | auto | self] "auto"
nav-next getTrait [auto | url(<Local IRI Reference>) | self] setTrait [url(<Local IRI Reference>) | auto | self] "auto"
nav-up getTrait [auto | url(<Local IRI Reference>) | self] setTrait [url(<Local IRI Reference>) | auto | self] "auto"
nav-up-right getTrait [auto | url(<Local IRI Reference>) | self] setTrait [url(<Local IRI Reference>) | auto | self] "auto"
nav-up-left getTrait [auto | url(<Local IRI Reference>) | self] setTrait [url(<Local IRI Reference>) | auto | self] "auto"
nav-prev getTrait [auto | url(<Local IRI Reference>) | self] setTrait [url(<Local IRI Reference>) | auto | self] "auto"
nav-down getTrait [auto | url(<Local IRI Reference>) | self] setTrait [url(<Local IRI Reference>) | auto | self] "auto"
nav-down-right getTrait [auto | url(<Local IRI Reference>) | self] setTrait [url(<Local IRI Reference>) | auto | self] "auto"
nav-down-left getTrait [auto | url(<Local IRI Reference>) | self] setTrait [url(<Local IRI Reference>) | auto | self] "auto"
nav-left getTrait [auto | url(<Local IRI Reference>) | self] setTrait [url(<Local IRI Reference>) | auto | self] "auto"
focusHighlight getTrait [auto| none] setTrait [auto| none] "auto"
font-family getTrait [the font-family computed value listed in the same syntax as the font-family property] setTrait [same syntax as font-family attribute] User-Agent
font-size getFloatTrait [value >= 0] setFloatTrait [value >= 0]

setTrait [inherit]
User-Agent
font-style getTrait [normal | italic | oblique ] setTrait [normal | italic | oblique | inherit] "normal"
font-weight getTrait [100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 ] setTrait [normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit] "normal"
gradientUnits getTrait [userSpaceOnUse | objectBoundingBox] setTrait [userSpaceOnUse | objectBoundingBox] "objectBoundingBox"
height getFloatTrait [value >= 0] setFloatTrait [value >= 0] REQUIRED(0.0f) If the height is specified as a percentage or unit value (only possible for the 'svg' 'height'), a DOMException with error code TYPE_MISMATCH_ERR is raised since the requested trait's computed value cannot be converted to a float.
id getTrait setTrait
keyPoints N/A setTrait
keySplines N/A setTrait
keyTimes N/A setTrait
max N/A setTrait
min N/A setTrait
offset getFloatTrait[value >= 0 && value <= 1] setFloatTrait[value >= 0 && value <= 1]
opacity getFloatTrait [value >= 0 && value <= 1] setFloatTrait [value >= 0 && value <= 1]

setTrait[inherit]
path getPathTrait [SVGPath] setPathTrait [SVGPath] REQUIRED(Empty SVGPath)
r getFloatTrait [ value >= 0] setFloatTrait [value >= 0] REQUIRED (0.0f)
repeatCount N/A setTrait
repeatDur N/A setTrait
restart getTrait [always | whenNotActive | never] setTrait [always | whenNotActive | never] always
rx getFloatTrait [value >= 0] setFloatTrait [value >= 0] 0.0f
ry getFloatTrait [value >= 0] setFloatTrait [value >= 0] 0.0f
snapshotTime getFloatTrait [value >= 0] setFloatTrait [value >= 0] 0.0f
solid-color getRGBColorTrait [SVGRGBColor]

getTrait [SVGRGBColor]
setRGBColorTrait [SVGRGBColor]

setTrait [SVGRGBColor | inherit]
rgb(0,0,0) -See RGB access rule.
solid-opacity getFloatTrait [value >= 0 && value <= 1] setFloatTrait [value >= 0 && value <= 1]

setTrait [inherit]
1.0f
stop-color getRGBColorTrait [SVGRGBColor]

getTrait [none | SVGRGBColor]
setRGBColorTrait [SVGRGBColor]

setTrait(none | currentColor | inherit | SVGRGBColor]
rgb(0,0,0) -See RGB access rule.
stop-opacity getFloatTrait [value >= 0 && value <= 1] setFloatTrait [value >= 0 && value <= 1]

setTrait[inherit]
1.0f
stroke getRGBColorTrait [SVGRGBColor]

getTrait [none | SVGRGBColor]
setRGBColorTrait [SVGRGBColor]

setTrait [none | currentColor | inherit | SVGRGBColor]
"none" -See RGB access rule.
stroke-dashoffset getFloatTrait setTrait [inherit]

setFloatTrait
0.0f
stroke-linecap getTrait [butt | round | square] setTrait [butt | round | square | inherit] "butt"
stroke-linejoin getTrait [miter | round | bevel ] setTrait [miter | round | bevel | inherit] "miter"
stroke-miterlimit getFloatTrait [ value >= 1] setTrait [inherit]

setFloatTrait [value >= 1]
4.0f
stroke-opacity getFloatTrait [value >= 0 && value <= 1] setFloatTrait [value >= 0 && value <= 1]

setTrait[inherit]
1.0f
stroke-width getFloatTrait [value >= 0] setTrait [inherit]

setFloatTrait [value >= 0]
1.0f
target getTrait setTrait "_self"
"text" getTrait("#text") ["text content"] setTrait("#text", "text content") -See Text Node Access for details.
text-anchor getTrait [start | middle | end] setTrait [start | middle | end | inherit ] "start"
transform getMatrixTrait [SVGMatrix]

getTrait
setMatrixTrait [SVGMatrix]

setTrait
Identity matrix (1,0,0,1,0,0) -See Transform access rule.
type For animateTransform: getTrait [translate | scale | rotate | skewX | skewY] For animateTransform: setTrait [translate | scale | rotate | skewX | skewY]
values N/A setTrait
vector-effect getTrait [none | non-scaling-stroke] setTrait [none | non-scaling-stroke | inherit] "none"
version getTrait Not available (readonly) "1.2"
viewBox getRectTrait [null, SVGRect] setRectTrait [SVGRect]

setTrait [none]
null If the actual trait value is not an SVGRect (i.e. "none"), the getRectTrait method will return null.
viewport-fill getRGBColorTrait [SVGRGBColor]

getTrait [none | SVGRGBColor]
setRGBColorTrait [SVGRGBColor]

setTrait [none | currentColor | SVGRGBColor | inherit]
"none" -See RGB access rule.
viewport-fill-opacity getFloatTrait [value >= 0 && value <= 1] setFloatTrait [value >= 0 && value <= 1]

setTrait [inherit]
1.0f
visibility getTrait [visible | hidden] setTrait [visible | hidden | inherit] "visible"
width getFloatTrait [ value >= 0] setFloatTrait [ value >= 0] REQUIRED (0.0f) If the width is specified as a percentage or unit value (only possible for the 'svg' 'width'), a DOMException with error code TYPE_MISMATCH_ERR is raised since the requested trait's computed value cannot be converted to a float.
x getFloatTrait

(array of x-values not supported)
setFloatTrait

(array of x-values not supported)
0.0f
x1 getFloatTrait setFloatTrait 0.0f
x2 getFloatTrait setFloatTrait 0.0f
xlink:href getTraitNS [absolute IRI or ""] setTraitNS "".
y getFloatTrait

(array of y-values not supported)
setFloatTrait

(array of y-values not supported)
0.0f
y1 getFloatTrait setFloatTrait 0.0f
y2 getFloatTrait setFloatTrait 0.0f
zoomAndPan getTrait [disable | magnify] setTrait [disable | magnify] "magnify"

A.7.13 Additional accessing rules

Accessing rules for RGBColorTrait

The getRGBColorTrait is used to get the SVGRGBColor color. If the actual trait value is not an SVGRGBColor, i.e. 'none' or a link to a paint server (e.g. to a gradient or a solid-color), this method must raise a DOMException with error code TYPE_MISMATCH_ERR and getTrait should be used instead. setTrait must be used to set a color type that is not an SVGRGBColor.

Accessing rules for 'transform' attribute

The 'transform' attribute in SVGT1.2 can have three types of values. The "normal" transformation list (e.g. scale, translate, rotate, matrix etc), the newly introduced 'ref(svg)' type or 'none'. getMatrixTrait returns the current evaluated matrix in all cases. If the user needs to know that the 'transform' attribute value was a 'ref' or a 'none' he must call getTrait. By using setTrait he can set the 'transform' attribute to 'ref(svg)' or 'none'.

Accessing rules for 'display' property

Due to backward compatibility reasons the 'display' values accessible via the trait mechanism are limited to 'none' and 'inline', all other values are translated into 'none' or 'inline'. (For a list of all possible 'display' values, see Controlling visibility.) If other 'display' values are of interest, e.g. the user want to set display to 'block', the more generic getAttributeNS/setAttributeNS must be used. Note however that an SVGT1.2 user agent is allowed to normalize its attribute data as described in Display Normalization.

Accessing rules for animation and font related elements

The following rule applies to Smil-animation elements ('animate', 'animateTransform', 'animateColor', 'animateMotion', 'set') and font element with its children ('font', 'font-face', 'missing-glyph', 'glyph', 'hkern', 'font-face-src', 'font-face-uri', 'font-face-name').

These elements can be inserted and removed from the tree but they cannot be modified once inserted into the tree. Manipulating animations while they are in the uDOM tree and possiblely active would result in undefined behaviour. This may also have an effect on past resolved times. This restriction means that if the author wishes to add animations via script, the element must be modified when it is not attached to the tree. A similar reasoning applies to the different font elements, modifying them while attached to the tree might lead to unpredictable result. Following is an example of adding animation to the tree including setting the properties prior to insertion.

Example: Animating via the uDOM
<svg version="1.2" baseProfile="tiny" xmlns="http://www.w3.org/2000/svg" id="svg-root"
width="100%" height="100%" viewBox="0 0 480 360">
<rect id="myRect" fill="green" x="10" y="10" width="200" height="100" stroke="black" stroke-width="2"/>
</svg>
A script (java) such as the following might be used to add an animation to the rectangle:
SVGElement newAnimate = (SVGElement)document.createElementNS(svgNS, "animate");
newAnimate.setTrait("attributeName", "fill");
newAnimate.setTrait("from", "red");
newAnimate.setTrait("to", "blue");
newAnimate.setTrait("dur", "5");
newAnimate.setTrait("repeatCount", "10");
Element myRect = document.getElementById("myRect");
myRect.appendChild(newAnimate);

A.7.14 ElementTraversal

This interface provides a way to traverse elements in the uDOM tree. It is needed mainly because SVG Tiny uDOM does not expose character data nodes. Each element in the SVG Tiny document tree implements this interface. This applies to elements in the foreign namespaces as well.
IDL Definition
interface ElementTraversal
{
	readonly attribute Element firstElementChild;
	readonly attribute Element lastElementChild;
	readonly attribute Element nextElementSibling;
	readonly attribute Element previousElementSibling;
};
No defined constants
Attributes
firstElementChild
Returns the first child element node of this element. null if this element has no child elements.
lastElementChild
last child element node of this element. null if this element has no child elements.
nextElementSibling
Returns the next sibling element node of this element. null if this element has no element sibling nodes that come after this one in the document tree.
previousElementSibling
previous sibling element node of this element. null if this element has no element sibling nodes that come before this one in the document tree.
No defined methods

A.7.15 SVGElement

This interface represents an SVG element in the document tree. It provides methods to traverse elements in the uDOM tree and allows setting and getting the id of an element.

Note: See the definition of id and xml:id for the rules of how to treat id and xml:id.

IDL Definition
interface SVGElement : Element, EventTarget, TraitAccess, ElementTraversal
{
	attribute DOMString id;
};
No defined constants
Attributes
id
On read : Returns the Element's id, null if no id specified.

On write : Sets the Element's id attribute. See the description of how to handle multiple ID attribute in the Structure chapter.
No defined methods

A.7.16 SVGAnimationElement

This interface represents an SVGAnimationElement which is implemented by Timed Elements and the svg element.
IDL Definition
interface SVGAnimationElement : SVGElement, smil::ElementTimeControl
{
};
No defined constants
No defined attributes
No defined methods

A.7.17 SVGVisualMediaElement

This interface represents a media element that is visual, i.e. has a physical location on the screen.

This interface is implemented by: 'animation' and 'video'.
IDL Definition
interface SVGVisualMediaElement : SVGLocatableElement, SVGAnimationElement
{
};
No defined constants
No defined attributes
No defined methods

A.7.18 EventListenerInitializer2

EventListenerInitializer2 allows event listeners to be initialized. In typical usage with Java, a 'script' element references a JAR file which contains a manifest entry (SVG-Handler-Class) which identifies the class responsible for creating the event listeners. Further information about EventListenerInitializer2 can be found in the Scripting chapter.

Note: Script code must not invoke the EventListenerInitializer2 methods directly (they are are only called by the User Agent implementation during the parsing or execution of 'script', 'listener' or 'handler' elements). User Agents must prevent user scripts from invoking the methods.

IDL Definition
interface EventListenerInitializer2
{
	void initializeEventListeners( in Element scriptElement );
	EventListener createEventListener( in Element handlerElement );
};
No defined constants
No defined attributes
Methods
initializeEventListeners
For each 'script' element, at load time for that element, the user agent finds the appropriate object which implements the EventListenerInitializer2 interface. (For Java, it is the class identified by the SVG-Handler-Class manifest entry). The user agent then invokes the initializeEventListeners method, which allows the scripting code to register event listeners.
Parameters
in Element scriptElement The 'script' element which has been loaded.
No Return value
No Exceptions
createEventListener

For each <handler> element, at load time for that element, the user agent finds the appropriate object which implements the EventListenerInitializer2 interface. (For Java, it is the class identified by the SVG-Handler-Class manifest entry). The user agent then invokes the createEventListener method, which allows the scripting code to register an appropriate event listener.

This method returns the event listener that will handle events. The user agent must register this event listener with the event target identified by the 'handler' element.

Parameters
in Element handlerElement The 'handler' element which has been loaded.
Return value
EventListener The created EventListener.
No Exceptions

Example #1: The usage of java together with the 'script' element

The example rely on the fact the 'myclasses.jar' JAR file contains a MANIFEST file with the following entry:

SVG-Handler-Class: org.example.SVGHandler

Given the following SVG document:
<svg xmlns:svg="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny"
xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 500 500">
<script type="application/java-archive" xlink:href="myclasses.jar"/>
<rect id="therect" x="0" y="0" width="100" height="100"/>
</svg>
Given that the SVGHandler implementation available in the 'myclasses.jar' JAR file is the following:
package org.example;

import org.w3c.dom.*;
import org.w3c.dom.svg.*;

public class SVGHandler implements EventListenerInitializer2 {
public void initializeEventListeners (Element scriptElement) {
Document document = scriptElement.getOwnerDocument();
EventTarget rect = (EventTarget) document.getElementById("therect");
rect.addEventListenerNS("http://www.w3.org/2001/xml-events", "click", new MyListener(), null, false, null);
}

public EventListener createEventListener (Element handlerElement) {}
}

An instance of "MyListener" listener will be called when a 'click' event will occur on the 'rect' element.

Example #2: The usage of java together with the 'handler' element

The example rely on the fact the 'myclasses.jar' JAR file contains a MANIFEST file with the following entry:

SVG-Handler-Class: org.example.SVGHandler

Given the following SVG document:
<svg xmlns:svg="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny"
xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 500 500">
xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:myns="http://example.org/myNS">
<script id="init" type="application/java-archive" xlink:href="myclasses.jar"/>
<rect id="therect" x="0" y="0" width="100" height="100">
<handler type="application/java" ev:event="click"
xlink:href="#init" myns:listenerClass="MyListener"/>
</rect>
</svg>
Given that the SVGHandler implementation available in the 'myclasses.jar' JAR file is the following:
package org.example;

import org.w3c.dom.*;
import org.w3c.dom.svg.*;

public class SVGHandler implements EventListenerInitializer2 {
public void initializeEventListeners (Element scriptElement) {}

public EventListener createEventListener (Element handlerElement) {
EventListener listenerInstance = null;
try {
String listenerClass = handlerElement.getAttributeNS("http://example.org/myNS", "listenerClass");
listenerInstance = Class.forName(listenerClass).newInstance();
}
catch (Exception e) {}

return listenerInstance;
}
}

An instance of "MyListener" listener will be called when a 'click' event will occur on the 'rect' element. What createEventListener does is totally in the hand of the developer, the listener instance can be hardcoded or fully configured from information put on the 'handler' element as shown here.

A.7.19 SVGGlobal

The majority of scripted SVG documents in existence make use of the browser specific Window interface. SVGT 1.2 specifies an SVGGlobal interface, taking into account the de-facto standard that already exists, as well as adding the new features present in SVGT 1.2. SVGGlobal inherits from the Global interface, which is currently defined to be empty. The Global interface is designed to be the parent interface for language specific window objects. In scripting implementations, the methods and attributes defined by the Global object are normally part of the global execution context.

Interface SVGGlobal provides a global object for scripts embedded in an SVG document.

IDL Definition
interface SVGGlobal : Global, EventListenerInitializer2
{
	Connection createConnection();
	Timer createTimer();
	void gotoLocation(in DOMString newIRI);
	readonly attribute Document document;
	readonly attribute Global parent;
	DOMString binaryToString(in sequence<octet>, in DOMString encoding) raises(GlobalException);
	sequence<octet> stringToBinary(in DOMString data, in DOMString encoding) raises(GlobalException);
	DOMString getURL(in DOMString iri, in AsyncStatusCallback callback);
	DOMString postURL(in DOMString iri, in DOMString data, in AsyncStatusCallback callback, in DOMString type, in DOMString encoding);
	Node parseXML(in DOMString data, in Document contextDoc);
};
No defined constants
Attributes
document
The Document that this SVGGlobal operates on.
parent
The Global context of this document's parent. If the document has no notion of parent (e.g. when the document is displayed in a stand-alone viewer) the parent is null.
Methods
createConnection
Creates a Connection object.
No Parameters
Return value
Connection The created Connection.
No Exceptions
createTimer
Creates a new Timer instance.
Return value
Timer The created Timer.
No Exceptions
gotoLocation
Request that the user agent traverse a link to the given IRI. If the IRI is invalid or unresolvable, the current document remains loaded. "" means that no link traversal is specified. (See the attribute definition for xlink:href).
Parameters
in DOMString newIRI The IRI to be traversed.
No Return value
No Exceptions
binaryToString

Given a sequence of octets such as can be obtained through a Connection object and a character encoding identifier, this method returns the string produced by interpreting the sequence of octets using that character encoding. Both the UTF-8 and UTF-16 (BE and LE) encodings must be supported, implementations may support other encodings as well.

Parameters
in sequence<octet> data A character encoding identifier. The values "UTF-8", "UTF-16", "ISO-10646-UCS-2", and "ISO-10646-UCS-4" should be used for the various encodings and transformations of Unicode / ISO/IEC 10646. It is recommended that character encodings registered (as charsets) with the Internet Assigned Numbers Authority, other than those just listed, be referred to using their registered names; other encodings should use names starting with an "x-" prefix.
in DOMString encoding A character encoding identifier.
Return value
DOMString The string resulting from decoding the sequence of octets.
Exceptions
GlobalException
ENCODING_ERR: Raised if it is impossible to decode the given sequence of octets with the provided encoding (e.g. because of poorly formed data).
stringToBinary

Given a string and a character encoding identifier, this method returns a sequence of octets representing the string encoded using the specified encoding as can be used to transmit data using the Connection interface. Both the UTF-8 and UTF-16 (BE and LE) encodings must be supported, implementations may support other encodings as well.

Parameters
in DOMString data A string to be encoded using the specified encoding.
in DOMString encoding A character encoding identifier. The values "UTF-8", "UTF-16", "ISO-10646-UCS-2", and "ISO-10646-UCS-4" should be used for the various encodings and transformations of Unicode / ISO/IEC 10646. It is recommended that character encodings registered (as charsets) with the Internet Assigned Numbers Authority, other than those just listed, be referred to using their registered names; other encodings should use names starting with an "x-" prefix.
Return value
sequence<octet> The sequence of octets resulting from encoding the string.
Exceptions
GlobalException
ENCODING_ERR: Raised if it is impossible to encode the given string with the provided encoding (e.g. because the target encoding cannot capture all characters in the string).
getURL

Given an IRI and an AsyncStatusCallback object on which to operate a callback, this method will attempt to fetch the resource at that IRI using the HTTP GET method. Once the request has been completed the callback is called as described in the AsyncStatusCallback interface.

Processing requirements

This method call must take place asynchronously. When called, control returns immediately to the calling context, and once the request is completed the callback is called. Multiple calls to this method must be executed in FIFO order.

User Agents are required to support the gzip content coding and must decode it before passing it on to the callback. User Agents are not required to support encoding content that they send, though they are encouraged to. Cookies should be supported so that state can be maintained across requests. User Agents may provide the user with means to interact with the request (e.g. to enter authentication information) but is not required to. For security reasons, User Agents are encouraged to restrict the domains to which one may make such requests. When enforcing such restrictions, the callback is called immedately with its AsyncURLStatus object's success field set to false and other fields set to null. Redirection responses (3xx HTTP codes) must not be exposed through the API but rather they must be processed internally according to the HTTP specification.

Parameters
in DOMString iri The IRI of the resource that is being requested.
in AsyncStatusCallback callback The object on which the callback will be called upon completion of the request.
No return value
No exceptions
postURL

Given an IRI, data to be transmitted, an AsyncStatusCallback object on which to operate a callback, a media type, and a content coding, this method will send the data to the specified IRI as the body of an HTTP POST request using the requested media type and content coding. Once the request has been completed the callback is called as described in the AsyncStatusCallback interface.

Processing requirements are the same as for getURL, with the following notes and additions.

  • The data passed in does not get any HTML form encoding applied to it, so that applications that whish to transmit content corresponding to what an HTML form would must produce the encoding themselves
  • When the content type parameter is set then the Content-Type header of the request must be set accordingly. If the syntax of the content type parameter does not match that of a media type, it must be ignored. If this parameter is not specified, then it must default to text/plain.
  • When the encoding parameter is set then the User Agent must encode the submitted data with that HTTP content coding and set the Content-Encoding header accordingly, if it supports it. If it does not support it, then it must ignore it, must not set the Content-Encoding header, and must transmit the data with no encoding. The only required content coding is identity.
Parameters
in DOMString iri The IRI of the resource that is being requested.
in DOMString data The data that will be the body of the POST request.
in AsyncStatusCallback callback The object on which the callback will be called upon completion of the request.
in DOMString type The content type of the POST request.
in DOMString encoding The encoding of the POST request.
No return value
No exceptions
parseXML

Given a string and a Document object, parse the string as an XML document and return a Node representing it. If the XML in the string is not well-formed according to either XML 1.0 or XML 1.1 or not namespace-well-formed according to Namespaces in XML 1.1, this method must return a null value.

The purpose of the document parameter is to provide the context into which the XML is parsed. If it is null, this method must return a Document object representing the parsed XML. If it is defined, this method returns an Element object the ownerDocument field of which must be set to be the provided Document object. In effect when the document parameter is specified the processing must be equivalent to applying the following steps:

  1. parsing the XML into a Document
  2. retrieving its documentElement element
  3. calling importNode on the Document object passed to parseXML with the Element from the previous step as its first parameter and the deep parameter set to true. (Please note that importNode is part of DOM 3 Core but not of the uDOM. It is mentionned here to indicate that the effect must be as if importNode had been used, but not to require that it be supported in implementations)
  4. return the result of the last step, cast to Element
Parameters
in DOMString data The data that is to be parsed as XML.
in Document contextDoc The Document object in the context of which to produce the parsing.
Return value
Node A Node (either a Document or an Element) representing the content that was parsed.
No exceptions

A.7.20 AsyncStatusCallback

This interface is implemented by code that intends to process content retrieved through getURL or postURL, both of which take an instance of this interface as a parameter, and call its operationComplete method upon completion of the request.

IDL Definition
interface AsyncStatusCallback
{
	void operationComplete(in AsyncURLStatus status);
};
No defined constants
No defined attributes
Methods
operationComplete

This method is implemented by code in order to be notified of the result of HTTP requests. Upon request completion, it receives an AsyncURLStatus object that captures the details of what was returned.

Parameters
in AsyncURLStatus status An object representing the HTTP response.
No return value
No exceptions

A.7.21 AsyncURLStatus

This interface captures several aspects of an HTTP response in order to be passed to the operationComplete method upon completion of an HTTP request.

IDL Definition
interface AsyncURLStatus
{
	readonly attribute boolean success;
	readonly attribute DOMString contentType;
	readonly attribute DOMString content;
};
No defined constants
Attributes
success

A boolean field indicating whether the request succeeded or not. For response codes in the 200 range, it must be set to true, and for responses in the 400 and 500 ranges it must be set to false. Responses in the 100 range must be ignored and responses in the 300 range must be processed as indicated in getURL's processing requirements.

contentType

A string containing the media type of the response, which must be that set in the Content-Type HTTP header. If there was no Content-Type header, its value is null.

content

A string containing the body of the HTTP response. Binary HTTP bodies must not be used and implementations must set this field to null when they receive one. If the body was in the text/* hierarchy and specified a charset parameter, then the text must be converted into the host programming language's native form if the encoding is supported. If the encoding is not supported, the value of this field must be null. The only required encodings are UTF-8 and UTF-16 (BE and LE). If the HTTP body had one or more content codings applied to it then it must be fully decoded before setting this field.

No defined methods