SVG においては、 SVG 内容のどこにでも外部の名前空間による要素を含めることが許容される。一般に、 SVG-UAは未知の要素を DOM に含めるが、それ以外の点では無視する(注意すべき例外は 外部の型のオブジェクトの埋め込み で述べられる)。 (訳注:外部 = foreign または private - この章の文脈においては「外部」とは、 SVG にとって管轄外のあるいは未知のものを指し、何らかの目的のための拡張を暗に意味する)
SVG allows inclusion of elements from foreign namespaces anywhere with the SVG content. In general, the SVG user agent will include the unknown elements in the DOM but will otherwise ignore unknown elements. (The notable exception is described under Embedding Foreign Object Types.)
更に、 SVG においては、任意の SVG 要素に外部の名前空間による属性を含めることが許容される。 SVG-UAは未知の属性を DOM に組み入れるが、それ以外の点では無視する。
Additionally, SVG allows inclusion of attributes from foreign namespaces on any SVG element. The SVG user agent will include unknown attributes in the DOM but with otherwise ignore unknown attributes.
外部の名前空間を含めることを可能にする SVG の能力には次の目的がある:
SVG's ability to include foreign namespaces can be used for the following purposes:
例えばビジネスグラフィックスの文書作成アプリケーションは、 SVG 文書内に何らかのプライベートデータを含ませ、読込み時に図表(下の例の場合は円グラフ)が正しく組み上げられるようにすることを望むかもしれない:
To illustrate, a business graphics authoring application might want to include some private data within an SVG document so that it could properly reassemble the chart (a pie chart in this case) upon reading it back in:
<?xml version="1.0" standalone="yes"?> <svg width="4in" height="3in" version="1.1" xmlns = 'http://www.w3.org/2000/svg'> <defs> <myapp:piechart xmlns:myapp="http://example.org/myapp" title="Sales by Region"> <myapp:pieslice label="Northern Region" value="1.23"/> <myapp:pieslice label="Eastern Region" value="2.53"/> <myapp:pieslice label="Southern Region" value="3.89"/> <myapp:pieslice label="Western Region" value="2.04"/> <!-- 他のプライベートデータがここに --> </myapp:piechart> </defs> <desc>この図表は別の名前空間のプライベートデータを含む </desc> <!-- 実際に円グラフを描く SVG のグラフィックス要素はここに --> </svg>
SVG の目標の一つは、他の XML 言語プロセッサが、 SVG 内容木の与えられた場所において現在有効な種々の変換と合成パラメタに従い、その SVG の描画区域に出力できる仕組を提供する所にある。一つの特殊な例として、 CSS または XSL によりスタイル付けされた XML 内容に対し、 SVG 内容のどこかに( SVG による変換と合成に従って)動的にテキストを流し込めるようなフレームを提供することが挙げられる。別の例としては MathML による数式を SVG の絵図に挿入することが挙げられる。
One goal for SVG is to provide a mechanism by which other XML language processors can render into an area within an SVG drawing, with those renderings subject to the various transformations and compositing parameters that are currently active at a given point within the SVG content tree. One particular example of this is to provide a frame for XML content styled with CSS or XSL so that dynamically reflowing text (subject to SVG transformations and compositing) could be inserted into the middle of some SVG content. Another example is inserting a MathML expression into an SVG drawing.
'foreignObject' 要素には、グラフィック内容が別のUAにより描画されるような、外部の名前空間のものを含ませることができる。この含められた外部のグラフィック内容は SVG の変換と合成の対象になる。
The 'foreignObject' element allows for inclusion of a foreign namespace which has its graphical content drawn by a different user agent. The included foreign graphical content is subject to SVG transformations and compositing.
'foreignObject' の内容は別の名前空間のものとみなされる。 'foreignObject' 内の任意の SVG 要素は、適切に定義された下位の SVG 文書が適切な xmlns 属性("Namespaces in XML" [XML-NS] 参照)の指定を伴なって再帰的に埋めこまれている状況を除き、描画されないことになる。そのような状況の一つは、 SVG 文書片が別の非 SVG 文書片内に埋めこまれており、それがまた別の SVG 文書片内に埋めこまれる(例えば SVG 文書片が XHTML 文書片を含んでおり、それがまた別の SVG 文書片を含んでいる)ような場合である。
The contents of 'foreignObject' are assumed to be from a different namespace. Any SVG elements within a 'foreignObject' will not be drawn, except in the situation where a properly defined SVG subdocument with a proper xmlns (see "Namespaces in XML" [ XML-NS]) attribute specification is embedded recursively. One situation where this can occur is when an SVG document fragment is embedded within another non-SVG document fragment, which in turn is embedded within an SVG document fragment (e.g., an SVG document fragment contains an XHTML document fragment which in turn contains yet another SVG document fragment).
通常、 'foreignObject' の利用においては、UAのサポートの有無を正しく確認し、そのサポートが無い場合の代替描画を提供するための 'switch' 要素と requiredExtensions 属性が伴うことになる。
Usually, a 'foreignObject' will be used in conjunction with the 'switch' element and the requiredExtensions attribute to provide proper checking for user agent support and provide an alternate rendering in case user agent support is not available.
<!ENTITY % SVG.foreignObject.extra.content "" > <!ENTITY % SVG.foreignObject.element "INCLUDE" > <![%SVG.foreignObject.element;[ <!ENTITY % SVG.foreignObject.content "( #PCDATA %SVG.foreignObject.extra.content; )*" > <!ELEMENT %SVG.foreignObject.qname; %SVG.foreignObje ct.content; > <!-- end of SVG.foreignObject.element -->]]> <!ENTITY % SVG.foreignObject.attlist "INCLUDE" > <![%SVG.foreignObject.attlist;[ <!ATTLIST %SVG.foreignObject.qname; %SVG.Core.attrib; %SVG.Conditional.attrib; %SVG.Style.attrib; %SVG.Presentation.attrib; %SVG.GraphicalEvents.attrib; %SVG.External.attrib; x %Coordinate.datatype; #IMPLIED y %Coordinate.datatype; #IMPLIED width %Length.datatype; #REQUIRED height %Length.datatype; #REQUIRED transform %TransformList.datatype; #IMPLIED > |
属性定義:
ここに例を示す:
Here is an example:
<?xml version="1.0" standalone="yes"?> <svg width="4in" height="3in" version="1.1" xmlns = 'http://www.w3.org/2000/svg'> <desc>この例は 'switch' 要素を用いて XMHTML がサポート されていない場合に備え、段落のグラフィック表現も与える。 </desc> <!-- 'switch' 要素はテスト属性を順に評価して 真になる最初の子要素の処理をする--> <switch> <!-- 埋込まれた XHTML に対し requiredExtensions 属性が真と評価されるならば (即ち、UAが SVG に埋込まれた XHTML をサポートするならば)その処理を行う。 --> <foreignObject width="100" height="50" requiredExtensions="http://example.com/SVGExtensions/EmbeddedXHTML"> <!-- XHTML 内容がここに --> <body xmlns="http://www.w3.org/1999/xhtml"> <p>ここに行の折り返しを要する段落が入る。</p> </body> </foreignObject> <!-- そうでなければ、以下の代替 SVG の処理が行われる。 'text' 要素に対するテスト属性は存在しないことに注意。 テスト属性が与えられていない場合、真と評価される テスト属性が存在するものとみなされる。 --> <text font-size="10" font-family="Verdana"> <tspan x="10" y="10">ここに行の折り返しを</tspan> <tspan x="10" y="20">要する段落が入る。</tspan> </text> </switch> </svg>
SVG-UAには、埋めこまれた外部の型のオブジェクトを他の任意のUAに処理させることは要求されていない。しかしながら、全ての適合 SVG-UAは 'switch' 要素をサポートし、その要素内に代替表示として現れる SVG 要素が有効なものであれば、その描画をしなければならない。
It is not required that SVG user agent support the ability to invoke other arbitrary user agents to handle embedded foreign object types; however, all conforming SVG user agents would need to support the 'switch' element and must be able to render valid SVG elements when they appear as one of the alternatives within a 'switch' element.
最終的には、商用のウェブブラウザには、 SVG に対し、 CSS または XSL を利用する他の XML 言語による内容を埋めこみ、 CSS / XSL により整形された結果が SVG による変換と合成に従って処理されるような機能を将来的にサポートすることが見込まれている。現時点においてはそのような能力は要求されていないが。
Ultimately, it is expected that commercial Web browsers will support the ability for SVG to embed content from other XML grammars which use CSS or XSL to format their content, with the resulting CSS- or XSL-formatted content subject to SVG transformations and compositing. At this time, such a capability is not a requirement.
SVG の DTD は、内部 DTD サブセットによる SVG 言語の拡張を許容している。内部 DTD サブセットにおいては、ほとんどの SVG 要素に対し、独自の要素や属性の追加が許容されている。
The SVG DTD allows for extending the SVG language within the internal DTD subset. Within the internal DTD subset, you have the ability to add custom elements and attributes to most SVG elements.
SVG の DTD では、ほとんどの SVG 要素において拡張実体( extension entity )を定義している。例えば 'view' 要素は次のように DTD で定義されている:
The DTD defines an extension entity for most of SVG elements. For example, the 'view' element is defined in the DTD as follows:
<!ENTITY % viewExt "" > <!ELEMENT view (%descTitleMetadata;%viewExt;) > <!ATTLIST view %stdAttrs; externalResourcesRequired %Boolean; #IMPLIED viewBox %ViewBoxSpec; #IMPLIED preserveAspectRatio %PreserveAspectRatioSpec; 'xMidYMid meet' zoomAndPan (disable | magnify) 'magnify' viewTarget CDATA #IMPLIED >
<!ENTITY % SVG.view.extra.content "" > <!ENTITY % SVG.view.element "INCLUDE" > <![%SVG.view.element;[ <!ENTITY % SVG.view.content "( %SVG.Description.class; %SVG.view.extra.content; )*" > <!ELEMENT %SVG.view.qname; %SVG.view.content; > <!-- end of SVG.view.element -->]]> <!ENTITY % SVG.view.attlist "INCLUDE" > <![%SVG.view.attlist;[ <!ATTLIST %SVG.view.qname; %SVG.Core.attrib; %SVG.External.attrib; viewBox %ViewBoxSpec.datatype; #IMPLIED preserveAspectRatio %PreserveAspectRatioSpec.datatype; 'xMidYMid meet' zoomAndPan ( disable | magnify ) 'magnify' viewTarget CDATA #IMPLIED >
文書の
'view'
要素に独自の副要素または属性を追加する目的で実体 viewExt
SVG.view.extra.content
を内部 DTD サブセットに定義することができる。
例えば次では、追加の子要素 'customNS:customElement' と追加の属性 'customNS:customAttr' を与えて
'view'
要素を拡張している:
The entity viewExt
can be defined in the internal DTD subset to add custom sub-element or custom attributes to the
'view' element within a given document. For example, the following extends the
'view'
element with an additional child element 'customNS:customElement' and an additional attribute customNS:customAttr:
<?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [ <!ENTITY % viewExt "| customNS:customElement" > <!ATTLIST view xmlns:customNS CDATA #FIXED "http://www.example.org/customNS" customNS:customAttr CDATA #IMPLIED > <!ELEMENT customNS:customElement EMPTY> <!ATTLIST customNS:customElement xmlns:customNS CDATA #FIXED "http://www.example.org/customNS" info CDATA #IMPLIED> ]> <svg width="8cm" height="4cm" version="1.1" xmlns="http://www.w3.org/2000/svg"> <desc>内部 DTD サブセットにより 'view' 要素を拡張する。</desc> <!-- 何か斬新なグラフィックがここに置かれるらしい。 --> <view viewBox="100 110 20 30" customNS:customAttr="123"> <customNS:customElement info="abc"/> </view> </svg>
<?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [ <!ENTITY % SVG.view.extra.content "| customNS:customElement" > <!ATTLIST view xmlns:customNS CDATA #FIXED "http://www.example.org/customNS" customNS:customAttr CDATA #IMPLIED > <!ELEMENT customNS:customElement EMPTY> <!ATTLIST customNS:customElement xmlns:customNS CDATA #FIXED "http://www.example.org/customNS" info CDATA #IMPLIED> ]> <svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="8cm" height="4cm"> <desc>Extend the 'view' element via the internal DTD subset</desc> <!-- Presumably, some great graphics would go here. --> <view viewBox="100 110 20 30" customNS:customAttr="123"> <customNS:customElement info="abc"/> </view> </svg>
要素 | 属性 | 内容モデル |
---|---|---|
foreignObject | Core.attrib, Conditional.attrib, External.attrib, Style.attrib, Presentation.attrib, GraphicsElementEventAttrs, transform, x, y, width, height, content | #PCDATA |
Extensibility モジュールは Extensibility.class 内容セットを定義する。
内容セット名 | 内容セットに含まれる要素 |
---|---|
Extensibility.class | foreignObject |
次に挙げるインターフェースが以下で定義される: SVGForeignObjectElement
SVGForeignObjectElement インターフェースは 'foreignObject' 要素に対応する。
interface SVGForeignObjectElement : SVGElement, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGStylable, SVGTransformable, events::EventTarget { readonly attribute SVGAnimatedLength x; readonly attribute SVGAnimatedLength y; readonly attribute SVGAnimatedLength width; readonly attribute SVGAnimatedLength height; };