この付録は正式なものである。
This appendix is normative.
この付録は SVG DOM についての概要と、 SVG DOM と DOM2 仕様( Document Object Model (DOM) Level 2 Specification ) [DOM2] との関係について述べる。 SVG 仕様の特定のセクションに固有の SVG DOM インターフェースは、次に挙げるこの仕様の対応する章の最後で定義されている:
This appendix provides an introduction to the SVG DOM and discusses the relationship of the SVG DOM with the Document Object Model (DOM) Level 2 Specification [ DOM2]. The specific SVG DOM interfaces that correspond to particular sections of the SVG specification are defined at the end of corresponding chapters in this specification, as follows:
SVG DOM は、 DOM2 仕様 [DOM2] を基礎に構築されており、 DOM2 と互換である。特に:
The SVG DOM is builds upon and is compatible with the Document Object Model (DOM) Level 2 Specification [DOM2]. In particular:
DOM アプリケーションは、 DOMImplementation インターフェースの hasFeature メソッドを利用してこの節で挙げられているインターフェースがサポートされているかどうかを確かめることができる。用意されているインターフェースの一覧は hasFeatureメソッド呼び出しに対する特色機能文字列 で与えられている。
A DOM application can use the hasFeature method of the DOMImplementation interface to verify that the interfaces listed in this section are supported. The list of available interfaces is provided in section Feature strings for the hasFeature method call.
すべての SVG DOM オブジェクトは属性に直接対応する。例えば SVGRectElement の SVGAnimatedLength 'ry' は活性状態である。すなわち、属性に対し加えられた変更は即座に対応する SVG DOM オブジェクトに反映される。
SVG DOM を通して文書に指定されていないオブジェクトにアクセスした場合 - 例えば 'x' 属性が指定されずに x.baseVal にアクセスしたときなど - 対応する SVG DOM オブジェクトが生成され、属性が指定されなかった場合に描画の際に用いられる属性値と同じ値に初期化される。 返されるオブジェクトは一度変更が加えられるまでは描画に影響しない。オブジェクトに一度変更が加えられると、それは活性化する。すなわち、対応する任意の属性値への変更が即座にオブジェクトに反映される。
注意:一部の属性については適切な初期値を設定することが難しい。
SVG DOM における名前付け慣行は HTML 文書オブジェクトモデル( Document Object Model HTML ) [ DOM1-HTML] におけるものに似せてある。
The SVG DOM follows similar naming conventions to the Document Object Model HTML [ DOM1-HTML].
全ての名前は一つ以上の英単語を連ねた(空白の無い)単一の文字列として定義される。プロパティ名またはメソッド名における最初の単語は小文字で始まり後に続く単語は大文字で始まる。例えば、ファイルが作成された日付などの文書のメタ情報を返すプロパティは "fileDateCreated" のような名前を持つであろう。 ECMAScript バインディングにおいては、プロパティは与えられたオブジェクトのプロパティとして公開される。 Java においては、プロパティは get と set メソッドにより公開される。
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.
CDATA データ型の属性に対し、返り値の文字の大小はソース文書で与えられたものそのままである。
For attributes with the CDATA data type, the case of the return value is that given in the source document.
この例外は特定の SVG の演算が実行不能なときレイズされる。
This exception is raised when a specific SVG operation is impossible to perform.
exception SVGException { unsigned short code; }; // SVGExceptionCode const unsigned short SVG_WRONG_TYPE_ERR = 0; const unsigned short SVG_INVALID_VALUE_ERR = 1; const unsigned short SVG_MATRIX_NOT_INVERTABLE = 2;
SVG DOM がサポートする [DOM2-CORE] で定義される DOMImplementation インターフェースの hasFeature メソッド呼び出しで利用可能な特色機能文字列は、多くの SVG 要素で利用できる requiredFeatures 属性で利用可能な特色機能文字列と同じである。
The feature strings that are available for the hasFeature method call that is part of the SVG DOM's support for the DOMImplementation interface defined in [ DOM2-CORE] are the same features strings available for the requiredFeatures attribute that is available for many SVG elements.
この仕様で記述された SVG 言語の特色機能全て( SVG 言語の特色機能の一覧は付録 特色機能文字列 を見よ)に対し、hasFeature メソッド呼び出しに対する バージョン番号は "1.1" である。他の言語に対応する特色機能については、関連する他の仕様を参照してその特色機能のバージョン番号の決定をすること。
For all features that correspond to the SVG language and are documented in this specification (see appendix Feature Strings for a list of features in the SVG language), the version number for the hasFeature method call is "1.1". For features that correspond to other languages, refer to the relevant other specifications to determine the appropriate version number for the given feature.
SVG DOM は [DOM2-EVENTS] による、以下に挙げるインターフェースとイベント型をサポートする:
The SVG DOM supports the following interfaces and event types from [ DOM2-EVENTS]:
SVG DTD 内で少なくとも一つの イベント属性 が割当てられている SVG 要素は、 DOM2 イベント登録インターフェース [ DOM2-EVREG] をサポートする。イベント登録インターフェースの利用により、イベント属性に対応する DOM2 イベントに対するイベントリスナとして要素を登録させることが可能になる。例えば、 SVG DTD が要素に対する "onclick" イベント属性のサポートを指示しているならば、その要素をイベントターゲットとする "click" イベントのイベントリスナを登録させることが出来る。
Each SVG element which has at least one event attribute assigned to it in the SVG DTD supports the DOM2 event registration interfaces [ DOM2-EVREG] and can be registered as an event listener for the corresponding DOM2 event using the event registration interfaces. Thus, for example, if the SVG DTD indicates that a given element supports the "onclick" event attribute, then an event listener for the "click" event can be registered with the given element as the event target.
実装はイベント属性の設定を EventTarget に対する EventListener の生成と登録とみなすことができる。 useCapture の既定値は 'false' である。この EventListener は EventTarget として登録させることができる他の EventListener と同じように振る舞う。
Implementors may view the setting of event attributes as the creation and registration of an EventListener on the EventTarget. The value of useCapture defaults to 'false'. This EventListener behaves in the same manner as any other EventListeners which may be registered on the EventTarget.
イベントリスナを表現している属性の変化は、以前に登録された EventListener の削除と新しいものの登録とみなすことができる。このとき、同じ EventTarget に対する他の EventListener も考慮するとき、どのイベント属性がイベントを受け取るかを定める優先順位の変更は行われない。
If the attribute representing the event listener is changed, this may be viewed as the removal of the previously registered EventListener and the registration of a new one. Futhermore, no specification is made as to the order in which event attributes will receive the event with regards to the other EventListeners on the EventTarget.
SVG の アニメーション要素 も DOM2 イベント登録インターフェース [ DOM2-EVREG] をサポートする。アニメーションイベント(即ち開始, 終了, 反復のいずれか)に対するイベントリスナは任意の アニメーション要素 に対し登録できる。
SVG's animation elements also support the DOM2 event registration interfaces [ DOM2-EVREG]. Event listeners for animation events (i.e., start, end or repeat) can be registered on any of the animation elements.
Java においてイベントリスナを確立する方法の一つは、次の様に EventListener インターフェースを実装するクラスを定義することである:
In Java, one way that event listeners can be established is to define a class which implements the EventListener interface, such as:
class MyAction1 implements EventListener { public void handleEvent(Event evt) { // process the event } } // ... later ... MyAction1 mc1 = new MyAction1(); myElement.addEventListener("DOMActivate", mc1, false);
ECMAScript においてイベントリスナを確立する方法の一つは、 関数を定義してその名前を addEventListener メソッドに渡すことである:
In ECMAScript, one way to establish an event listener is to define a function and pass the name of that function to the addEventListener method:
function myAction1(evt) { // process the event } // ... later ... myElement.addEventListener("DOMActivate", myAction1, false)
ECMAScript においては、 イベント属性 の文字データ内容によりイベントに反応する ECMAScript 関数が記述される。この関数は名前が evt のイベントオブジェクトをパラメタとして受け取る。このことは登録されている他のどの ECMAScript イベントリスナ関数にも同様にあてはまる。例えば次のように書くことができる:
In ECMAScript, the character data content of an Event attribute become the definition of the ECMAScript function which gets invoked in response to the event. As with all registered ECMAScript event listener functions, this function receives an Event object as a parameter, and the name of the Event object is evt. For example, it is possible to say:
<rect onactivate="MyActivateHandler(evt)" .../>
これは、イベントオブジェクト evt を関数 MyActivateHandler
に渡すことを指示する。
which will pass the Event object evt into function MyActivateHandler
.
この節では SVG DOM の一部である CSS 文書オブジェクトモデル( Document Object Model CSS ) [DOM2-CSS] 、略称 CSS OM の機能について述べる。
The section describes the facilities from the Document Object Model CSS [ DOM2-CSS], the CSS OM, that are part of the SVG DOM.
CSS によるスタイル付け をサポートしないUAは、 [DOM2-CSS] による次のインターフェースを( CSSPrimitiveValue や CSSValueList などの、それらのインターフェース実装するのに必要なインターフェースに加えて )サポートすればよい(最低限要求される)。これらのインターフェースは、インターフェース SVGStylable の getPresentationAttribute メソッド呼び出しと伴に利用される。このメソッドは全ての SVG DOM の実装においてサポートされなければならない:
User agents that do not support styling with CSS are only required to support the following interfaces from [ DOM2-CSS], along with any interfaces necessary to implement the interfaces, such as CSSPrimitiveValue and CSSValueList. These interfaces are used in conjunction with the getPresentationAttribute method call on interface SVGStylable. This method must be supported on all implementations of the SVG DOM:
CSS によるスタイル付け, SVG DOM, 聴覚スタイル付け [CSS2-AURAL] をサポートするUAは、 [DOM2-CSS] で定義されている聴覚プロパティに適用されるインターフェース全てをサポートしなければならない。
User agents that support Styling with CSS, the SVG DOM, and aural styling [ CSS2-AURAL] must support all of the interfaces defined in [ DOM2-CSS] which apply to aural properties.
視覚メディア [ CSS2-VISUAL] に対しては、 SVG DOM は [DOM2-CSS] で定義され、要求されているインターフェース全てをサポートする。 [DOM2-CSS] におけるオプションのインターフェース全ては SVG DOM においてもオプションである。
For visual media [ CSS2-VISUAL], the SVG DOM supports all of the required interfaces defined in [ DOM2-CSS]. All of the interfaces that are optional for [ DOM2-CSS] are also optional for the SVG DOM.
UAによる CSS によるスタイル付け のサポートの有無に関らず、UAは( SVGStylable インターフェースの getPresentationAttribute メソッド呼び出しの返り値の型であるところの) CSSValue インターフェースをサポートしなければならない。
Whether or not a user agent supports styling with CSS, a user agent still must support interface CSSValue, as this is the type that is returned from the getPresentationAttribute method call on interface SVGStylable.
[DOM2-CSS] は、 CSSValue インターフェースと関連して利用するための拡張インターフェースのセット [DOM2-CSS-EI] を定義する。下の表は、視覚メディア [ CSS2-VISUAL] に適用される各 SVG プロパティを表現するのに用いられる CSSValue [ DOM2-CSSVALUE] の型を指定している。ただし例外として、 CSSStyleDeclaration インターフェースの getPropertyCSSValue メソッドまたは SVGStylable インターフェースの getPresentationAttribute メソッドによる返り値の CSSValue は、バインディング特有の型強制により特有の派生インターフェースに型強制され得る。
[ DOM2-CSS] defines a set of extended interfaces [ DOM2-CSS-EI] for use in conjunction with interface CSSValue. The table below specifies the type of CSSValue [ DOM2-CSSVALUE] used to represent each SVG property that applies to visual media [ CSS2-VISUAL]. The expectation is that the CSSValue returned from the getPropertyCSSValue method on the CSSStyleDeclaration interface or the getPresentationAttribute method on the SVGStylable interface can be cast down, using binding-specific casting methods, to the specific derived interface.
独自インターフェース( CSSValue の valueType が CSS_CUSTOM )によって表現されるプロパティに対しては、派生インターフェースの名前が表で指定されている。これらのプロパティに対し、どの拡張インターフェースが義務的であり、どれがそうでないかは下の表に示されている。
For properties that are represented by a custom interface (the valueType of the CSSValue is CSS_CUSTOM), the name of the derived interface is specified in the table. For these properties, the table below indicates which extended interfaces are mandatory and which are not.
値のリスト( CSSValue の valueType が CSS_VALUE_LIST )からなるプロパティに対する派生インターフェースは CSSValueList である。他の全てのプロパティ( CSSValue の valueType が CSS_PRIMITIVE_VALUE )に対する派生インターフェースは CSSPrimitiveValue である。
For properties that consist of lists of values (the valueType of the CSSValue is CSS_VALUE_LIST), the derived interface is CSSValueList. For all other properties (the valueType of the CSSValue is CSS_PRIMITIVE_VALUE), the derived interface is CSSPrimitiveValue.
省略形式( shorthand )のプロパティに対しては、 CSSValue は常に値 null をとる。省略形式のプロパティの値は文字列としてのみアクセス/変更が可能である。
For shorthand properties, a CSSValue always will have a value of null. Shorthand property values can only be accessed and modified as strings.
SVG DOM は次の SVG 独自のプロパティインターフェースを定義する。これら全てのサポートは SVG-UAの義務である:
The SVG DOM defines the following SVG-specific custom property interfaces, all of which are mandatory for SVG user agents:
スクリプトが DOM 属性に無効な値(例えば非負数を要求する属性に対する負数、あるいは列挙値の範囲外の値など)を設定した場合、この仕様で特に指示されていない限り例外はレイズされないが、文書片は形式の上では エラー処理 で述べられる エラー状態 ということになる。
If a script sets a DOM attribute to an invalid value (e.g., a negative number for an attribute that requires a non-negative number or an out-of-range value for an enumeration), unless this specification indicates otherwise, no exception shall be raised on setting, but the given document fragment shall become technically in error as described in Error processing.