UAは SVG 内容の処理と表示の能力を持たないことがある。以下に SVG 内容に関連する後方互換性への配慮についての2つの手法を述べる:
A user agent (UA) might not have the ability to process and view SVG content. The following list outlines two of the backwards compatibility scenarios associated with SVG content:
この 'switch' 要素と特色機能利用可能性テスト機能(またはそれらに等価なもの)が、 SVG 内容に対する画像やテキスト文字列などの代替表現を提供する方法として、 XML 文書作成者に推奨されるものになる。下の例に SMIL 1.0 の文書内に SVG の絵図を埋め込む際に、UAが SVG をサポートしていなくても代替画像を表示させられるようにする方法を示す。 "type" 属性の MIME タイプが、UAによる参照先メディアの解読が可能かどうかの判別に重要な意味を持つことに注意されたい。
この例では、 SVG 内容は URL 参照により包含されている。親の XML 文法によっては、同じファイル内にインラインに SVG 文書片を含めることも可能である。
<?xml version="1.0" standalone="yes"?> <smil> <body> <!-- SMIL 1.0 においては、'switch' の最初の子要素は、 SMIL 1.0 UAによる判定処理が可能であり、そのテストが 真を返すならそれが処理され、他の全ての子要素は何の 視覚効果も生じさせない。この場合、もし SMIL 1.0 UAが "image/svg+xml" を処理できるならば、 SVG が表示される。 そうでない場合、代替画像 (2番目の子要素)が表示される。 --> <switch> <!-- 可能なら SVG を描画する。 --> <ref type="image/svg+xml" src="drawing.svg" /> <!-- 無理なら代替画像を描画する。 --> <img src="alternate_image.jpg" /> </switch> </body> </smil>
This 'switch' element and feature-availability test facility (or their equivalents) are the recommended way for XML authors to provide an alternate representation to SVG content, such as an image or a text string. The following example shows how to embed an SVG drawing within a SMIL 1.0 document such that an alternate image will display in the event the user agent doesn't support SVG. Note that the MIME type in the "type" attribute is an important means for the user agent to decide if it can decode the referenced media.
In this example, the SVG content is included via a URL reference. With some parent XML grammars it will also be possible to include an SVG document fragment inline within the same file as its parent grammar.
<?xml version="1.0" standalone="yes"?> <smil> <body> <!-- With SMIL 1.0, the first child element of 'switch' which the SMIL 1.0 user agent is able to process and which tests true will get processed and all other child elements will have no visual effect. In this case, if the SMIL 1.0 user agent can process "image/svg+xml", then the SVG will appear; otherwise, the alternate image (the second child element) will appear. --> <switch> <!-- Render the SVG if possible. --> <ref type="image/svg+xml" src="drawing.svg" /> <!-- Else, render the alternate image. --> <img src="alternate_image.jpg" /> </switch> </body> </smil>
HTML 4 においては、'object' 要素の利用により SVG の絵図を埋め込むことができる。画像などの代替表現は 'object' 要素の内容として含めることができる。この場合、 SVG 内容は通常 URL 参照により包含される。下の例に 'object' 要素を用いて、 URL 参照による SVG の絵図と伴に SVG-UAが無い際の代替表現を受け持つ画像を含ませる方法を示す:
<html> <body> <object type="image/svg+xml" data="drawing.svg"> <!-- UAが SVG を処理できないときは 'object' 要素の 内容(即ち代替画像)が表示される。--> <img src="alternate_image.jpg" alt="alternate description"> </object> </body> </html>
For HTML 4, SVG drawings can be embedded using the 'object' element. An alternate representation such as an image can be included as the content of the 'object' element. In this case, the SVG content usually will be included via a URL reference. The following example shows how to use the 'object' element to include an SVG drawing via a URL reference with an image serving as the alternate representation in the absence of an SVG user agent:
<html> <body> <object type="image/svg+xml" data="drawing.svg"> <!-- The contents of the 'object' element (i.e., an alternate image) are drawn in the event the user agent cannot process the SVG drawing. --> <img src="alternate_image.jpg" alt="alternate description"> </object> </body> </html>