This appendix is normative.
The SVG DOM has the following general characteristics:
In particular, the following should be noted:
The SVG DOM follows similar naming conventions to the HTML DOM Level 1.
All names are defined as one or more English words concatenated together to form a single string. Property or method names start with the initial keyword in lowercase, and each subsequent word starts with a capital letter. For example, a property that returns document meta information such as the date the file was created might be named "fileDateCreated". In the ECMAScript binding, properties are exposed as properties of a given object. In Java, properties are exposed with get and set methods.
The return value of an attribute that has a data type that is a value list is always capitalized, independent of the case of the value in the source document. For example, if the value of the align attribute on a P element is "left" then it is returned as "Left". For attributes with the CDATA data type, the case of the return value is that given in the source document.
SVGDocument
is the root of the SVG hierarchy and
holds the entire content. Beside providing access to the hierarchy, it
also provides some convenience methods for accessing certain sets of
information from the document.
interface SVGDocument : Document { // Same meanings as in HTML DOM Level 1 attribute DOMString title; readonly attribute DOMString referrer; readonly attribute DOMString domain; readonly attribute DOMString URL; void open(); void close(); void write(in DOMString text); void writeln(in DOMString text); Element getElementById(in DOMString elementId); // Methods to eliminate flicker in animations. unsigned long suspend_redraw(in unsigned long max_wait_milliseconds); void unsuspend_redraw(in unsigned long suspend_handle_id) raises(DOMException); void unsuspend_redraw_all(); // The following utility methods for matrix arithmetic will be // available from the DOM. (Details not yet available.) // matrix += Vector2D - translation // matrix -= Vector2D - translation // matrix *= number - scaling // matrix /= number - scaling // matrix *= Vector2D - non-orthogonal scaling // matrix /= Vector2D - non-orthogonal scaling // matrix *= Matrix2D - matrix concatenation // matrix == number - test scaling matrix identity // matrix == Vector2D - test for simple scaling // matrix.FSimple() - transformation is an offset/scale // matrix.Rotate(angle) - rotation // matrix.Rotate(Vector2D) - rotation defined by vector (atan(y/x)) // matrix.FlipX() - flip +x <-> -x // matrix.FlipY() - flip +y <-> -y // matrix.SkewX() - skew in direction of X axis // matrix.SkewY() - skew in direction of Y axis // matrix.Inverse() - invert the matrix };
title
title
sub-element of the svg
element that
encompasses the document (i.e., <svg><defs><title>Here is the title</title></defs><svg>
referrer
domain
URL
open
close
open()
and forces rendering.write
open()
. The text is parsed into the document's structure
model.
text |
The string to be parsed into some structure in the document structure model. |
writeln
open()
. The text is parsed into the
document's structure model.
text |
The string to be parsed into some structure in the document structure model. |
getElementById
id
is given by
elementId. If no such element exists, returns null
.
Behavior is not defined if more than one element
has this id
.
elementId |
The unique |
suspend_redraw
unsuspend_redraw(suspend_handle_id)
call has been made, (b) an unsuspend_redraw_all()
call has been made, or (c) its timer has timed out.
In environments that do not support interactivity (e.g., print media), then redraw
should not be suspended. suspend_handle_id = suspend_redraw(max_wait_milliseconds)
and
unsuspend_redraw(suspend_handle_id)
should be packaged as balanced pairs.
When you want to suspend redraw actions as a collection of SVG DOM changes occur,
then precede the changes to the SVG DOM with a method call
similar to suspend_handle_id = suspend_redraw(max_wait_milliseconds)
and follow the changes with a method call similar to unsuspend_redraw(suspend_handle_id)
.
Note that multiple suspend_redraw
calls can be used at once and that each
such method call is treated independently of the other suspend_redraw
method calls.
max_wait_milliseconds |
The amount of time in milliseconds to hold off before redrawing the device. Values greater than 60 seconds will be truncated down to 60 seconds. |
suspend_redraw()
call.
This value should be passed as the parameter to the corresponding unsuspend_redraw()
method call.
unsuspend_redraw
suspend_redraw()
by providing a unique suspend_handle_id
.
suspend_handle_id |
A number which acts as a unique identifier for the desired |
suspend_handle_id
is active)
for suspend_handle_id
is provided.unsuspend_redraw_all
suspend_redraw()
method calls.
This method is most useful at the very end of a set of SVG DOM calls
to ensure that all pending suspend_redraw()
method calls
have been cancelled.
All SVG element interfaces derive from this class.
interface SVGElement : Element { readonly attribute SVGDocument ownerSVGDocument; CSSStyleDeclaration style; };
Corresponds to the <path> element.
interface SVGPathElement : SVGElement { // Create an empty SVGPathSeg, specifying the type via a number. // All values initialized to zero. SVGPathSeg createSVGPathSeg(in unsigned short pathsegType) raises(DOMException); // Create an empty SVGPathSeg, specifying the type via a single character. // All values initialized to zero. SVGPathSeg createSVGPathSegFromLetter(in DOMString pathsegTypeAsLetter) raises(DOMException); // Create an SVGPathSeg, specifying the path segment as a string. // For example, "M 100 200". All irrelevant values are set to zero. SVGPathSeg createSVGPathSegFromString(in DOMString pathsegString) raises(DOMException); // This set of functions allows retrieval and modification // to the path segments attached to this path object. // All 20 defined types of path segments are available // through these attributes and methods. readonly attribute unsigned long number_of_pathsegs; SVGPathSeg getSVGPathSeg(in unsigned long index); DOMString getSVGPathSegAsString(in unsigned long index); SVGPathSeg insertSVGPathSegBefore(in SVGPathSeg newSVGPathSeg, in unsigned long index) raises(DOMException); SVGPathSeg replaceSVGPathSeg(in SVGPathSeg newSVGPathSeg, in unsigned long index) raises(DOMException); SVGPathSeg removeSVGPathSeg(in unsigned long index) raises(DOMException); SVGPathSeg appendSVGPathSeg(in SVGPathSeg newSVGPathSeg) raises(DOMException); // This alternate set of functions also allows retrieval and modification // to the path segments attached to this path object. // These attributes and methods provide a "normalized" view of // the path segments where the path is expressed in terms of // the following subset of SVGPathSeg types: // kSVG_PATHSEG_MOVETO_ABS (M), kSVG_PATHSEG_LINETO_ABS (L), // kSVG_PATHSEG_CURVETO_CUBIC_ABS (C) and kSVG_PATHSEG_CLOSEPATH (z). // Note that number_of_pathsegs and number_of_normalized_pathsegs // may not be the same. In particular, elements such as arcs may // be expanded into multiple kSVG_PATHSEG_CURVETO_CUBIC_ABS (C) // pieces when retrieved in the "normalized" view of the path object. readonly attribute unsigned long number_of_normalized_pathsegs; SVGPathSeg getNormalizedSVGPathSeg(in unsigned long index); DOMString getNormalizedSVGPathSegAsString(in unsigned long index); SVGPathSeg insertNormalizedSVGPathSegBefore(in SVGPathSeg newSVGPathSeg, in unsigned long index) raises(DOMException); SVGPathSeg replaceNormalizedSVGPathSeg(in SVGPathSeg newSVGPathSeg, in unsigned long index) raises(DOMException); SVGPathSeg removeNormalizedSVGPathSeg(in unsigned long index) raises(DOMException); SVGPathSeg appendNormalizedSVGPathSeg(in SVGPathSeg newSVGPathSeg) raises(DOMException); };
Corresponds to a single segment within a path data specification.
interface SVGPathSeg { // Path Segment Types const unsigned short kSVG_PATHSEG_UNKNOWN = 0; // ? const unsigned short kSVG_PATHSEG_CLOSEPATH = 1; // z const unsigned short kSVG_PATHSEG_MOVETO_ABS = 2; // M const unsigned short kSVG_PATHSEG_MOVETO_REL = 3; // m const unsigned short kSVG_PATHSEG_LINETO_ABS = 4; // L const unsigned short kSVG_PATHSEG_LINETO_REL = 5; // l const unsigned short kSVG_PATHSEG_CURVETO_CUBIC_ABS = 6; // C const unsigned short kSVG_PATHSEG_CURVETO_CUBIC_REL = 7; // c const unsigned short kSVG_PATHSEG_CURVETO_QUADRATIC_ABS = 8; // Q const unsigned short kSVG_PATHSEG_CURVETO_QUADRATIC_REL = 9; // q const unsigned short kSVG_PATHSEG_ARC_SWEEP_ABS = 10; // A const unsigned short kSVG_PATHSEG_ARC_SWEEP_REL = 11; // a const unsigned short kSVG_PATHSEG_ARC_VECTOR_ABS = 12; // B const unsigned short kSVG_PATHSEG_ARC_VECTOR_REL = 13; // b const unsigned short kSVG_PATHSEG_LINETO_HORIZONTAL_ABS = 14; // H const unsigned short kSVG_PATHSEG_LINETO_HORIZONTAL_REL = 15; // h const unsigned short kSVG_PATHSEG_LINETO_VERTICAL_ABS = 16; // V const unsigned short kSVG_PATHSEG_LINETO_VERTICAL_REL = 17; // v const unsigned short kSVG_PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 18; // S const unsigned short kSVG_PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 19; // s const unsigned short kSVG_PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 20; // T const unsigned short kSVG_PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 21; // t readonly attribute unsigned short pathsegType; readonly attribute DOMString pathsegTypeAsLetter; // Attribute values for a path segment. // Each pathseg has slots for any possible path seg type. // (We don't want to define 20 different subclasses to PathSeg - our document is long enough already.) attribute double x; // end point for pathseg (or center for A/a/B/b) attribute double y; // end point for pathseg (or center for A/a/B/b) attribute double x0,y0; // for control points (start point for B/b) attribute double x1,y1; // for control points (end point for B/b) attribute double r1,r2; // radii for A/a/B/b attribute double a1,a2,a3; // angles for A/a readonly attribute Path parentPath; readonly attribute SVGDocument ownerSVGDocument; readonly attribute SVGPathSeg previousSibling; readonly attribute SVGPathSeg nextSibling; };