精图规范1.0----5 文档结构 Document Structure

previous next   contents   elements   attributes   properties   index  


04 September 2001

5 文档结构 Document Structure



内容 Contents


 

5.1 定义一块精图文档片段:  'svg'元素 Defining an SVG documentfragment: the 'svg' element

5.1.1 概览 Overview

一块精图文档片段由包含在一个'svg'元素内的任意数目的精图元素所组成.   An SVG document fragment consists of any number of SVGelements contained within an 'svg' element.

一块精图文档片段范围可以从一空片段 (即, 在'svg' 元素内部无内容), 到包含一个单一的精图图形元素比如'rect'的非常简单的精图文档片段 , 到一个极复杂的由容器元素图形元素的深度嵌套的文档.    An SVGdocument fragment can range from an empty fragment (i.e., no content inside ofthe 'svg' element), to a very simple SVGdocument fragment containing a single SVGgraphicselement such as a 'rect', to a complex, deeply nested collection ofcontainerelements andgraphicselements.

一块精图文档片段可以作为一种自包含文件或资源而独立存在, 在这种情况下精图文档片段为一种 精图文档, 否则它可以作为一片段内联嵌入一父XML文档中.     An SVG documentfragment can stand by itself as a self-contained file or resource, in whichcase the SVG document fragment is an SVG document,or it can be embedded inline as a fragment within a parent XML document.

下面的例子说明简单的精图内容作为片段内联嵌入父XML文档中. Note the use of XML namespacesto indicate that the 'svg' and 'ellipse' elements belong to the SVGnamespace:    The following example shows simple SVG content embedded inline as a fragment within aparent XML document. Note the use of XML namespaces to indicate that the 'svg' and 'ellipse'elements belong to the SVG namespace:

 
<?xml version="1.0" standalone="yes"?>
<parent xmlns="http://example.org"
       xmlns:svg="http://www.w3.org/2000/svg">
   <!-- parent contents here -->
   <svg:svg width="4cm" height="8cm">
      <svg:ellipse cx="2cm" cy="4cm" rx="2cm" ry="1cm" />
   </svg:svg>
   <!-- ... -->
</parent>

下面的这个例子说明一个稍微更复杂 (即, 它包含多个矩形) 独立的, 自包含的精图文档:   This example shows aslightly more complex (i.e., it contains multiple rectangles) stand-alone,self-contained SVG document:

 
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="5cm" height="4cm"
     xmlns="http://www.w3.org/2000/svg">
  <desc>Four separate rectangles
  </desc>
    <rect x="0.5cm" y="0.5cm" width="2cm" height="1cm"/>
    <rect x="0.5cm" y="2cm" width="1cm" height="1.5cm"/>
    <rect x="3cm" y="0.5cm" width="1.5cm" height="2cm"/>
    <rect x="3.5cm" y="3cm" width="1cm" height="0.5cm"/>
 
  <!-- Show outline of canvas using 'rect' element -->
  <rect x=".01cm" y=".01cm" width="4.98cm" height="3.98cm"
        fill="none" stroke="blue" stroke-width=".02cm" />
 
</svg>

View thisexample as SVG (SVG-enabled browsers only)
 

'svg' 元素可以出现在精图内容的中间.这是一种可以让精图文档片段嵌入另一个精图文档片段的机制.    'svg' elementscan appear in the middle of SVG content. This is the mechanism by which SVGdocument fragments can be embedded within other SVG document fragments.

另一个在精图内容的中间使用'svg' 元素将建立一个新的视口. (参见 建立一个新的视口.)    Another use for 'svg' elements within themiddle of SVG content is to establish a new viewport. (SeeEstablishinga new viewport.)

在所有情况下, 为了遵守 "XML命名空间" 推荐规范 [XML-NS], 必须提供精图命名空间的声明使得所有精图元素标识为属于此命名空间. 下面是提供一个命名空间的声明的可能方式. 可以在一个'svg'元素上指定无命名空间前缀的 xmlns 性质, 它意味着精图是具有 xmlns 性质的元素的作用域上的所有元素的缺省命名空间:     In all cases, for compliance with the"Namespaces in XML" Recommendation [XML-NS], an SVG namespacedeclaration must be provided so that all SVG elements are identified asbelonging to the SVG namespace. The following are possible ways to provide anamespace declaration. An xmlns attribute withouta namespace prefix could be specified on an 'svg'element, which means that SVG is the default namespace for all elements withinthe scope of the element with the xmlns attribute:

<svg xmlns="http://www.w3.org/2000/svg"...>
  <rect .../>
</svg>

如果在xmlns 性质上指定了命名空间前缀 (例如, xmlns:svg="http://www.w3.org/2000/svg"), 那么相应的命名空间不是缺省的命名空间, 因此一个明确的命名空间前缀必须指派给这些元素:   If a namespace prefix isspecified on the xmlns attribute (e.g.,xmlns:svg="http://www.w3.org/2000/svg"), then the corresponding namespace is notthe default namespace, so an explicit namespace prefix must be assigned to theelements:

<svg:svg xmlns:svg="http://www.w3.org/2000/svg"...>
  <svg:rect .../>
</svg:svg>

命名空间前缀可以在祖先元素上指定 (解释在上面的例子).关于更多的信息, 请参见 "XML命名空间" 推荐规范 [XML-NS].    Namespaceprefixes can be specified on ancestor elements (illustrated in the above example). For more information, refer tothe "Namespaces in XML" Recommendation [XML-NS].

5.1.2 'svg'元素  The 'svg' element

 
<!ENTITY % svgExt "" >
<!ELEMENT svg (desc|title|metadata|defs|
                   path|text|rect|circle|ellipse|line|polyline|polygon|
                   use|image|svg|g|view|switch|a|altGlyphDef|
                   script|style|symbol|marker|clipPath|mask|
                   linearGradient|radialGradient|pattern|filter|cursor|font|
                   animate|set|animateMotion|animateColor|animateTransform|
                   color-profile|font-face
                   %ceExt;%svgExt;)* >
<!ATTLIST svg
  xmlns CDATA #FIXED "http://www.w3.org/2000/svg"
  %stdAttrs;
  %testAttrs;
  %langSpaceAttrs;
  externalResourcesRequired %Boolean; #IMPLIED 
  class %ClassList; #IMPLIED
  style %StyleSheet; #IMPLIED
  %PresentationAttributes-All;
  viewBox %ViewBoxSpec; #IMPLIED
  preserveAspectRatio %PreserveAspectRatioSpec; 'xMidYMid meet'
  zoomAndPan (disable | magnify) 'magnify'
  %graphicsElementEvents;
  %documentEvents;
  version %Number; #FIXED "1.0"
  x %Coordinate; #IMPLIED
  y %Coordinate; #IMPLIED
  width %Length; #IMPLIED
  height %Length; #IMPLIED
  contentScriptType %ContentType; "text/ecmascript"
  contentStyleType %ContentType; "text/css" >

性质定义: Attribute definitions:

xmlns [:prefix]= "resource-name"

指定一个XML命名空间的标准XML性质. 参见 "XML命名空间" 推荐规范 [XML-NS].  Standard XML attribute for identifying an XML namespace. Refer to the"Namespaces in XML" Recommendation [XML-NS].
Animatable:no.

version = "<number>"

表示此文档片段所遵循的精图语言的版本.    Indicates the SVG language version to which thisdocument fragment conforms.
对于精图 1.0, 这一性质固定为值 "1.0". 对于对应于此规范的未来版本的文档片段,此性质必须提供.     ForSVG 1.0, this attribute is fixed to the value "1.0". For documentfragments corresponding to future versions of the specification, this attributewill be required.
Animatable:no.

x = "<coordinate>"

(在最外层的'svg' 元素上无意义或无效.) (Has no meaning or effect on outermost 'svg'elements.)
在所嵌入的'svg'元素中安置此元素的矩形区域的一个角的x-轴的坐标.  The x-axis coordinate of one corner of the rectangular region into which anembedded 'svg' element is placed.
如果不指定此性质, 其效果相当于指定此性质的值为"0".     If the attribute is not specified, the effect is as if a value of "0"were specified.
Animatable:yes.

y = "<coordinate>"

(在最外层的'svg' 元素上无意义或无效.) (Has no meaning or effect on outermost 'svg'elements.)
在所嵌入的'svg'元素中安置此元素的矩形区域的一个角的y-轴的坐标.  The y-axis coordinate of one corner of the rectangular region into which anembedded 'svg' element is placed.
如果不指定此性质, 其效果相当于指定此性质的值为"0".     If the attribute is not specified, the effect is as if a value of "0"were specified.
Animatable:yes.

width = "<length>"

对于最外层的'svg' 元素, 精图文档片段的固有宽度. 对于被嵌入的 'svg' 元素, 安置此'svg'元素的矩形区域的宽度.     For outermost 'svg'elements, the intrinsic width of the SVG document fragment. For embedded 'svg' elements, the width of the rectangular regioninto which the 'svg' element is placed.
负值是一种错误 (参见 错误处理).值为零则不渲染此元素.   A negative value is an error (see Error processing).A value of zero disables rendering of the element.
如果不指定此性质, 其效果相当于指定此性质的值为"100%".     If the attribute is not specified, the effect is as if a value of"100%" were specified.
Animatable:yes.

height = "<length>"

对于最外层的'svg' 元素, 精图文档片段的固有高度. 对于被嵌入的 'svg' 元素, 安置此'svg'元素的矩形区域的高度.    For outermost 'svg'elements, the intrinsic height of the SVG document fragment. For embedded 'svg' elements, the height of the rectangular regioninto which the 'svg' element is placed.
负值是一种错误 (参见 错误处理).值为零则不渲染此元素.   A negative value is an error (see Errorprocessing). A value of zero disables rendering of the element.
如果不指定此性质, 其效果相当于指定此性质的值为"100%".     If the attribute is not specified, the effect is as if a value of"100%" were specified.
Animatable:yes.

 

在别处定义的性质:  Attributes defined elsewhere:

%stdAttrs;,%langSpaceAttrs;,class,%graphicsElementEvents;,%documentEvents;,%testAttrs;,externalResourcesRequired,viewBox,preserveAspectRatio,zoomAndPan,contentScriptType,contentStyleType,style,%PresentationAttributes-All;.

如果一个精图文档很可能作为另一个文档的部件来引用, 作者常常要在被引用的文档的最外层的'svg' 元素中包含一个 viewBox 性质 . 此性质提供一种方便的方法来设计精图文档使得它可以通过缩放来适应任意的视口.      If an SVG document is likely to bereferenced as a component of another document, the author will often want toinclude aviewBox attribute on the outermost 'svg' element of the referenced document. Thisattribute provides a convenient way to design SVG documents to scale-to-fitinto an arbitrary viewport.

5.2 分组: 'g'元素 Grouping: the 'g' element

5.2.1 概览 Overview

'g'元素是为了对相关的图形元素进行分组的一种容器元素 .    The 'g' element is a containerelement for grouping together related graphicselements.

分组结构, 当与 'desc''title' 元素结合时, 提供关于文档结构和语义的信息.在结构上丰富的文档既可以以图形方式进行渲染, 也可以作为语音进行播放, 或者用盲字进行印刷, 从而提升可达性.    Grouping constructs, when used in conjunction with the 'desc' and 'title' elements, provide information aboutdocument structure and semantics. Documents that are rich in structure may berendered graphically, as speech, or as braille, and thus promoteaccessibility.

一组元素, 和单独的对象一样, 可以通过使用 id 性质提供一个名字. 基于几种目的比如一个动画和重用对象需要命名分组.    A group of elements, as well as individualobjects, can be given a name using theid attribute. Named groups are needed for severalpurposes such as animation and re-usable objects.

一个例子:  Anexample:

 
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="5cm" height="5cm"
     xmlns="http://www.w3.org/2000/svg">
  <desc>Two groups, each of two rectangles
  </desc>
  <g id="group1" fill="red" >
    <rect x="1cm" y="1cm" width="1cm" height="1cm" />
    <rect x="3cm" y="1cm" width="1cm" height="1cm" />
  </g>
  <g id="group2" fill="blue" >
    <rect x="1cm" y="3cm" width="1cm" height="1cm" />
    <rect x="3cm" y="3cm" width="1cm" height="1cm" />
  </g>
 
  <!-- Show outline of canvas using 'rect' element -->
  <rect x=".01cm" y=".01cm" width="4.98cm" height="4.98cm"
        fill="none" stroke="blue" stroke-width=".02cm" />
 
</svg>

View thisexample as SVG (SVG-enabled browsers only)
 

一个'g' 元素可以包含其它嵌入其中的'g' 元素, 并且可以达到任意深度. 于是, 下面是可能的:   A 'g' element can contain other 'g' elements nested within it, to an arbitrary depth.Thus, the following is possible:

 
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="4in" height="3in"
     xmlns="http://www.w3.org/2000/svg">
  <desc>Groups can nest
  </desc>
  <g>
     <g>
       <g>
       </g>
     </g>
   </g>
</svg>

如何不包含在一个'g'中的元素可以(至少在概念上)就像它在它的自己组里那样来对待 .   Any element that is not contained within a 'g' is treated (at least conceptually)as if it were in its own group.

5.2.2 'g'元素 The 'g' element

 
<!ENTITY % gExt "" >
<!ELEMENT g (desc|title|metadata|defs|
                   path|text|rect|circle|ellipse|line|polyline|polygon|
                   use|image|svg|g|view|switch|a|altGlyphDef|
                   script|style|symbol|marker|clipPath|mask|
                   linearGradient|radialGradient|pattern|filter|cursor|font|
                   animate|set|animateMotion|animateColor|animateTransform|
                   color-profile|font-face
                   %ceExt;%gExt;)* >
<!ATTLIST g
  %stdAttrs;
  %testAttrs;
  %langSpaceAttrs;
  externalResourcesRequired %Boolean; #IMPLIED
  class %ClassList; #IMPLIED
  style %StyleSheet; #IMPLIED
  %PresentationAttributes-All;
  transform %TransformList; #IMPLIED
  %graphicsElementEvents;  >

 

在别处定义的性质:  Attributes defined elsewhere:

%stdAttrs;,%langSpaceAttrs;,class,transform,%graphicsElementEvents;,%testAttrs;,externalResourcesRequired,style,%PresentationAttributes-All;.



5.3 引用和'defs'元素 References and the 'defs' element

5.3.1 概览 Overview

精图广泛使用URI 引用 [URI] 对其它对象进行引用. 例如, 为了使用一种线性渐变填充一个矩形, 你首先定义一个'linearGradient' 元素并为它分配一个 ID, 如下:     SVGmakes extensive use of URI references [URI] to other objects. Forexample, to fill a rectangle with a linear gradient, you first define a 'linearGradient' element and give it an ID, as in:

 
<linearGradient id="MyGradient">...</linearGradient>

然后你引用此线性渐变作为矩形的 'fill' 填充属性的值, 如下:  Youthen reference the linear gradient as the value of the 'fill' property for therectangle, as in:

 
<rect style="fill:url(#MyGradient)"/>

在精图中, 下列项允许使用URI 引用:   In SVG, thefollowing facilities allow URI references:

URI 引用定义为下列形式之一:    URI references are defined in either of thefollowing forms:

 
<URI-reference> = [ <absoluteURI> | <relativeURI> ] [ "#" <elementID> ]    -or-
<URI-reference> = [ <absoluteURI> | <relativeURI> ] [ "#xpointer(id(" <elementID> "))" ]

这里 <elementID> 为被引用元素的 ID .   where <elementID> is the ID of the referencedelement.

(注意上面的两种在语法上用公式表示的形式 (即, #<elementID> 和#xpointer(id(<elementID>))) 与 "XML 指针语言 (XPointer)" [XPTR]兼容. URI 引用的这两种公式仅XPointer公式在精图1.0用户代理被要求.)    (Notethat the two forms above (i.e., #<elementID>and #xpointer(id(<elementID>))) areformulated in syntaxes compatible with "XML Pointer Language(XPointer)" [XPTR]. These twoformulations of URI references are the only XPointer formulations that arerequired in SVG 1.0 user agents.)

精图支持两类URI 引用:   SVG supports twotypes of URI references:

  • 本地URI引用, 这里URI引用不包含一个 <absoluteURI> 或 <relativeURI> 而仅仅包含一段标识符(即, #<elementID> 或 #xpointer(id<elementID>))   local URI references, where the URI reference does not contain an <absoluteURI> or <relativeURI> and thus only contains a fragment identifier (i.e., #<elementID> or #xpointer(id<elementID>))
  • 非本地URI引用, 这里URI引用包含一个 <absoluteURI> 或 <relativeURI>   non-local URI references, where the URI reference does contain an <absoluteURI> or <relativeURI>

下列规则用于处理URI引用:    The followingrules apply to the processing of URI references:

  • URI引用的节点不存在则此引用被看成是无效的引用 .   URI references to nodes that do not exist shall be treated as invalid references.
  • URI引用的元素为不适当的的目标此引用被看成是无效的引用 . 例如, 'clip-path' 属性只能引用 'clipPath' 元素. 属性设置 clip-path:url(#MyElement) 是无效的引用如果所引用的元素不是一个 'clipPath'的话.    URI references to elements which are inappropriate targets for the given reference shall be treated as invalid references. For example, the'clip-path' property can only refer to 'clipPath' elements. The property setting clip-path:url(#MyElement) is an invalid reference if the referenced element is not a 'clipPath'.

除了'a' 元素上的xlink:href 性质和在URI引用无效时允许使用备用值的某些属性(参见 'fill''stroke')外 :     Except for thexlink:href attribute on the 'a' element and for some properties will allowfor backup values in case a URI reference is invalid (see'fill' and'stroke'):

  • 一个无效的本地URI引用 (即, 对当前文档中的节点的无效引用) 表示一种错误 (参见 错误处理).   An invalid local URI reference (i.e., an invalid references to a node within the current document) represents an error (seeError processing).
  • 如果在引用元素或其祖先上当性质 externalResourcesRequired 设置为 true , 那么一个无解的外部URI引用 (即, 一种资源不能被定位) 表示一种错误 (参见错误处理).     When attributeexternalResourcesRequired has been set to true on the referencing element or one of its ancestors, then an unresolved external URI reference (i.e., a resource that cannot be located) represents an error (seeError processing).

建议无论哪里被引用的元素定义在一个'defs' 元素里. 在这些总是被引用的元素里:'altGlyphDef','clipPath', 'cursor', 'filter', 'linearGradient', 'marker', 'mask', 'pattern', 'radialGradient''symbol'. 在'defs'元素里定义这些元素可以提升精图内容的易懂性从而提升其可达性.    It is recommended that, wherever possible,referenced elements be defined inside of a'defs' element. Among the elements that arealways referenced: 'altGlyphDef', 'clipPath', 'cursor', 'filter', 'linearGradient', 'marker', 'mask', 'pattern', 'radialGradient' and 'symbol'. Defining these elements inside of a 'defs' element promotes understandability of theSVG content and thus promotes accessibility.

5.3.2 URI引用性质  URI reference attributes

一个URI引用通过XLink [XLINK]命名空间的一个href 性质来指定. 如果在XLink命名空间的性质使用缺省前缀 'xlink:', 那么此性质指定为 xlink:href. 这一性质的值为对期望的资源的URI引用 (或者资源片段).    A URI reference is specified within an href attribute in the XLink [XLINK] namespace. If the default prefixof 'xlink:' is used for attributes in the XLink namespace, then the attributewill be specified as xlink:href. The value of thisattribute is a URI reference for the desired resource (or resource fragment).

href 性质的值必须为定义在 [RFC2396]中的URI引用, 或者在下面所描述的转义过程执行之后其结果必须为URI引用. 当将此URI引用传给一个URI分解器时使用此过程.   The value of the href attribute must be a URIreference as defined in [RFC2396],or must result in a URI reference after the escaping procedure described belowis applied. The procedure is applied when passing the URI reference to a URIresolver.

某些字符不允许用在URI引用中, 即使它们在XML中允许使用 ; 不允许的字符包括所有 非-ASCII 字符, 加上在[RFC2396]的章节 2.4里排除的字符 , except for the number sign(#) and 百分号 (%) 和方括号字符 re-allowed in [RFC2732]???. 不允许的字符必须转义如下:    Some characters are disallowed in URI references, even if they are allowed inXML; the disallowed characters include all non-ASCII characters, plus theexcluded characters listed in Section 2.4 of [RFC2396], except for the numbersign (#) and percent sign (%) and the square bracket characters re-allowed in [RFC2732]. Disallowed charactersmust be escaped as follows:

1.     每个不允许的字符转换为一个或更多字节的 UTF-8 [RFC2279].    Each disallowed character is converted to UTF-8 [RFC2279] as one or more bytes.

2.     对应于不允许字符的任何字节使用URI转义机制进行转义 (即, 转换成%HH, 这里 HH 为字节值的十六进制记法).       Any bytes corresponding to a disallowed character are escaped with the URIescaping mechanism (that is, converted to%HH, where HH is the hexadecimal notation of the byte value).

3.     原字符用结果字符序列代替.    The original character is replaced by theresulting character sequence.

因为要求任何应用检查一个值是否为URI引用是不切实际的, 这一规范 在这件事情上效仿 [RFC2396]  故在精图应用上并不要求进行这种兼容测试.     Because it is impractical for any application to check that a value is a URIreference, this specification follows the lead of [RFC2396] in this matter andimposes no such conformance testing requirement on SVG applications.

如果URI 引用是相对的, 它的绝对版本必须在使用之前根据 [XML-Base] 中的方法进行计算.     If the URI reference is relative, its absolute version must be computed by themethod of [XML-Base] before use.

为了定位XML 资源, 用在URI 引用中的部分标识符(如果有的话) 按照XPointer规范[XPTR]来指定 .    For locators into XML resources, the format ofthe fragment identifier (if any) used within the URI reference is specified bythe XPointer specification [XPTR].

可以指定额外的XLink性质来提供关于被引用的资源的附加信息. 这些附加的性质被包含在下列实体的DTD中. 这两个实体定义仅仅在xlink:show的值上不同 , 其中在第一个实体上它的值为 other 而在第二个实体上它的值为 embed. 第一个实体定义用于大多数引用资源的元素定义上. 第二个实体定义用于元素 'use', 'image''feImage'.      Additional XLink attributes can be specified that provide supplementalinformation regarding the referenced resource. These additional attributes areincluded in the DTD inthe following entities. The two entity definitions differ only in the value ofxlink:show, which has the value other in the first entity and the value embed in the second. The first entity definition isused in most element definitions which reference resources. The second entitydefinition is used by elements'use','image' and 'feImage'.

 
<!ENTITY % xlinkRefAttrs
 "xmlns:xlink CDATA #FIXED 'http://www.w3.org/1999/xlink'
  xlink:type (simple) #FIXED 'simple' 
  xlink:role %URI; #IMPLIED
  xlink:arcrole %URI; #IMPLIED
  xlink:title CDATA #IMPLIED
  xlink:show (other) 'other'
  xlink:actuate (onLoad) #FIXED 'onLoad'" >
 
<!ENTITY % xlinkRefAttrsEmbed
 "xmlns:xlink CDATA #FIXED 'http://www.w3.org/1999/xlink'
  xlink:type (simple) #FIXED 'simple' 
  xlink:role %URI; #IMPLIED
  xlink:arcrole %URI; #IMPLIED
  xlink:title CDATA #IMPLIED
  xlink:show (embed) 'embed'
  xlink:actuate (onLoad) #FIXED 'onLoad'" >

xmlns [:prefix]= "resource-name"

指定一个XML命名空间的标准XML性质. 这一性质使得 XLink [XLink] 命名空间对当前元素是可用的. 参见 "XML命名空间" 推荐规范 [XML-NS].     Standard XML attribute for identifying an XML namespace. This attribute makesthe XLink [XLink] namespace availableto the current element. Refer to the "Namespaces in XML"Recommendation [XML-NS].
Animatable:no.

xlink:type = 'simple'

指定将使用的XLink的类型. 在精图里, 仅简单的链接是可用的. 参考 "XML 链接语言 (XLink)" [XLink].    Identifies thetype of XLink being used. In SVG, only simple links are available. Refer to the"XML Linking Language (XLink)" [XLink].
Animatable:no.

xlink:role = '<uri>'

一个URI 引用 标识描述想要的属性的某种资源. 其值必须为一个 按照在 [RFC2396]中定义的URI 引用, 除了所用的URI 方案可以为绝对和相对形式外,URI 部分必须为绝对的. 当不提供值时, 不能推断特定的角色. 在此性质中URI引用不允许使用的字符必须使用此章节之前所描述的方法进行特别的编码. 参考 "XML 链接语言 (XLink)" [XLink].      AURI referencethat identifies some resource that describes the intended property. The valuemust be a URI reference as defined in [RFC2396], except that if the URIscheme used is allowed to have absolute and relative forms, the URI portionmust be absolute. When no value is supplied, no particular role value is to beinferred. Disallowed URI reference characters in these attribute values must bespecially encoded as described earlier in this section. Refer to the "XMLLinking Language (XLink)" [XLink].
Animatable:no.

xlink:arcrole = '<uri>'

一个URI 引用 标识描述想要的属性的某种资源. 其值必须为一个 按照在 [RFC2396]中定义的URI 引用, 除了所用的URI 方案可以为绝对和相对形式外,URI 部分必须为绝对的. 当不提供值时, 不能推断特定的角色. 在此性质中URI引用不允许使用的字符必须使用此章节之前所描述的方法进行特别的编码.  arcrole 性质对应于一个属性的 [RDF] 记法, 这里角色可以解释为陈述"开始资源 HASarc-role 结束资源." 当在这种特定弧的上下文的外部时这种上下文相关的角色不同于结束资源的意义???.例如, 一个资源也许常常表示一个 "人," 但是当在特定弧的上下文里它可以有"母亲"的角色而在一个不同弧的上下文里它可以有"女儿"的角色.  参考 "XML 链接语言 (XLink)" [XLink].        AURIreference that identifies some resource that describes the intendedproperty. The value must be a URI reference as defined in [RFC2396], except that if the URIscheme used is allowed to have absolute and relative forms, the URI portionmust be absolute. When no value is supplied, no particular role value is to beinferred. Disallowed URI reference characters in these attribute values must bespecially encoded as described earlier in this section. The arcrole attributecorresponds to the [RDF]notion of a property, where the role can be interpreted as stating that"starting-resource HAS arc-role ending-resource." This contextualrole can differ from the meaning of an ending resource when taken outside thecontext of this particular arc. For example, a resource might genericallyrepresent a "person," but in the context of a particular arc it mighthave the role of "mother" and in the context of a different arc itmight have the role of "daughter." Refer to the "XML LinkingLanguage (XLink)" [XLink].
Animatable:no.

xlink:title = '<string>'

标题性质用于以可供人阅读的形式描述链接或资源的意义, 这里跟着和role 或 arcrole相同的句子. 此值是可选的; 如果提供值, 将包含描述资源的字符串. 这一信息的使用非常依赖进行处理的类型. 例如对于面向视觉缺陷的用户的应用使得此标题是可用的, 或者创建一个链接表格, 或者当用户用鼠标掠过一个开始资源上方时呈现帮组文本. 参考 "XML 链接语言 (XLink)" [XLink].          The title attribute is used to describe the meaning of a link or resource in ahuman-readable fashion, along the same lines as the role or arcrole attribute.A value is optional; if a value is supplied, it should contain a string thatdescribes the resource. The use of this information is highly dependent on thetype of processing being done. It may be used, for example, to make titles availableto applications used by visually impaired users, or to create a table of links,or to present help text that appears when a user lets a mouse pointer hoverover a starting resource. Refer to the "XML Linking Language (XLink)"[XLink].
Animatable:no.

xlink:show = 'embed'

一个应用在经过到达结束资源时将用结束资源的表示替换开始资源的表示. 参考 "XML 链接语言 (XLink)" [XLink].          An application traversing to the ending resource should load its presentationin place of the presentation of the starting resource. Refer to the "XMLLinking Language (XLink)" [XLink].
Animatable:no.

xlink:actuate = 'onLoad'

表示应用在装载开始资源时立即跨越结束资源???. 参考 "XML 链接语言 (XLink)" [XLink].           Indicates that the application should traverse to the ending resourceimmediately on loading the starting resource. Refer to the "XML LinkingLanguage (XLink)" [XLink].
Animatable:no.

在所有情况下, 为了与"XML命名空间" 推荐规范 [XML-NS]兼容, 无论何时上述XLink 性质之一用于精图内容上都必须提供一个显式的 XLink 命名空间声明. 提供这种XLink 命名空间声明的一种简单方法为在使用XLink性质的内容的最外层的'svg' 元素上包含一个用于XLink命名空间的 xmlns 性质. 例如:    In all cases, for compliance with the "Namespaces in XML"Recommendation [XML-NS], anexplicit XLink namespace declaration must be provided whenever one of the aboveXLink attributes is used within SVG content. One simple way to provide such anXLink namespace declaration is to include an xmlnsattribute for the XLink namespace on the outermost 'svg'element for content that uses XLink attributes. For example:

<svg xmlns:xlink="http://www.w3.org/1999/xlink"...>
  <image xlink:href="foo.png" .../>
</svg>

5.3.3 'defs'元素   The 'defs' element

  'defs' 元素为一种包含被引用元素的容器元素. 基于易懂性和可达性 的理由, 建议尽可能将被引用的元素定义在一个'defs'的里面.     The 'defs' element is a container element forreferenced elements. Forunderstandability andaccessibilityreasons, it is recommended that, whenever possible, referenced elements bedefined inside of a 'defs'.

The content model for 'defs'的内容模型与 'g' 元素的相同; 于是, 任何能够作为一个'g'的子元素的元素都可以成为'defs'的子元素, 反之亦然.  The content model for 'defs' is the same as forthe'g' element; thus, any element that can be achild of a 'g' can also be a child of a 'defs', and vice versa.

一个 'defs' 的后裔元素不被直接渲染; 它们被阻止成为渲染树的一部分就像 'defs' 元素为一'g' 元素并且其'display' 属性被设置成none一样. 注意, 无论如何, 'defs'的后裔总是呈现在源树上于是总是可以被其它元素所引用;于是, the valueof the在 'defs' 元素上和后裔的'display' 属性的值不能阻止这些元素被其它元素所引用.       Elements that are descendantsof a 'defs' are not rendered directly; they areprevented from becoming part of the rendering tree just as if the 'defs' element were a'g' element and the 'display' property were set to none. Note, however, that the descendants of a 'defs' are always present in the source tree and thuscan always be referenced by other elements; thus, the value of the'display' property on the 'defs'element or any of its descendants does not prevent those elements from beingreferenced by other elements.

 
<!ENTITY % defsExt "" >
<!ELEMENT defs (desc|title|metadata|defs|
                   path|text|rect|circle|ellipse|line|polyline|polygon|
                   use|image|svg|g|view|switch|a|altGlyphDef|
                   script|style|symbol|marker|clipPath|mask|
                   linearGradient|radialGradient|pattern|filter|cursor|font|
                   animate|set|animateMotion|animateColor|animateTransform|
                   color-profile|font-face
                   %ceExt;%defsExt;)* >
<!ATTLIST defs
  %stdAttrs;
  %testAttrs;
  %langSpaceAttrs;
  externalResourcesRequired %Boolean; #IMPLIED
  class %ClassList; #IMPLIED
  style %StyleSheet; #IMPLIED
  %PresentationAttributes-All;
  transform %TransformList; #IMPLIED
  %graphicsElementEvents;  >

 

在别处定义的性质:  Attributes defined elsewhere:

%stdAttrs;,%langSpaceAttrs;,class,transform,%testAttrs;,externalResourcesRequired,style,%PresentationAttributes-All;,%graphicsElementEvents;.

为了给某些精图用户代理提供一种在流环境中执行有效的实现的机会, 鼓励精图内容的作者安放所有为本地URI 引用的目标的元素在一个 'defs'元素内而此'defs'元素为引用元素的祖先的一个直接的孩子. 例如:    To providesome SVG user agents with an opportunity to implement efficient implementationsin streaming environments, creators of SVG content are encouraged to place allelements which are targets of local URI references within a 'defs' element which is a direct child of one of theancestors of the referencing element. For example:

 
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="8cm" height="3cm"
     xmlns="http://www.w3.org/2000/svg">
  <desc>Local URI references within ancestor's 'defs' element.</desc>
  <defs>
    <linearGradient id="Gradient01">
      <stop offset="20%" stop-color="#39F" />
      <stop offset="90%" stop-color="#F3F" />
    </linearGradient>
  </defs>
  <rect x="1cm" y="1cm" width="6cm" height="1cm" 
        fill="url(#Gradient01)"  />
 
  <!-- Show outline of canvas using 'rect' element -->
  <rect x=".01cm" y=".01cm" width="7.98cm" height="2.98cm"
        fill="none" stroke="blue" stroke-width=".02cm" />
 
</svg>

View this exampleas SVG (SVG-enabled browsers only)
 

在上述文档中, 一个线性渐变定义在一个'defs' 元素内而此'defs' 元素为'svg' 元素的直接孩子, 'svg'元素也为 'rect' 元素的祖先而此'rect'元素引用了此线性渐变. 于是, 上述文档遵循了上述指导方针.      In the document above, the lineargradient is defined within a 'defs' elementwhich is the direct child of the 'svg' element,which in turn is an ancestor of the 'rect'element which references the linear gradient. Thus, the above document conformsto the guideline.

5.4 'desc' 和 'title'元素  The 'desc' and 'title'elements

在一个精图图画中的每个 容器元素 图形元素可以使用一个 'desc' 和/或一个 'title' 描述字符串此描述是纯文本的.当在一种可视媒体上当前的精图文档片段作为精图进行渲染时, 'desc' 和 'title' 元素不被作为图形的一部分进行渲染 . 无论如何作为一个例子当指点设备掠过特定的元素时, 用户代理将 'title' 元素作为小提示进行显示. 一种替换的表示也是可能的, 不管是视觉的还是听觉的, 它显示 'desc' 和 'title' 元素而不显示'path'元素或其它图形元素.这可以通过使用一个不同的(也许为用户)样式表就可以容易达到. 对于更深的层次, 和对于下列 'use' 元素引用, 有时期望允许用户控制他们将下钻到描述文本有多深.     Each containerelement or graphicselement in an SVG drawing can supply a 'desc'and/or a 'title' description string where thedescription is text-only. When the current SVG document fragment is rendered asSVG on visual media, 'desc' and 'title' elements are not rendered as part of thegraphics. User agents may, however, for example, display the 'title' element as a tooltip, as the pointing devicemoves over particular elements. Alternate presentations are possible, bothvisual and aural, which display the 'desc' and 'title' elements but do not display 'path'elements or other graphicselements. This is readily achieved by using a different (perhaps user)style sheet. For deep hierarchies, and for following'use' element references, it is sometimesdesirable to allow the user to control how deep they drill down intodescriptive text.

 
<!ENTITY % descExt "" >
<!ELEMENT desc (#PCDATA %descExt;)* >
<!ATTLIST desc
  %stdAttrs;
  %langSpaceAttrs;
  class %ClassList; #IMPLIED
  style %StyleSheet; #IMPLIED
  %StructuredText; >

在别处定义的性质:  Attributes defined elsewhere:

%stdAttrs;,%langSpaceAttrs;,class,style.

 
<!ENTITY % titleExt "" >
<!ELEMENT title (#PCDATA %titleExt;)* >
<!ATTLIST title
  %stdAttrs;
  %langSpaceAttrs;
  class %ClassList; #IMPLIED
  style %StyleSheet; #IMPLIED
  %StructuredText; >

在别处定义的性质:  Attributes defined elsewhere:

%stdAttrs;,%langSpaceAttrs;,class,style.

下面是一个例子.在典型的操作中, 精图用户代理将不渲染'desc'和 'title'元素而将渲染 'g' 元素余下的内容 .     The following is an example. In typicaloperation, the SVG user agent would not render the 'desc'and 'title' elements but would render theremaining contents of the'g' element.

 
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg SYSTEM "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="4in" height="3in"
     xmlns="http://www.w3.org/2000/svg">
<g>
  <title>
    Company sales by region
  </title>
  <desc>
    This is a bar chart which shows 
    company sales by region.
  </desc>
  <!-- Bar chart defined as vector data -->
</g>
</svg>

描述和标题元素可以包含来自其它命名空间的标记文本. 这里是一个例子:   Description and title elements can contain marked-up text from othernamespaces. Here is an example:

 
<?xml version="1.0" standalone="yes"?>
<svg width="4in" height="3in" 
 xmlns="http://www.w3.org/2000/svg">
   <desc xmlns:mydoc="http://example.org/mydoc">
      <mydoc:title>This is an example SVG file</mydoc:title>
      <mydoc:para>The global description uses markup from the 
        <mydoc:emph>mydoc</mydoc:emph> namespace.</mydoc:para>
   </desc>
   <g>
   <!-- the picture goes here -->
   </g>
</svg>

作者应当总是为在一个单独的精图文档中的最外层的'svg' 元素提供一个'title' 子元素.'svg' 元素的'title' 子元素用于标识给定的精图文档片段的内容. 因为用户常常参考上下文之外的文档, 作者应该提供丰富上下文的标题.于是, 代替不能提供更多上下文背景的标题比如"Introduction", 作者应该提供比如"Introduction to Medieval Bee-Keeping" 这样的标题. 基于可达性的理由, 用户代理应该使最外层的'svg'元素的'title'子元素对用户总是可用的. 如何做这些的机制依赖于用户代理(例如, 字幕 , 口语).     Authors should always provide a 'title' childelement to the outermost'svg' element within a stand-alone SVG document.The 'title' child element to an'svg' element serves the purposes of identifyingthe content of the given SVG document fragment. Since users often consultdocuments out of context, authors should provide context-rich titles. Thus,instead of a title such as "Introduction", which doesn’t provide muchcontextual background, authors should supply a title such as "Introductionto Medieval Bee-Keeping" instead. For reasons of accessibility, useragents should always make the content of the 'title'child element to the outermost'svg' element available to users. The mechanismfor doing so depends on the user agent (e.g., as a caption, spoken).

很多精图的元素的 DTD 定义 (特别地, 容器和文本元素) 对安置 'desc''title' 子元素的位置和数量没有限制. 这种灵活性仅仅表示对于容器元素有一个一致的内容模型, 因为在精图中某些容器元素允许混合的内容, 而关于XML [XML-MIXED]的混合内容规则不允许所期望的限制. 精图语言的未来版本的表示也许使用比DTD更富表现的表达式它允许对混合内容规则更多的限制. 强烈建议最多一个 'desc' 和最多一个'title' 元素作为任何特定元素的子元素, 并且这些元素出现在任何其它子元素 (除非可能的'metadata' 元素) 或者字符数据内容的前面 . 如果用户代理需要选择多个'desc''title'元素之一进行处理(例如, 决定哪个字符串用于小提示), 用户代理将选择第一个.       The DTD definitions of many of SVG's elements (particularly, container and textelements) place no restriction on the placement or number of the'desc' and 'title' sub-elements. This flexibility is onlypresent so that there will be a consistent content model for containerelements, because some container elements in SVG allow for mixed content, andbecause the mixed content rules for XML [XML-MIXED] do notpermit the desired restrictions. Representations of future versions of the SVGlanguage might use more expressive representations than DTDs which allow formore restrictive mixed content rules. It is strongly recommended that at mostone'desc' and at most one 'title' element appear as a child of any particularelement, and that these elements appear before any other child elements (exceptpossibly'metadata' elements) or character data content.If user agents need to choose among multiple'desc' or'title' elements for processing (e.g., to decidewhich string to use for a tooltip), the user agent shall choose the first one.



5.5 'symbol' 元素  The 'symbol' element

'symbol' 元素用来定义图形的模板对象它可以通过'use' 元素实例化.    The 'symbol'element is used to define graphical template objects which can be instantiatedby a'use' element.

通过对在同一文档中多次使用的图形使用 'symbol' 元素增强了结构和语义. 结构丰富的文档也许渲染为图形, 用语音播送, 或印成盲文, 从而提升了可达性.   The useof 'symbol' elements for graphics that are usedmultiple times in the same document adds structure and semantics. Documentsthat are rich in structure may be rendered graphically, as speech, or asbraille, and thus promoteaccessibility.

一个 'symbol' 和一个 'g' 之间的主要不同是:   The key distinctions between a 'symbol' and a 'g' are:

  • 'symbol' 元素本身不被渲染. Only instances of 只有一个 'symbol' 元素的实例 (即, 通过一个 'use' 元素对一个'symbol' 的引用) 才被渲染.    A 'symbol' element itself is not rendered. Only instances of a 'symbol' element (i.e., a reference to a 'symbol' by a'use' element) are rendered.
  • 一个 'symbol' 元素有性质 viewBox preserveAspectRatio 它们允许一个 'symbol' 进行缩放以适应由引用 'use' 元素所定义的一个矩形视口.     A 'symbol' element has attributes viewBox and preserveAspectRatio which allow a 'symbol' to scale-to-fit within a rectangular viewport defined by the referencing'use' element.

与 'symbol' 元素紧密相关的是 'marker' 'pattern' 元素.   Closely related tothe 'symbol' element are the 'marker'and 'pattern'elements.
 

 
<!ENTITY % symbolExt "" >
<!ELEMENT symbol (desc|title|metadata|defs|
                   path|text|rect|circle|ellipse|line|polyline|polygon|
                   use|image|svg|g|view|switch|a|altGlyphDef|
                   script|style|symbol|marker|clipPath|mask|
                   linearGradient|radialGradient|pattern|filter|cursor|font|
                   animate|set|animateMotion|animateColor|animateTransform|
                   color-profile|font-face
                   %ceExt;%symbolExt;)* >
<!ATTLIST symbol
  %stdAttrs;
  %langSpaceAttrs;
  externalResourcesRequired %Boolean; #IMPLIED
  class %ClassList; #IMPLIED
  style %StyleSheet; #IMPLIED
  %PresentationAttributes-All;
  viewBox %ViewBoxSpec; #IMPLIED
  preserveAspectRatio %PreserveAspectRatioSpec; 'xMidYMid meet'
  %graphicsElementEvents; >

 

在别处定义的性质:  Attributes defined elsewhere:

%stdAttrs;,%langSpaceAttrs;,class,externalResourcesRequired,viewBox,preserveAspectRatio,style,%PresentationAttributes-All;,%graphicsElementEvents;.

 

'symbol' 元素决不会被直接渲染; 它们唯一的用法是可以作为被 'use' 元素所引用的元素.  'display' 属性不用于'symbol' 元素; 于是, 'symbol'元素不被直接渲染即使 'display' 属性被设置为非none的值, 并且'symbol' 元素对于引用它的元素而言仍然是可用的即使'symbol' 元素或它的任何祖先上的 'display' 属性设置为none也是如此.     'symbol'elements are never rendered directly; their only usage is as something that canbe referenced using the'use' element. The 'display' property does not apply to the 'symbol' element; thus, 'symbol'elements are not directly rendered even if the'display' property is set to a value other than none, and 'symbol'elements are available for referencing even when the'display' property on the 'symbol'element or any of its ancestors is set to none.

 

5.6 'use'元素  The 'use' element

任何 'svg', 'symbol', 'g', 图形对象或 其它'use' 潜在为可以通过一个'use' 元素在精图文档中可重用的 (即, "实例化")模板对象. 'use'元素引用另一个元素并且表明那个元素的图形内容被包含在/绘制在文档的给定点.    Any'svg','symbol', 'g', graphicselement or other 'use' is potentially atemplate object that can be re-used (i.e., "instanced") in the SVGdocument via a 'use' element. The 'use' element references another element andindicates that the graphical contents of that element is included/drawn at thatgiven point in the document.

不像 'image', 'use' 元素不能引用整个文件.   Unlike 'image', the 'use'element cannot reference entire files.

'use' 元素有可选的性质 x, y, width 和height 这些性质用于将被引用的元素的图形内容映照到当前坐标系的一个矩形区域上.    The 'use' element has optional attributes x, y, width and height which areused to map the graphical contents of the referenced element onto a rectangularregion within the current coordinate system.

一个'use' 元素的效果相当于被引用元素的内容被深度复制到一个分离的非暴露的DOM树中在此树上此 'use' 元素作为它的双亲并且所有此 'use' 元素的祖先作为它的高级祖先. 因为复制DOM树是非暴露的, 精图文档对象模型 (DOM)只包含 'use' 元素和它的性质. 精图 DOM 并不显示被引用元素的内容作为'use' 元素的孩子.     The effect of a 'use'element is as if the contents of the referenced element were deeply cloned intoa separate non-exposed DOM tree which had the 'use'element as its parent and all of the 'use'element's ancestors as its higher-level ancestors. Because the cloned DOM treeis non-exposed, the SVG Document Object Model (DOM) only contains the 'use' element and its attributes. The SVG DOM doesnot show the referenced element's contents as children of 'use' element.

对于支持用CSS进行格式化的用户代理而言 , 被引用元素到非暴露的 DOM树上的概念上的深度复制也将被引用元素和内容上从CSS层叠 [CSS2-CASCADE]中导出的任何属性值复制过来. CSS2 选择子可以用于原来的(即, 被引用的) 元素 因为它们是正式文档结构的一部分. CSS2 选择子不可以用于 (概念上) 复制 DOM 树中因为它的内容不是正式文档结构的一部分.    For user agents that supportStyling withCSS, the conceptual deep cloning of the referenced element into anon-exposed DOM tree also copies any property values resulting from the CSScascade [CSS2-CASCADE]on the referenced element and its contents. CSS2 selectors can be applied tothe original (i.e., referenced) elements because they are part of the formaldocument structure. CSS2 selectors cannot be applied to the (conceptually)cloned DOM tree because its contents are not part of the formal documentstructure.

可是属性继承起作用就像被引用的元素以原文的形式作为'use'元素一个深度复制的孩子被包含. 被引用的元素从'use'元素和'use'元素的祖先那里继承属性. 一个被引用元素的实例不从此元素原来的双亲那里继承属性.    Property inheritance, however, works as if the referenced element had beentextually included as a deeply cloned child of the 'use'element. The referenced element inherits properties from the 'use' element and the 'use'element's ancestors. An instance of a referenced element does not inheritproperties from the referenced element's original parents.

如果事件性质被指派到被引用的元素上, 那么此事件的实际目标将为在"实例树"上对应于给定被引用元素的SVGElementInstance对象.      Ifevent attributes are assigned to referenced elements, then the actual targetfor the event will be the SVGElementInstance object within the"instance tree" corresponding to the given referenced element.

  'visibility' 属性的行为遵循属性继承的这种模型. 于是, 在一个 'use' 元素上指定 'visibility:hidden' 并不保证被引用的内容不被渲染.如果 'use' 元素指定 'visibility:hidden' 并且被引用的元素指定 'visibility:hidden' 或者 'visibility:inherit', 那么这一元素将被隐藏. 可是, 如果被引用元素指定为'visibility:visible', 那么实例元素将是可见的即使 'use' 元素设置为 'visibility:hidden'.    The behavior of the 'visibility' property conforms to this model ofproperty inheritance. Thus, specifying 'visibility:hidden'on a 'use' element does not guarantee that thereferenced content will not be rendered. If the 'use'element specifies 'visibility:hidden' and theelement it references specifies 'visibility:hidden'or 'visibility:inherit', then that one elementwill be hidden. However, if the referenced element instead specifies 'visibility:visible', then that element will be visibleeven if the 'use' element specifies 'visibility:hidden'.

在被引用元素上的动画将使得实例也被动画.    Animations on a referenced element will causethe instance to also be animated.

一个 'use' 元素与此'use'元素被下列生成内容所替换后所产生的视觉效果相同:     A 'use' element has the same visual effect asif the 'use' element were replaced by thefollowing generated content:

  • 如果'use' 元素引用一个 'symbol' 元素:   If the 'use' element references a 'symbol' element:

    在生成的内容里, 'use' 将由 'g'代替, 这里除了x,y,width, height xlink:href 所有来自'use' 元素的性质都被转移到所生成的 'g' 元素上. 一个附加的变换 translate(x,y) 被追加到所生成的'g'上的transform 性质的尾部 (即, 右边)  , 这里 x 和 y 表示在'use'元素上 x y 性质的值. 所引用的 'symbol' 和它的内容被深度复制到此生成树中, 除了此 'symbol'被一个 'svg'替换外. 这一生成的 'svg' 将总是具有性质 widthheight的显式的值 . 如果在'use'元素上提供了性质width 和/或 height , 那么这些值将传给生成的 'svg'. 如果性质 width 和/或 height 不被提供, 生成的 'svg' 元素使用100%作为这些性质的值.      In the generated content, the 'use' will be replaced by'g', where all attributes from the 'use' element except for x, y, width, height and xlink:href are transferred to the generated 'g' element. An additional transformation translate(x,y) is appended to the end (i.e., right-side) of thetransform attribute on the generated 'g', where x and y represent the values of the x and y attributes on the 'use' element. The referenced 'symbol' and its contents are deep-cloned into the generated tree, with the exception that the'symbol' is replaced by an'svg'. This generated 'svg' will always have explicit values for attributes width and height. If attributes width and/or height are provided on the 'use' element, then these attributes will be transferred to the generated'svg'. If attributeswidth and/or height are not specified, the generated 'svg' element will use values of 100% for these attributes.
  • 如果'use' 元素引用一个 'svg' 元素:   If the 'use' element references an 'svg' element:

    在生成的内容里, 'use' 将由 'g'代替, 这里除了x,y,width, height xlink:href 所有来自'use' 元素的性质都被转移到所生成的 'g' 元素上. 一个附加的变换 translate(x,y) 被追加到所生成的'g'上的transform 性质的尾部 (即, 右边)  , 这里 x 和 y 表示在'use'元素上 x y 性质的值. 所引用的  'svg'  和它的内容被深度复制到此生成树中. 如果在'use'元素上提供了性质 width 和/或 height , 那么这些值将在生成树上覆盖 'svg' 上的相应性质.       In the generated content, the 'use' will be replaced by 'g', where all attributes from the 'use' element except for x, y, width, height and xlink:href are transferred to the generated 'g' element. An additional transformation translate(x,y) is appended to the end (i.e., right-side) of thetransform attribute on the generated 'g', where x and y represent the values of the x and y attributes on the 'use' element. The referenced 'svg' and its contents are deep-cloned into the generated tree. If attributeswidth and/orheight are provided on the 'use' element, then these values will override the corresponding attributes on the'svg' in the generated tree.
  • 其它情况:  Otherwise:

    在生成的内容里, 'use' 将由 'g'代替, 这里除了x,y,width, height xlink:href 所有来自'use' 元素的性质都被转移到所生成的 'g' 元素上. 一个附加的变换 translate(x,y) 被追加到所生成的'g'上的transform 性质的尾部 (即, 右边)  , 这里 x 和 y 表示在'use'元素上 x y 性质的值. 所引用的 对象 和它的内容被深度复制到此生成树中.     In the generated content, the 'use' will be replaced by'g', where all attributes from the 'use' element except for x, y, width, height and xlink:href are transferred to the generated 'g' element. An additional transformation translate(x,y) is appended to the end (i.e., right-side) of thetransform attribute on the generated 'g', where x and y represent the values of the x and y attributes on the 'use' element. The referenced object and its contents are deep-cloned into the generated tree.

对于支持用CSS进行格式化的用户代理而言 , 此生成的'g' 元素携带在'use' 元素上的根据CSS 层叠 [CSS2-CASCADE]生成的"层叠" 属性值 . 另外, 被引用资源的复制(深度复制)携带在原来 (即, 被引用)元素上的根据 CSS 层叠 生成的"层叠" 属性值. 于是, 各种CSS选择子与class style性质的组合的结果, 从其效果看, 被一个在功能上等价的在生成内容上的 style 性质所代替此性质受让了这些"层叠" 属性值.     For user agents that support Styling withCSS, the generated 'g' element carries along with it the"cascaded" property values on the 'use'element which result from the CSS cascade [CSS2-CASCADE].Additionally, the copy (deep clone) of the referenced resource carries alongwith it the "cascaded" property values resulting from the CSS cascadeon the original (i.e., referenced) elements. Thus, the result of various CSSselectors in combination with theclass and style attributes are, in effect, replaced by thefunctional equivalent of a style attribute in the generated content whichconveys the "cascaded" property values.

下面的例子 Use01 在一个 'rect'上有一个简单的'use'.    Example Use01 below has asimple 'use' on a 'rect'.

 
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="10cm" height="3cm" viewBox="0 0 100 30"
     xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <desc>Example Use01 - Simple case of 'use' on a 'rect'</desc>
  <defs>
    <rect id="MyRect" width="60" height="10"/>
  </defs>
  <rect x=".1" y=".1" width="99.8" height="29.8"
        fill="none" stroke="blue" stroke-width=".2" />
  <use x="20" y="10" xlink:href="#MyRect" />
</svg>

Example Use01

View this exampleas SVG (SVG-enabled browsers only)
 

其视觉效果等价于下列文档:    The visual effect would be equivalent to the following document:

 
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="10cm" height="3cm" viewBox="0 0 100 30"
     xmlns="http://www.w3.org/2000/svg">
  <desc>Example Use01-GeneratedContent - Simple case of 'use' on a 'rect'</desc>
  <!-- 'defs' section left out -->
 
  <rect x=".1" y=".1" width="99.8" height="29.8"
        fill="none" stroke="blue" stroke-width=".2" />
 
  <!-- Start of generated content. Replaces 'use' -->
  <g transform="translate(20,10)">
    <rect width="60" height="10"/>
  </g>
  <!-- End of generated content -->
 
</svg>

Viewthis example as SVG (SVG-enabled browsers only)
 

下面的例子 Use02 在一个 'symbol'上有一个'use'.   Example Use02 below has a 'use' on a 'symbol'.

 
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="10cm" height="3cm" viewBox="0 0 100 30"
     xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <desc>Example Use02 - 'use' on a 'symbol'</desc>
  <defs>
    <symbol id="MySymbol" viewBox="0 0 20 20">
      <desc>MySymbol - four rectangles in a grid</desc>
      <rect x="1" y="1" width="8" height="8"/>
      <rect x="11" y="1" width="8" height="8"/>
      <rect x="1" y="11" width="8" height="8"/>
      <rect x="11" y="11" width="8" height="8"/>
    </symbol>
  </defs>
  <rect x=".1" y=".1" width="99.8" height="29.8"
        fill="none" stroke="blue" stroke-width=".2" />
  <use x="45" y="10" width="10" height="10" 
       xlink:href="#MySymbol" />
</svg>

Example Use02

View this exampleas SVG (SVG-enabled browsers only)
 

其视觉效果等价于下列文档:   The visual effect would be equivalent to the following document:

 
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="10cm" height="3cm" viewBox="0 0 100 30"
     xmlns="http://www.w3.org/2000/svg">
  <desc>Example Use02-GeneratedContent - 'use' on a 'symbol'</desc>
 
  <!-- 'defs' section left out -->
 
  <rect x=".1" y=".1" width="99.8" height="29.8"
        fill="none" stroke="blue" stroke-width=".2" />
 
  <!-- Start of generated content. Replaces 'use' -->
  <g transform="translate(45, 10)" >
    <!-- Start of referenced 'symbol'. 'symbol' replaced by 'svg',
         with x,y,width,height=0,0,100%,100% -->
    <svg width="10" height="10" 
         viewBox="0 0 20 20">
      <rect x="1" y="1" width="8" height="8"/>
      <rect x="11" y="1" width="8" height="8"/>
      <rect x="1" y="11" width="8" height="8"/>
      <rect x="11" y="11" width="8" height="8"/>
    </svg>
    <!-- End of referenced symbol -->
  </g>
  <!-- End of generated content -->
 
</svg>

Viewthis example as SVG (SVG-enabled browsers only)
 

下面的例子Use03 解释当一个 'use' 有 transform性质将会发生什么.  Example Use03 illustrateswhat happens when a 'use' has a transform attribute.

 
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="10cm" height="3cm" viewBox="0 0 100 30"
     xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <desc>Example Use03 - 'use' with a 'transform' attribute</desc>
  <defs>
    <rect id="MyRect" x="0" y="0" width="60" height="10"/>
  </defs>
  <rect x=".1" y=".1" width="99.8" height="29.8"
        fill="none" stroke="blue" stroke-width=".2" />
  <use xlink:href="#MyRect"
       transform="translate(20,2.5) rotate(10)" />
</svg>

Example Use03

View this exampleas SVG (SVG-enabled browsers only)
 

其视觉效果等价于下列文档:   The visual effect would be equivalent to the following document:

 
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="10cm" height="3cm" viewBox="0 0 100 30"
     xmlns="http://www.w3.org/2000/svg">
  <desc>Example Use03-GeneratedContent - 'use' with a 'transform' attribute</desc>
 
  <!-- 'defs' section left out -->
 
  <rect x=".1" y=".1" width="99.8" height="29.8"
        fill="none" stroke="blue" stroke-width=".2" />
 
  <!-- Start of generated content. Replaces 'use' -->
  <g transform="translate(20,2.5) rotate(10)">
    <rect x="0" y="0" width="60" height="10"/>
  </g>
  <!-- End of generated content -->
 
</svg>

Viewthis example as SVG (SVG-enabled browsers only)
 

下面的例子Use04 解释一个使用各种CSS格式化方法的 'use' 元素.     Example Use04 illustrates a 'use'element with various methods of applying CSS styling.

 
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="12cm" height="3cm" viewBox="0 0 1200 300"
     xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <desc>Example Use04 - 'use' with CSS styling</desc>
  <defs style=" /* rule 9 */ stroke-miterlimit: 10" >
    <path id="MyPath" d="M300 50 L900 50 L900 250 L300 250"
                     class="MyPathClass"
                     style=" /* rule 10 */ stroke-dasharray:300,100" />
  </defs>
  <style type="text/css">
    <![CDATA[
      /* rule 1 */ #MyUse { fill: blue }
      /* rule 2 */ #MyPath { stroke: red }
      /* rule 3 */ use { fill-opacity: .5 }
      /* rule 4 */ path { stroke-opacity: .5 }
      /* rule 5 */ .MyUseClass { stroke-linecap: round }
      /* rule 6 */ .MyPathClass { stroke-linejoin: bevel }
      /* rule 7 */ use > path { shape-rendering: optimizeQuality }
      /* rule 8 */ g > path { visibility: hidden }
    ]]>
  </style>
 
  <rect x="0" y="0" width="1200" height="300"
         style="fill:none; stroke:blue; stroke-width:3"/>
  <g style=" /* rule 11 */ stroke-width:40">
    <use id="MyUse" xlink:href="#MyPath" 
         class="MyUseClass"
         style="/* rule 12 */ stroke-dashoffset:50" />
  </g>
</svg>

Example Use04

View this exampleas SVG (SVG-enabled browsers only)
 

其视觉效果等价于下列文档. 观察上面用于生成内容的某些样式表规则 (即, 规则 1-6, 10-12), 而其它的则不作用于 (即, 规则 7-9). 不影响生成内容的规则是:    Thevisual effect would be equivalent to the following document. Observe that someof the style rules above apply to the generated content (i.e., rules 1-6,10-12), whereas others do not (i.e., rules 7-9). The rules which do not affectthe generated content are:

  • 规则 7 和 8: CSS 选择子只能用于正式的文档树, 不能用于生成树; 于是, 这些选择子不会产生匹配.     Rules 7 and 8: CSS selectors only apply to the formal document tree, not on the generated tree; thus, these selectors will not yield a match.
  • 规则 9: 生成树只能继承 'use' 元素的祖先的属性不能从被引用元素的祖先上继承; 于是, 这一规则不会影响生成内容.     The generated tree only inherits from the ancestors of the 'use' element and does not inherit from the ancestors of the referenced element; thus, this rule does not affect the generated content.

在下面生成的内容里, 为了方便解释能产生一个匹配的选择子被转换成一个内联的 'style' 性质.  In the generated contentbelow, the selectors that yield a match have been transferred into inline 'style'attributes for illustrative purposes.

 
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="12cm" height="3cm" viewBox="0 0 1200 300"
     xmlns="http://www.w3.org/2000/svg">
  <desc>Example Use04-GeneratedContent - 'use' with a 'transform' attribute</desc>
 
  <!-- 'style' and 'defs' sections left out -->
 
  <rect x="0" y="0" width="1200" height="300"
         style="fill:none; stroke:blue; stroke-width:3"/>
  <g style="/* rule 11 */ stroke-width:40">
 
    <!-- Start of generated content. Replaces 'use' -->
    <g style="/* rule 1 */ fill:blue;
                 /* rule 3 */ fill-opacity:.5;
                 /* rule 5 */ stroke-linecap:round;
                 /* rule 12 */ stroke-dashoffset:50" >
      <path d="M300 50 L900 50 L900 250 L300 250"
            style="/* rule 2 */ stroke:red; 
                   /* rule 4 */ stroke-opacity:.5; 
                   /* rule 6 */ stroke-linejoin: bevel; 
                   /* rule 10 */ stroke-dasharray:300,100" />
    </g> 
    <!-- End of generated content -->
 
  </g>
</svg>

Viewthis example as SVG (SVG-enabled browsers only)
 

当一个 'use' 引用另一个元素此元素为另一个  'use' 或者其内容包含一个 'use' 元素, 那么上述深度复制方法是递归的.   When a 'use' references another element whichis another 'use' or whose content contains a 'use' element, then the deep cloning approachdescribed above is recursive.


 

 
<!ENTITY % useExt "" >
<!ELEMENT use (%descTitleMetadata;,(animate|set|animateMotion|animateColor|animateTransform
                   %geExt;%useExt;)*) >
<!ATTLIST use
  %stdAttrs;
  %xlinkRefAttrsEmbed;
  xlink:href %URI; #REQUIRED
  %testAttrs;
  %langSpaceAttrs;
  externalResourcesRequired %Boolean; #IMPLIED
  class %ClassList; #IMPLIED
  style %StyleSheet; #IMPLIED
  %PresentationAttributes-All;
  transform %TransformList; #IMPLIED
  %graphicsElementEvents;
  x %Coordinate; #IMPLIED
  y %Coordinate; #IMPLIED
  width %Length; #IMPLIED
  height %Length; #IMPLIED >

性质定义:  Attributedefinitions:

x = "<coordinate>"

安置被引用元素的矩形区域的一个角的 x-轴坐标.     The x-axis coordinate of one corner of the rectangular region into which thereferenced element is placed.
如果不指定此性质, 其效果相当于指定此性质的值为"0".     Ifthe attribute is not specified, the effect is as if a value of "0"were specified.
Animatable:yes.

y = "<coordinate>"

安置被引用元素的矩形区域的一个角的 y-轴坐标.     The y-axis coordinate of one corner of the rectangular region into which thereferenced element is placed.
如果不指定此性质, 其效果相当于指定此性质的值为"0".     Ifthe attribute is not specified, the effect is as if a value of "0"were specified.
Animatable:yes.

width = "<length>"

安置被引用元素的矩形区域的宽度.    The width of the rectangular region into whichthe referenced element is placed.
Animatable:yes.

height = "<length>"

安置被引用元素的矩形区域的高度.    The height of the rectangular region into whichthe referenced element is placed.
Animatable:yes.

xlink:href = "<uri>"

指向在精图文档内的一个元素或片段的一个URI 引用.   AURIreference to an element/fragment within an SVG document.
Animatable:yes.

 

在别处定义的性质:  Attributesdefined elsewhere:

%stdAttrs;,%xlinkRefAttrsEmbed;,%testAttrs;,%langSpaceAttrs;,externalResourcesRequired,class,style,%PresentationAttributes-All;,transform,%graphicsElementEvents;.



5.7 'image'元素 The 'image'element

'image' 元素表示一个完整文件的内容被渲染到一个在当前用户坐标系下的给定的矩形内. 'image' 元素可以引用光栅图像文件比如 PNG 或JPEG 或者MIME类型为"image/svg+xml"的文件 .兼容精图浏览器至少需要支持 PNG,JPEG 和精图格式文件.   The 'image' element indicates that the contentsof a complete file are to be rendered into a given rectangle within the currentuser coordinate system. The 'image' element canrefer to raster image files such as PNG or JPEG or to files with MIME type of"image/svg+xml". ConformingSVG viewers need to support at least PNG, JPEG and SVG format files.

处理一个'image'的结果总是一个四通道RGBA的结果. 当一个 'image' 元素引用一个光栅图像文件比如PNG 或JPEG文件而这种文件只有三个通道 (RGB), 那么效果为此对象被转换成4-通道 RGBA 图像其alpha 通道统统设为 1. 对于但通道的光栅图像, 其效果为此对象被转换成4-通道 RGBA 图像, 而被引用对象的单个通道用于计算三个颜色通道而alpha 通道统统设为1.       The result of processing an 'image' is always a four-channel RGBA result. When an'image' element references a raster image filesuch as PNG or JPEG files which only has three channels (RGB), then the effectis as if the object were converted into a 4-channel RGBA image with the alphachannel uniformly set to 1. For a single-channel raster image, the effect is asif the object were converted into a 4-channel RGBA image, where the singlechannel from the referenced object is used to compute the three color channelsand the alpha channel is uniformly set to 1.

当一个 'image' 元素引用一个光栅图像文件比如 PNG 或JPEG文件, 那么此光栅图像适合于由x,y,width height性质指定的区域. 性质 preserveAspectRatio 确定光栅图像尺寸和纵横比当适合于由x,y,width height性质指定的区域时. 例如, 如果 preserveAspectRatio="xMinYMinmeet", 那么光栅图像的纵横比被保留 (这就意味着从光栅图像的坐标到当前用户空间的坐标的比例因子与对于X和 Y是相同的), 光栅图像改变尺寸变得尽可能大以便保证整个光栅图像适合安置在视口内, 并且光栅图像的左上角与视口的左上角对齐. 如果 preserveAspectRatio="none", 那么光栅图像的纵横比不被保留.图像将被安置使得光栅图像的左上角严格与坐标 (x,y)对齐并且光栅图像的右下角 严格与坐标 (x+width,y+height)对齐.            When an 'image' element references a rasterimage file such as PNG or JPEG files, then the raster image is fitted into theregion specified by thex,y, width and height attribute. Attribute preserveAspectRatio determines both the size andaspect ratio of the raster when fitted into the region specified byx,y, width and height. For example, if preserveAspectRatio="xMinYMinmeet", then the aspect ratio of the raster would be preserved(which means that the scale factor from image's coordinates to current userspace coordinates would be the same for both X and Y), the raster would besized as large as possible while ensuring that the entire raster fits withinthe viewport, and the top/left of the raster would be aligned with the top/leftof the viewport. If preserveAspectRatio="none",then the aspect ratio of the raster would not be preserved. The image would befitted such that the top/left corner of the raster exactly aligns withcoordinate (x,y) and the bottom/right corner of the raster exactlyaligns with coordinate (x+width,y+height).

当一个 'image' 元素引用一个精图文件时, 那么此'image' 元素按照建立一个新的视口中所描述的为此精图文件建立一个新的视口. 新视口的边界由x,y, width height性质来定义. 除了由于处理xy 性质可能出现的隐式坐标系平移 (参见 建立一个新的视口)外, 'image'元素本身不产生任何坐标系变换.于是, 被引用的精图文件的初始坐标系与新视口的坐标系一致. 如果需要对精图文件进行缩放以便适合由 'image' 元素所建立的视口, 那么在被引用的精图文件上最外层的'svg' 元素必须包含一个viewBox性质或者引用的文件需要包含适当的变换 , 也许在'image' 元素或者它的祖先之一上包含一个适当的transform 性质或者安置此 'image' 元素在一个包含一个适当的 viewBox性质的'svg' 元素内.           Whenan 'image' element references an SVG file, thenthe 'image' element establishes a new viewportfor the SVG file as described in Establishinga new viewport. The bounds for the new viewport are defined by attributesx,y, width and height. Except for the implicit coordinate systemtranslation that may occur due to the processing of thex andy attributes (see establishinga new viewport), the 'image' element itselfdoes not cause any coordinate system transformations. Thus, the initialcoordinate system for the referenced SVG file will be identical to thecoordinate system for the new viewport. If it is necessary for the referencedSVG file to be scaled to fit into the viewport established by the 'image' element, then that outermost'svg' element on the referenced SVG file willneed to have a viewBox attribute or the referencing file will needto include appropriate transformations, perhaps by including an appropriatetransform attribute on the 'image'element or one of its ancestors or by placing the 'image'element within an'svg' element which has an appropriate viewBox attribute.

被'image'元素引用的资源表示一个分离的文档此文档生成自己的分析树和文档对象模型(如果此资源为XML文档). 于是, 此图像不存在属性的继承.   The resource referenced by the 'image' elementrepresents a separate document which generates its own parse tree and documentobject model (if the resource is XML). Thus, there is no inheritance ofproperties into the image.

不像 'use', 'image' 元素不能引用精图文件内的元素.    Unlike 'use', the 'image'element cannot reference elements within an SVG file.
 

 
<!ENTITY % imageExt "" >
<!ELEMENT image (%descTitleMetadata;,(animate|set|animateMotion|animateColor|animateTransform
                   %geExt;%imageExt;)*) >
<!ATTLIST image
  %stdAttrs;
  %xlinkRefAttrsEmbed;
  xlink:href %URI; #REQUIRED
  %testAttrs;
  %langSpaceAttrs;
  externalResourcesRequired %Boolean; #IMPLIED
  class %ClassList; #IMPLIED
  style %StyleSheet; #IMPLIED
  %PresentationAttributes-Color;
  %PresentationAttributes-Graphics;
  %PresentationAttributes-Images;
  %PresentationAttributes-Viewports;
  transform %TransformList; #IMPLIED
  preserveAspectRatio %PreserveAspectRatioSpec; 'xMidYMid meet'
  %graphicsElementEvents;
  x %Coordinate; #IMPLIED
  y %Coordinate; #IMPLIED
  width %Length; #REQUIRED
  height %Length; #REQUIRED >

性质定义:  Attributedefinitions:

x = "<coordinate>"

安置被引用文档的矩形区域的一个角的 x-轴坐标.     The x-axis coordinate of one corner of the rectangular region into which thereferenced document is placed.
如果不指定此性质, 其效果相当于指定此性质的值为"0".    Ifthe attribute is not specified, the effect is as if a value of "0"were specified.
Animatable:yes.

y = "<coordinate>"

安置被引用文档的矩形区域的一个角的 y-轴坐标.     The y-axis coordinate of one corner of the rectangular region into which thereferenced document is placed.
如果不指定此性质, 其效果相当于指定此性质的值为"0".    Ifthe attribute is not specified, the effect is as if a value of "0"were specified.
Animatable:yes.

width = "<length>"

安置被引用文档的矩形区域的宽度.    The width of the rectangular region into whichthe referenced document is placed.
负值是一种错误 (参见 错误处理).值为零则不渲染此元素.   Anegative value is an error (see Errorprocessing). A value of zero disables rendering of the element.
Animatable:yes.

height = "<length>"

安置被引用文档的矩形区域的高度.    The height of the rectangular region into whichthe referenced document is placed.
负值是一种错误 (参见 错误处理).值为零则不渲染此元素.   Anegative value is an error (see Errorprocessing). A value of zero disables rendering of the element.
Animatable:yes.

xlink:href = "<uri>"

一个URI 引用.  AURIreference.
Animatable:yes.

 

在别处定义的性质:  Attributesdefined elsewhere:

%stdAttrs;,%xlinkRefAttrsEmbed;,%testAttrs;,%langSpaceAttrs;,externalResourcesRequired,class,style,%PresentationAttributes-Color;,%PresentationAttributes-Graphics;,%PresentationAttributes-Images;,%PresentationAttributes-Viewports;,transform,preserveAspectRatio,%graphicsElementEvents;.

一个例子:  An example:

 
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="4in" height="3in"
     xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <desc>This graphic links to an external image
  </desc>
  <image x="200" y="200" width="100px" height="100px"
         xlink:href="myimage.png">
    <title>My image</title>
  </image>
</svg>



5.8 条件处理   Conditional processing



5.8.1 条件处理概览 Conditional processing overview

精图包含一个 'switch' 元素连同性质 requiredFeatures, requiredExtensionssystemLanguage 提供一种指定可互换视图的能力可互换视图依赖于给定用户代理或用户语言的能力.      SVG contains a'switch' element along with attributes requiredFeatures, requiredExtensions and systemLanguage to provide an ability to specifyalternate viewing depending on the capabilities of a given user agent or theuser's language.

 
<!ENTITY % testAttrs
 "requiredFeatures %FeatureList; #IMPLIED
  requiredExtensions %ExtensionList; #IMPLIED
  systemLanguage %LanguageCodes; #IMPLIED" >

性质 requiredFeatures, requiredExtensionssystemLanguage 担当测试并返回要么真要么假的结果. 'switch' 渲染这些性质测试都为真的第一个孩子. 如果给定的性质未被指定, 那么假设此性质的值为真.    Attributes requiredFeatures, requiredExtensions and systemLanguage act as tests and return either trueor false results. The 'switch' renders the first of its children forwhich all of these attributes test true. If the given attribute is notspecified, then a true value is assumed.



5.8.2 'switch'元素  The 'switch' element

'switch' 元素按顺序求它的直系孩子的requiredFeatures,requiredExtensionssystemLanguage性质的值, 并且处理和渲染第一个这些性质的值都为真的孩子. 所有其它的孩子将被回避因此不被渲染. 如果子元素为容器元素比如 一个'g', 那么整个子树要么被处理/被渲染 要么被回避/不被渲染.         The 'switch' element evaluates the requiredFeatures, requiredExtensions and systemLanguage attributes on its direct childelements in order, and then processes and renders the first child for whichthese attributes evaluate to true. All others will be bypassed and thereforenot rendered. If the child element is a container element such as a 'g', then the entire subtree is eitherprocessed/rendered or bypassed/not rendered.

注意属性 'display''visibility'的值在'switch'元素处理上不起作用. 特别, 在一个 'switch' 元素的孩子上设置'display' 为none 对与'switch'元素处理相关的真/假测试不起作用.       Note that the values of properties 'display' and 'visibility' have no effect on 'switch' element processing. In particular,setting 'display' to none on achild of a 'switch' element has no effect on true/falsetesting associated with 'switch' element processing.


 

 
<!ENTITY % switchExt "" >
<!ELEMENT switch (%descTitleMetadata;,
                  (path|text|rect|circle|ellipse|line|polyline|polygon|
                   use|image|svg|g|switch|a|foreignObject|
                   animate|set|animateMotion|animateColor|animateTransform
                   %ceExt;%switchExt;)*) >
<!ATTLIST switch
  %stdAttrs;
  %testAttrs;
  %langSpaceAttrs;
  externalResourcesRequired %Boolean; #IMPLIED
  class %ClassList; #IMPLIED
  style %StyleSheet; #IMPLIED
  %PresentationAttributes-All;
  transform %TransformList; #IMPLIED
  %graphicsElementEvents; >

 

在别处定义的性质:  Attributesdefined elsewhere:

%stdAttrs;,%langSpaceAttrs;,class,transform,%graphicsElementEvents;,%testAttrs;,externalResourcesRequired,style,%PresentationAttributes-All;.

关于更多的信息和一个例子, 参见 嵌入外部对象类型.    For more information and an example, see Embeddingforeign object types.

5.8.3 requiredFeatures性质 The requiredFeaturesattribute

  requiredFeatures的定义:  Definition of requiredFeatures:

requiredFeatures = list-of-features

值为特征字符串列表, 单个值之间用空白符分隔. 确定是否所有命名的特征被用户代理所支持. 只有此节中定义的特征字符串(参见下面) 被允许. 如果给定的所有特征被支持, 那么此性质的值为真; 否则, 当前元素和它的孩子被跳过并且不被渲染.     The value is a list of feature strings,with the individual values separated by white space. Determines whether all ofthe namedfeatures are supported by the user agent. Only featurestrings defined in this section (see below) are allowed. If all of the givenfeatures are supported, then the attribute evaluates to true; otherwise, thecurrent element and its children are skipped and thus will not be rendered.
Animatable:no.

所有涉及语言能力的特征字符串开始部分为 "org.w3c.svg". 所有涉及精图文档对象模型能力的特征字符串开始部分为"org.w3c.dom.svg".      All feature strings referring tolanguage capabilities begin with"org.w3c.svg". All feature strings referringtoSVG DOM capabilitiesbegin with "org.w3c.dom.svg".

下列为用于requiredFeatures性质的特征字符串. 这些特征字符串同样用于 hasFeature 方法调用 它为精图文档对象模型支持 定义在 [DOM2-CORE] 的DOMImplementation 接口 的一部分(参见 关于 hasFeature 方法调用的特征字符串).   The following are the feature strings for the requiredFeaturesattribute. These same feature strings apply to the hasFeaturemethod call that is part of theSVGDOM's support for the DOMImplementationinterface defined in [DOM2-CORE](seeFeaturestrings for the hasFeature method call).

  • 特征字符串 "org.w3c.svg" 表示用户代理支持至少下列之一 (它们随后描述): "org.w3c.svg.static","org.w3c.svg.animation","org.w3c.svg.dynamic""org.w3c.dom.svg". (因为在某些情形下特征字符串"org.w3c.svg" 变得模棱两可, 建议使用更具体的特征字符串.)      The feature string"org.w3c.svg" indicates that the user agent supports at least one of the following (all of which are described subsequently):"org.w3c.svg.static","org.w3c.svg.animation", "org.w3c.svg.dynamic" or"org.w3c.dom.svg". (Because the feature string"org.w3c.svg" can be ambiguous in some circumstances, it is recommended that more specific feature strings be used.)
  • 特征字符串  "org.w3c.dom.svg" 表示用户代理支持至少下列之一 (它们随后描述): "org.w3c.dom.svg.static","org.w3c.dom.svg.animation""org.w3c.dom.svg.dynamic". (因为在某些情形下特征字符串"org.w3c.dom.svg" 变得模棱两可, 建议使用更具体的特征字符串.)         The feature string"org.w3c.dom.svg" indicates that the user agent supports at least one of the following (all of which are described subsequently):"org.w3c.dom.svg.static", "org.w3c.dom.svg.animation" or"org.w3c.dom.svg.dynamic". (Because the feature string"org.w3c.dom.svg" can be ambiguous in some circumstances, it is recommended that more specific feature strings be used.)
  • 特征字符串"org.w3c.svg.static" 表示在下面定义的所有语言能力都可用:     The feature string"org.w3c.svg.static" indicates the availability of all of the language capabilities defined in:

对于精图浏览器, "org.w3c.svg.static" 表示浏览器能够成功处理和渲染上面所列的语言特征.     For SVG viewers,"org.w3c.svg.static"indicates that the viewer can process and render successfully all of thelanguage features listed above.

  • The feature string "org.w3c.dom.svg.static" indicates the availability of all of the DOM interfaces and methods that correspond to the language features for"org.w3c.svg.static".
  • The feature string "org.w3c.svg.animation" includes all of the language capabilities defined for"org.w3c.svg.static" plus the availability of all of the language capabilities defined inAnimation. For SVG viewers running on media capable of rendering time-based material, such as displays,"org.w3c.svg.animation" indicates that the viewer can process and render successfully all of the corresponding language features.
  • The feature string "org.w3c.dom.svg.animation" corresponds to the availability of DOM interfaces and methods that correspond to the language features for"org.w3c.svg.animation".
  • The feature string "org.w3c.svg.dynamic" includes all of the language capabilities defined for"org.w3c.svg.animation" plus the availability of all of the language capabilities defined inRelationship with DOM2 events, Linking and Interactivity and Scripting. For SVG viewers running on media capable of rendering time-based material, such as displays,"org.w3c.svg.dynamic" indicates that the viewer can process and render successfully all of the corresponding language features.
  • The feature string "org.w3c.dom.svg.dynamic" corresponds to the availability of DOM interfaces and methods that correspond to the language features for"org.w3c.svg.dynamic".
  • The feature string "org.w3c.svg.all" corresponds to the availability of all of the language capabilities defined in this specification.
  • The feature string "org.w3c.dom.svg.all" corresponds to the availability of all of the DOM interfaces defined in this specification.

如果不出现此性质, 那么它的隐含返回值为"true". 如果性质requiredFeatures的值为空串 , 则此性质返回"false".     If the attribute is not present,then its implicit return value is "true". If a null string or emptystring value is given to attribute requiredFeatures,the attribute returns "false".

requiredFeatures 常常用于与 'switch' 元素进行协作. 如果 requiredFeatures 用于其它场合, 那么表示在给定元素上一种简单开关对元素是否进行渲染.      requiredFeatures is often used in conjunction withthe'switch' element. If the requiredFeaturesis used in other situations, then it represents a simple switch on the givenelement whether to render the element or not.

5.8.4 requiredExtensions性质   The requiredExtensions attribute

requiredExtensions 性质定义需要的语言扩展的列表.语言扩展是一个用户代理超出本规范所定义的特征集之外的能力. 每个扩展通过一个URI 引用来指定 .    The requiredExtensions attribute defines a list of requiredlanguage extensions. Language extensions are capabilities within a user agentthat go beyond the feature set defined in this specification. Each extension isidentified by aURIreference.

requiredExtensions的定义:  Definition of requiredExtensions:

requiredExtensions = list-of-extensions

值为URI引用 的列表它们指定所要求的扩展, 单个值用空白符隔开. 确定是否所有 命名的扩展 被用户代理所支持. 如果所有给定的扩展被支持, 那么此性质的求值为真; 否则, 当前元素以及它的孩子被跳过从而不被渲染.     The value is a list ofURI referenceswhich identify the required extensions, with the individual values separated bywhite space. Determines whether all of the namedextensions aresupported by the user agent. If all of the given extensions are supported, thenthe attribute evaluates to true; otherwise, the current element and itschildren are skipped and thus will not be rendered.
Animatable:no.

如果一个给定的 URI 引用 本身包含空白符, 则此空白符必须被转义.    If agiven URIreference contains white space within itself, that white space must beescaped.

如果不出现此性质, 那么它的隐含返回值为"true". 如果性质requiredExtensions的值为空串 , 则此性质返回"false".     If the attribute is not present,then its implicit return value is "true". If a null string or emptystring value is given to attribute requiredExtensions,the attribute returns "false".

requiredExtensions 常常用于与 'switch' 元素进行协作. 如果 requiredExtensions 用于其它场合, 那么表示在给定元素上一种简单开关对元素是否进行渲染.      requiredExtensions is often used in conjunctionwith the'switch' element. If the requiredExtensionsis used in other situations, then it represents a simple switch on the givenelement whether to render the element or not.

关于扩展的URI 名字应包含版本信息 , 比如"http://example.org/SVGExtensionXYZ/1.0", 使得脚本作者能够区分给定扩展不同版本.     The URI names for the extension should include versioning information, such as"http://example.org/SVGExtensionXYZ/1.0", so that script writers candistinguish between different versions of a given extension.



5.8.5 systemLanguage性质  The systemLanguageattribute

性质值是用逗号分隔的在[RFC3066]中定义的语言名的列表 .   Theattribute value is a comma-separated list of language names as defined in [RFC3066].

求值为"true"if one of the languages indicated by user preferences exactly equals one of thelanguages given in the value of this parameter, or if one of the languagesindicated by user preferences exactly equals a prefix of one of the languagesgiven in the value of this parameter such that the first tag characterfollowing the prefix is "-".    Evaluates to"true" if one of the languages indicated by user preferences exactlyequals one of the languages given in the value of this parameter, or if one ofthe languages indicated by user preferences exactly equals a prefix of one ofthe languages given in the value of this parameter such that the first tagcharacter following the prefix is "-".

否则求值为"false".  Evaluates to "false" otherwise.

Note: This use of a prefix matching rule does not implythat language tags are assigned to languages in such a way that it is alwaystrue that if a user understands a language with a certain tag, then this userwill also understand all languages with tags for which this tag is a prefix.

The prefix rule simply allows the use of prefix tags ifthis is the case.

Implementation note: When making the choice of linguisticpreference available to the user, implementers should take into account thefact that users are not familiar with the details of language matching asdescribed above, and should provide appropriate guidance. As an example, usersmay assume that on selecting "en-gb", they will be served any kind ofEnglish document if British English is not available. The user interface for settinguser preferences should guide the user to add "en" to get the bestmatching behavior.

Multiple languages MAY be listed for content that isintended for multiple audiences. For example, content that is presentedsimultaneously in the original Maori and English versions, would call for:

<text systemLanguage="mi,en"><!-- content goes here --></text>

However, just because multiple languages are present withinthe object on which thesystemLanguage test attribute isplaced, this does not mean that it is intended for multiple linguisticaudiences. An example would be a beginner's language primer, such as "AFirst Lesson in Latin," which is clearly intended to be used by anEnglish-literate audience. In this case, thesystemLanguagetest attribute should only include "en".

Authoring note: Authors should realize that if severalalternative language objects are enclosed in a'switch', and none of them matches, this may leadto situations where no content is displayed. It is thus recommended to includea "catch-all" choice at the end of such a'switch' which is acceptable in all cases.

For the systemLanguageattribute: Animatable:no.

如果不出现此性质, 那么它的隐含返回值为 "true". 如果性质systemLanguage的值为空串 , 则此性质返回"false".     If the attribute is not present,then its implicit return value is "true". If a null string or emptystring value is given to attribute systemLanguage,the attribute returns "false".

systemLanguage 常常用于与 'switch' 元素进行协作. 如果 systemLanguage 用于其它场合, 那么表示在给定元素上一种简单开关对元素是否进行渲染.      systemLanguage is often used in conjunction withthe'switch' element. If the systemLanguageis used in other situations, then it represents a simple switch on the givenelement whether to render the element or not.



5.9 指定正确的渲染是否需要外部资源 Specifying whether external resources are required for properrendering

文档常常引用和使用其它文件的内容 (和环球网资源) 作为其渲染的一部分. 在某些情况下, 作者需要指定对一个被认为是正确的文档而言是否需要特殊的资源.     Documents often reference and use the contents of other files (and other Webresources) as part of their rendering. In some cases, authors want to specifythat particular resources are required for a document to be considered correct.

性质externalResourcesRequired isavailable 在所有容器元素和所有潜在能够引用外部资源的元素上是可用的. 它指定是否引用不为当前文档的一部分的资源此资源对于给定容器元素或图形元素思维适当渲染是必须的.      Attribute externalResourcesRequiredis available on all container elements and to all elements which potentiallycan reference external resources. It specifies whether referenced resourcesthat are not part of the current document are required for proper rendering ofthe given container element or graphics element.

性质定义:Attribute definition:

externalResourcesRequired = "false | true"

false

(缺省值.) 表示外部的资源对于当前文档是可选的. 即使对于当前元素和它的后裔外部资源不可用文档的渲染可以照常进行处理.      (The default value.) Indicates thatresources external to the current document are optional. Document rendering canproceed even if external resources are unavailable to the current element andits descendants.

true

表示外部资源对于当前文档是必需的. 如果一个外部资源不可用, 正在进行的渲染被暂停直到此资源和其它要用的资源变得可用为止, 已经被分析准备被渲染. 如果在要求一个外部资源时超时事件出现, 那么文档进入一种错误状态 (参见错误处理).The document remains in an error state until all required resources becomeavailable.      Indicates that resources external tothe current document are required. If an external resource is not available,progressive rendering is suspended until that resource and all other requiredresources become available, have been parsed and are ready to be rendered. If atimeout event occurs on a required resource, then the document goes into anerror state (seeErrorprocessing). The document remains in an error state until all requiredresources become available.

这一性质用于所有类型的资源引用, 包括样式表, 颜色配置表 (参见 颜色配置描述)和用在一个'font-face'元素或者一个CSS @font-face的URI引用 所指定的字体. 特别, 如果一个元素上设置externalResourcesRequired="true", 那么所有样式表必须是可用的因为任何样式表也许影响此元素的渲染.     This attribute applies to all types ofresource references, including style sheets, color profiles (seeColorprofile descriptions) and fonts specified by a URI referenceusing a 'font-face' element or a CSS @font-facespecification. In particular, if an element sets externalResourcesRequired="true",then all style sheets must be available since any style sheet might affect therendering of that element.

性质 externalResourcesRequired 不可继承 (从性质值继承的意义上), 但是如果设置在容器元素上, 它的值可以用于容器里的所有元素.   Attribute externalResourcesRequired is notinheritable (from a sense of attribute value inheritance), but if set on acontainer element, its value will apply to all elements within the container.

因为在容器元素上设置 externalResourcesRequired="true"  也许使容器的内容的不能逐渐进行显示, 生成精图内容的工具警告在全局基础在最外层的'svg' 元素上简单设置externalResourcesRequired="true" . 代之以较好的方式, 在特定的图形元素或容器元素上指定 externalResourcesRequired="true"  这些元素为了正确渲染需要外部资源可用.        Because setting externalResourcesRequired="true" on acontainer element can have the effect of disabling progressive display of thecontents of that container, tools that generate SVG content are cautionedagainst using simply setting externalResourcesRequired="true"on the outermost'svg' element on a universal basis. Instead, itis better to specify externalResourcesRequired="true"on those particular graphics elements or container elements which specify needthe availability of external resources in order to render properly.

For externalResourcesRequired:Animatable:no.



5.10 公共性质 Common attributes



5.10.1 对于所有元素是公共的性质: id 和 xml:base  Attributescommon to all elements: id and xml:base

id 和 xml:base 性质在所有精图元素上都是可用的:    The id and xml:base attributes are available on all SVG elements:

 
<!ENTITY % stdAttrs
 "id ID #IMPLIED
  xml:base %URI; #IMPLIED" >

性质定义:  Attributedefinitions:

id = "name"

用于给一个元素指定一个唯一的名字的标准XML性质. 参考 "可扩展标记语言 (XML) 1.0" 推荐规范 [XML10].   Standard XML attribute for assigning a uniquename to an element.Refer to the "Extensible Markup Language (XML) 1.0" Recommendation [XML10].
Animatable:no.

xml:base = "<uri>"

指定一个不同于文档的基础URI的基础URI或外部实体. 参考 "XML 基础" 规范 [XML-BASE].     Specifies a base URI other than the base URI of the document or externalentity. Refer to the "XML Base" specification [XML-BASE].
Animatable:no.



5.10.2 xml:lang 和 xml:space性质  The xml:langand xml:space attributes

可以包含字符数据内容的元素有性质xml:lang 和 xml:space:     Elements that might contain character datacontent have attributes xml:lang and xml:space:

 
<!ENTITY % langSpaceAttrs
 "xml:lang NMTOKEN #IMPLIED
  xml:space (default|preserve) #IMPLIED" >

性质定义:  Attributedefinitions:

xml:lang = "languageID"

用于给一个元素指定用于特定元素的内容或性质值上的语言(例如, 英语) 的标准XML性质. 参考 "可扩展标记语言 (XML) 1.0" 推荐规范 [XML10].    Standard XML attribute to specify the language (e.g., English) used in thecontents and attribute values of particular elements. Refer to the"Extensible Markup Language (XML) 1.0" Recommendation [XML10].
Animatable:no.

xml:space = "{default | preserve}"

用于指定是否空白符保留在字符数据里的标准 XML性质.只有两种值defaultpreserve. 参考 "可扩展标记语言 (XML) 1.0" 推荐规范 [XML10]和在精图中的讨论空白符处理.    Standard XML attribute to specify whether white space is preserved in characterdata. The only possible values aredefault andpreserve.Refer to the "Extensible Markup Language (XML) 1.0" Recommendation [XML10] and to the discussionwhite space handlingin SVG.
Animatable:no.

 



5.11 DOM interfaces

The following interfaces are defined below: SVGDocument, SVGSVGElement,SVGGElement,SVGDefsElement,SVGDescElement, SVGTitleElement, SVGSymbolElement, SVGUseElement, SVGElementInstance, SVGElementInstanceList, SVGImageElement, SVGSwitchElement, GetSVGDocument.

 

Interface SVGDocument

When an 'svg' element isembedded inline as a component of a document from another namespace, such aswhen an 'svg' element is embedded inline withinan XHTML document [XHTML],then an SVGDocument object will not exist;instead, the root object in the document object hierarchy will be a Documentobject of a different type, such as an HTMLDocument object.

However, an SVGDocumentobject will indeed exist when the root element of the XML document hierarchy isan'svg' element, such as when viewing a stand-aloneSVG file (i.e., a file with MIME type "image/svg+xml"). In this case,the SVGDocument object will be the rootobject of the document object model hierarchy.

In the case where an SVG document is embedded by reference,such as when an XHTML document has an 'object'element whose href attribute references an SVGdocument (i.e., a document whose MIME type is "image/svg+xml" andwhose root element is thus an 'svg' element), therewill exist two distinct DOM hierarchies. The first DOM hierarchy will be forthe referencing document (e.g., an XHTML document). The second DOM hierarchywill be for the referenced SVG document. In this second DOM hierarchy, the rootobject of the document object model hierarchy is an SVGDocument object.

The SVGDocumentinterface contains a similar list of attributes and methods to the HTMLDocumentinterface described in theDocument ObjectModel (HTML) Level 1 chapter of the [DOM1]specification.


IDL Definition

 
interface SVGDocument : 
                Document,
                events::DocumentEvent { 
 
  readonly attribute DOMString    title;
  readonly attribute DOMString     referrer;
  readonly attribute DOMString      domain;
  readonly attribute DOMString      URL;
  readonly attribute SVGSVGElement rootElement;
};

 

Attributes

readonly DOMString title

The title of adocument as specified by the title sub-element ofthe 'svg' root element (i.e., <svg><title>Here is thetitle</title>...</svg>)

readonly DOMString referrer

Returns the URIof the page that linked to this page. The value is an empty string if the usernavigated to the page directly (not through a link, but, for example, via abookmark).

readonly DOMString domain

The domain nameof the server that served the document, or a null string if the server cannotbe identified by a domain name.

readonly DOMString URL

The complete URIof the document.

readonly SVGSVGElement rootElement

The root 'svg' element in the document hierarchy.

 

Interface SVGSVGElement

A key interface definition is the SVGSVGElement interface, which is the interfacethat corresponds to the'svg' element. This interface contains variousmiscellaneous commonly-used utility methods, such as matrix operations and theability to control the time of redraw on visual rendering devices.

SVGSVGElement extends ViewCSS and DocumentCSS to provide access to the computedvalues of properties and the override style sheet as described in DOM2.


IDL Definition

 
interface SVGSVGElement : 
                SVGElement,
                SVGTests,
                SVGLangSpace,
                SVGExternalResourcesRequired,
                SVGStylable,
                SVGLocatable,
                SVGFitToViewBox,
                SVGZoomAndPan,
                events::EventTarget,
                events::DocumentEvent,
                css::ViewCSS,
                css::DocumentCSS { 
 
  readonly attribute SVGAnimatedLength x;
  readonly attribute SVGAnimatedLength y;
  readonly attribute SVGAnimatedLength width;
  readonly attribute SVGAnimatedLength height;
           attribute DOMString         contentScriptType;
                       // raises DOMException on setting
           attribute DOMString         contentStyleType;
                       // raises DOMException on setting
  readonly attribute SVGRect           viewport;
  readonly attribute float pixelUnitToMillimeterX;
  readonly attribute float pixelUnitToMillimeterY;
  readonly attribute float screenPixelToMillimeterX;
  readonly attribute float screenPixelToMillimeterY;
           attribute boolean useCurrentView;
                       // raises DOMException on setting
  readonly attribute SVGViewSpec currentView;
           attribute float currentScale;
                       // raises DOMException on setting
  readonly attribute SVGPoint currentTranslate;
 
  unsigned long suspendRedraw ( in unsigned long max_wait_milliseconds );
  void          unsuspendRedraw ( in unsigned long suspend_handle_id )
                  raises( DOMException );
  void          unsuspendRedrawAll (  );
  void          forceRedraw (  );
  void          pauseAnimations (  );
  void          unpauseAnimations (  );
  boolean       animationsPaused (  );
  float         getCurrentTime (  );
  void          setCurrentTime ( in float seconds );
  NodeList      getIntersectionList ( in SVGRect rect, in SVGElement referenceElement );
  NodeList      getEnclosureList ( in SVGRect rect, in SVGElement referenceElement );
  boolean       checkIntersection ( in SVGElement element, in SVGRect rect );
  boolean       checkEnclosure ( in SVGElement element, in SVGRect rect );
  void          deselectAll (  );
  SVGNumber              createSVGNumber (  );
  SVGLength              createSVGLength (  );
  SVGAngle               createSVGAngle (  );
  SVGPoint               createSVGPoint (  );
  SVGMatrix              createSVGMatrix (  );
  SVGRect                createSVGRect (  );
  SVGTransform           createSVGTransform (  );
  SVGTransform     createSVGTransformFromMatrix ( in SVGMatrix matrix );
  Element         getElementById ( in DOMString elementId );
};

 

Attributes

readonly SVGAnimatedLength x

Corresponds toattribute x on the given 'svg'element.

readonly SVGAnimatedLength y

Corresponds toattribute y on the given 'svg'element.

readonly SVGAnimatedLength width

Corresponds toattribute width on the given 'svg' element.

readonly SVGAnimatedLength height

Corresponds toattribute height on the given 'svg' element.

DOMString contentScriptType

Corresponds toattribute contentScriptType on the given 'svg' element.

Exceptions on setting

DOMException

 

NO_MODIFICATION_ALLOWED_ERR: Raised on an attempt to change the value of a readonly attribute.

DOMString contentStyleType

Corresponds toattribute contentStyleType on the given 'svg' element.

Exceptions on setting

DOMException

 

NO_MODIFICATION_ALLOWED_ERR: Raised on an attempt to change the value of a readonly attribute.

readonly SVGRect viewport

The position and size of theviewport (implicit or explicit) that corresponds to this 'svg' element. When the user agent is actuallyrendering the content, then the position and size values represent the actualvalues when rendering. The position and size values are unitless values in thecoordinate system of the parent element. If no parent element exists (i.e., 'svg' element represents the root of the documenttree), if this SVG document is embedded as part of another document (e.g., viathe HTML 'object' element), then the positionand size are unitless values in the coordinate system of the parent document.(If the parent uses CSS or XSL layout, then unitless values represent pixelunits for the current CSS or XSL viewport, as described in the CSS2specification.) If the parent element does not have a coordinate system, thenthe user agent should provide reasonable default values for this attribute.

The object itself and itscontents are both readonly.

readonly float pixelUnitToMillimeterX

Size of a pixelunits (as defined by CSS2) along the x-axis of the viewport, which represents aunit somewhere in the range of 70dpi to 120dpi, and, on systems that supportthis, might actually match the characteristics of the target medium. On systemswhere it is impossible to know the size of a pixel, a suitable default pixelsize is provided.

readonly float pixelUnitToMillimeterY

Correspondingsize of a pixel unit along the y-axis of the viewport.

readonly float screenPixelToMillimeterX

User interface(UI) events in DOM Level 2 indicate the screen positions at which the given UIevent occurred. When the user agent actually knows the physical size of a"screen unit", this attribute will express that information;otherwise, user agents will provide a suitable default value such as .28mm.

readonly float screenPixelToMillimeterY

Correspondingsize of a screen pixel along the y-axis of the viewport.

boolean useCurrentView

The initial view(i.e., before magnification and panning) of the current innermost SVG documentfragment can be either the "standard" view (i.e., based on attributeson the 'svg' element such as fitBoxToViewport) or to a "custom" view (i.e.,a hyperlink into a particular 'view' or otherelement - see Linkinginto SVG content: URI fragments and SVG views). If the initial view is the"standard" view, then this attribute is false. If the initial view isa "custom" view, then this attribute is true.

Exceptions on setting

DOMException

 

NO_MODIFICATION_ALLOWED_ERR: Raised on an attempt to change the value of a readonly attribute.

readonly SVGViewSpec currentView

The definitionof the initial view (i.e., before magnification and panning) of the currentinnermost SVG document fragment. The meaning depends on the situation:

·  If the initial view was a"standard" view, then:

o     the values for viewBox, preserveAspectRatioand zoomAndPan within currentView will match the values for thecorresponding DOM attributes that are on SVGSVGElement directly

o     the values for transform and viewTargetwithin currentView will be null

·  If the initial view was a linkinto a 'view' element, then:

o     the values for viewBox, preserveAspectRatioand zoomAndPan within currentView will correspond to the correspondingattributes for the given 'view' element

o     the values for transform and viewTargetwithin currentView will be null

·  If the initial view was a linkinto another element (i.e., other than a 'view'),then:

o     the values for viewBox, preserveAspectRatioand zoomAndPan within currentView will match the values for thecorresponding DOM attributes that are on SVGSVGElement directly for the closestancestor 'svg' element

o     the values for transform within currentViewwill be null

o     the viewTargetwithin currentView will represent the targetof the link

·  If the initial view was a linkinto the SVG document fragment using an SVG view specification fragmentidentifier (i.e., #svgView(...)), then:

o     the values for viewBox, preserveAspectRatio,zoomAndPan, transformand viewTarget within currentView will correspond to the values from theSVG view specification fragment identifier

The object itself and itscontents are both readonly.

float currentScale

This attributeindicates the current scale factor relative to the initial view to take intoaccount user magnification and panning operations, as described underMagnificationand panning. DOM attributes currentScaleand currentTranslate are equivalent to the 2x3matrix [a b c d e f] = [currentScale 0 0 currentScale currentTranslate.xcurrentTranslate.y]. If "magnification" is enabled (i.e.,zoomAndPan="magnify"), then the effect is as if an extratransformation were placed at the outermost level on the SVG document fragment(i.e., outside the outermost'svg' element).

Exceptions on setting

DOMException

 

NO_MODIFICATION_ALLOWED_ERR: Raised on an attempt to change the value of a readonly attribute.

readonly SVGPoint currentTranslate

Thecorresponding translation factor that takes into account user"magnification".

Methods

suspendRedraw

Takes a time-outvalue which indicates that redraw shall not occur until: (a) the correspondingunsuspendRedraw(suspend_handle_id) call has been made, (b) anunsuspendRedrawAll() call has been made, or (c) its timer has timed out. Inenvironments that do not support interactivity (e.g., print media), then redrawshall not be suspended. suspend_handle_id = suspendRedraw(max_wait_milliseconds)and unsuspendRedraw(suspend_handle_id) must be packaged as balanced pairs. Whenyou 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 tosuspend_handle_id = suspendRedraw(max_wait_milliseconds) and follow the changeswith a method call similar to unsuspendRedraw(suspend_handle_id). Note thatmultiple suspendRedraw calls can be used at once and that each such method callis treated independently of the other suspendRedraw method calls.

Parameters

in unsigned long 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.

Return value

unsigned long

 

A number which acts as a unique identifier for the given suspendRedraw() call. This value must be passed as the parameter to the corresponding unsuspendRedraw() method call.

No Exceptions

unsuspendRedraw

Cancels aspecified suspendRedraw() by providing a unique suspend_handle_id.

Parameters

in unsigned long suspend_handle_id

 

A number which acts as a unique identifier for the desired suspendRedraw() call. The number supplied must be a value returned from a previous call to suspendRedraw()

No Return Value

Exceptions

DOMException

 

This method will raise a DOMException with value NOT_FOUND_ERR if an invalid value (i.e., no such suspend_handle_id is active) for suspend_handle_id is provided.

unsuspendRedrawAll

Cancels allcurrently active suspendRedraw() method calls. This method is most useful atthe very end of a set of SVG DOM calls to ensure that all pendingsuspendRedraw() method calls have been cancelled.

No Parameters

No Return Value

No Exceptions

forceRedraw

In renderingenvironments supporting interactivity, forces the user agent to immediatelyredraw all regions of the viewport that require updating.

No Parameters

No Return Value

No Exceptions

pauseAnimations

Suspends (i.e.,pauses) all currently running animations that are defined within the SVGdocument fragment corresponding to this 'svg'element, causing the animation clock corresponding to this document fragment tostand still until it is unpaused.

No Parameters

No Return Value

No Exceptions

unpauseAnimations

Unsuspends(i.e., unpauses) currently running animations that are defined within the SVGdocument fragment, causing the animation clock to continue from the time atwhich it was suspended.

No Parameters

No Return Value

No Exceptions

animationsPaused

Returns true ifthis SVG document fragment is in a paused state.

No Parameters

Return value

boolean

 

Boolean indicating whether this SVG document fragment is in a paused state.

No Exceptions

getCurrentTime

Returns thecurrent time in seconds relative to the start time for the current SVG documentfragment.

No Parameters

Return value

float

 

The current time in seconds.

No Exceptions

setCurrentTime

Adjusts theclock for this SVG document fragment, establishing a new current time.

Parameters

in float seconds

 

The new current time in seconds relative to the start time for the current SVG document fragment.

No Return Value

No Exceptions

getIntersectionList

Returns the listof graphics elements whose rendered content intersects the supplied rectangle,honoring the 'pointer-events' property value on each candidate graphicselement.

Parameters

in SVGRect rect

 

The test rectangle. The values are in the initial coordinate system for the current 'svg' element.

in SVGElement referenceElement

 

If not null, then only return elements whose drawing order has them below the given reference element.

Return value

NodeList

 

A list of Elements whose content intersects the supplied rectangle.

No Exceptions

getEnclosureList

Returns the listof graphics elements whose rendered content is entirely contained within thesupplied rectangle, honoring the 'pointer-events' property value on eachcandidate graphics element.

Parameters

in SVGRect rect

 

The test rectangle. The values are in the initial coordinate system for the current 'svg' element.

in SVGElement referenceElement

 

If not null, then only return elements whose drawing order has them below the given reference element.

Return value

NodeList

 

A list of Elements whose content is enclosed by the supplied rectangle.

No Exceptions

checkIntersection

Returns true ifthe rendered content of the given element intersects the supplied rectangle,honoring the 'pointer-events' property value on each candidate graphicselement.

Parameters

in SVGElement element

 

The element on which to perform the given test.

in SVGRect rect

 

The test rectangle. The values are in the initial coordinate system for the current 'svg' element.

Return value

boolean

 

True or false, depending on whether the given element intersects the supplied rectangle.

No Exceptions

checkEnclosure

Returns true ifthe rendered content of the given element is entirely contained within thesupplied rectangle, honoring the 'pointer-events' property value on eachcandidate graphics element.

Parameters

in SVGElement element

 

The element on which to perform the given test.

in SVGRect rect

 

The test rectangle. The values are in the initial coordinate system for the current 'svg' element.

Return value

boolean

 

True or false, depending on whether the given element is enclosed by the supplied rectangle.

No Exceptions

deselectAll

Unselects anyselected objects, including any selections of text strings and type-in bars.

No Parameters

No Return Value

No Exceptions

createSVGNumber

Creates anSVGNumber object outside of any document trees. The object is initialized to avalue of zero.

No Parameters

Return value

SVGNumber

 

An SVGNumber object.

No Exceptions

createSVGLength

Creates anSVGLength object outside of any document trees. The object is initialized tothe value of 0 user units.

No Parameters

Return value

SVGLength

 

An SVGLength object.

No Exceptions

createSVGAngle

Creates anSVGAngle object outside of any document trees. The object is initialized to thevalue 0 degrees (unitless).

No Parameters

Return value

SVGAngle

 

An SVGAngle object.

No Exceptions

createSVGPoint

Creates anSVGPoint object outside of any document trees. The object is initialized to thepoint (0,0) in the user coordinate system.

No Parameters

Return value

SVGPoint

 

An SVGPoint object.

No Exceptions

createSVGMatrix

Creates anSVGMatrix object outside of any document trees. The object is initialized tothe identity matrix.

No Parameters

Return value

SVGMatrix

 

An SVGMatrix object.

No Exceptions

createSVGRect

Creates anSVGRect object outside of any document trees. The object is initialized suchthat all values are set to 0 user units.

No Parameters

Return value

SVGRect

 

An SVGRect object.

No Exceptions

createSVGTransform

Creates anSVGTransform object outside of any document trees. The object is initialized toan identity matrix transform (SVG_TRANSFORM_MATRIX).

No Parameters

Return value

SVGTransform

 

An SVGTransform object.

No Exceptions

createSVGTransformFromMatrix

Creates anSVGTransform object outside of any document trees. The object is initialized tothe given matrix transform (i.e., SVG_TRANSFORM_MATRIX).

Parameters

in SVGMatrix matrix

 

The transform matrix.

Return value

SVGTransform

 

An SVGTransform object.

No Exceptions

getElementById

Searches thisSVG document fragment (i.e., the search is restricted to a subset of thedocument tree) for an Element whose id is given byelementId. If an Element is found, that Element is returned. If no such elementexists, returns null. Behavior is not defined ifmore than one element has this id.

Parameters

in DOMString elementId

 

The unique id value for an element.

Return value

Element

 

The matching element.

No Exceptions

 

Interface SVGGElement

The SVGGElementinterface corresponds to the 'g' element.


IDL Definition

 
interface SVGGElement : 
                SVGElement,
                SVGTests,
                SVGLangSpace,
                SVGExternalResourcesRequired,
                SVGStylable,
                SVGTransformable,
                events::EventTarget {};

 

 

Interface SVGDefsElement

The SVGDefsElementinterface corresponds to the 'defs' element.


IDL Definition

 
interface SVGDefsElement : 
                SVGElement,
                SVGTests,
                SVGLangSpace,
                SVGExternalResourcesRequired,
                SVGStylable,
                SVGTransformable,
                events::EventTarget {};

 

 

Interface SVGDescElement

The SVGDescElementinterface corresponds to the 'desc' element.


IDL Definition

 
interface SVGDescElement : 
                SVGElement,
                SVGLangSpace,
                SVGStylable {};

 

 

Interface SVGTitleElement

The SVGTitleElementinterface corresponds to the 'title' element.


IDL Definition

 
interface SVGTitleElement : 
                SVGElement,
                SVGLangSpace,
                SVGStylable {};

 

 

Interface SVGSymbolElement

The SVGSymbolElementinterface corresponds to the 'symbol' element.


IDL Definition

 
interface SVGSymbolElement : 
                SVGElement,
                SVGLangSpace,
                SVGExternalResourcesRequired,
                SVGStylable,
                SVGFitToViewBox,
                events::EventTarget {};

 

 

Interface SVGUseElement

The SVGUseElementinterface corresponds to the 'use' element.


IDL Definition

 
interface SVGUseElement : 
                SVGElement,
                SVGURIReference,
                SVGTests,
                SVGLangSpace,
                SVGExternalResourcesRequired,
                SVGStylable,
                SVGTransformable,
                events::EventTarget { 
 
  readonly attribute SVGAnimatedLength   x;
  readonly attribute SVGAnimatedLength   y;
  readonly attribute SVGAnimatedLength   width;
  readonly attribute SVGAnimatedLength   height;
  readonly attribute SVGElementInstance instanceRoot;
  readonly attribute SVGElementInstance animatedInstanceRoot;
};

 

Attributes

readonly SVGAnimatedLength x

Corresponds toattribute x on the given 'use'element.

readonly SVGAnimatedLength y

Corresponds toattribute y on the given 'use'element.

readonly SVGAnimatedLength width

Corresponds toattribute width on the given 'use' element.

readonly SVGAnimatedLength height

Corresponds toattribute height on the given 'use' element.

readonly SVGElementInstance instanceRoot

The root of the"instance tree". See description of SVGElementInstance for a discussion on theinstance tree.

readonly SVGElementInstance animatedInstanceRoot

If the 'href'attribute is being animated, contains the current animated root of the"instance tree". If the 'href' attribute is not currently beinganimated, contains the same value as 'instanceRoot'. The root of the"instance tree". See description ofSVGElementInstance for a discussion on the instancetree.

 

Interface SVGElementInstance

For each 'use' element, the SVG DOM maintains a shadowtree (the "instance tree") of objects of type SVGElementInstance. A SVGElementInstance represents a single node inthe instance tree. The root object in the instance tree is pointed to by the instanceRoot attribute on the SVGUseElement object for the corresponding 'use' element.

If the 'use' element references a simple graphicselement such as a 'rect', then there is only a single SVGElementInstance object, and the correspondingElement attribute on this SVGElementInstance object is the SVGRectElement that corresponds to the referenced'rect' element.

If the 'use' element references a 'g' which contains two 'rect' elements, then the instance tree containsthree SVGElementInstance objects, a root SVGElementInstance object whose correspondingElement is the SVGGElement object for the'g', and then two child SVGElementInstance objects, each of which has itscorrespondingElement that is an SVGRectElement object.

If the referenced object is itself a 'use', or if there are 'use' subelements within the referenced object,the instance tree will contain recursive expansion of the indirect referencesto form a complete tree. For example, if a'use' element references a 'g', and the 'g' itself contains a 'use', and that 'use' references a 'rect', then the instance tree for the original(outermost) 'use' will consist of a hierarchy of SVGElementInstance objects, as follows:

 
SVGElementInstance #1 (parentNode=null, firstChild=#2, correspondingElement is the 'g')
  SVGElementInstance #2 (parentNode=#1, firstChild=#3, correspondingElement is the other 'use')
    SVGElementInstance #3 (parentNode=#2, firstChild=null, corresponding Element is the 'rect')


IDL Definition

 
interface SVGElementInstance : events::EventTarget { 
  readonly attribute SVGElement correspondingElement;
  readonly attribute SVGUseElement correspondingUseElement;
  readonly attribute SVGElementInstance parentNode;
  readonly attribute SVGElementInstanceList childNodes;
  readonly attribute SVGElementInstance firstChild;
  readonly attribute SVGElementInstance lastChild;
  readonly attribute SVGElementInstance previousSibling;
  readonly attribute SVGElementInstance nextSibling;
};

 

Attributes

readonly SVGElement correspondingElement

Thecorresponding 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 SVGElementInstance object for the'rect' element.

readonly SVGUseElement 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 asa 'rect'), then the correspondingUseElementis the outermost 'use' (i.e., the one which indirectly referencesthe 'rect', not the one with the direct reference).

readonly SVGElementInstance parentNode

The parent ofthis SVGElementInstance within the instancetree. All SVGElementInstance objects have aparent except the SVGElementInstance whichcorresponds to the element which was directly referenced by the'use' element, in which case parentNode is null.

readonly SVGElementInstanceList childNodes

An SVGElementInstanceList that contains all childrenof this SVGElementInstance within theinstance tree. If there are no children, this is an SVGElementInstanceList containing no entries(i.e., an empty list).

readonly SVGElementInstance firstChild

The first childof this SVGElementInstance within theinstance tree. If there is no such SVGElementInstance,this returns null.

readonly SVGElementInstance lastChild

The last childof this SVGElementInstance within theinstance tree. If there is no such SVGElementInstance,this returns null.

readonly SVGElementInstance previousSibling

The SVGElementInstance immediately preceding this SVGElementInstance. If there is no such SVGElementInstance, this returns null.

readonly SVGElementInstance nextSibling

The SVGElementInstance immediately following this SVGElementInstance. If there is no such SVGElementInstance, this returns null.

 

Interface SVGElementInstanceList

The SVGElementInstanceListinterface provides the abstraction of an ordered collection of SVGElementInstance objects, without defining orconstraining how this collection is implemented.


IDL Definition

 
interface SVGElementInstanceList { 
 
  readonly attribute unsigned long length;
 
  SVGElementInstance item ( in unsigned long index );
};

 

Attributes

readonly unsignedlong length

The number of SVGElementInstance objects in the list. The rangeof valid child indices is 0 to length-1inclusive.

Methods

item

Returns the indexth item in the collection. If index is greater than or equal to the number ofnodes in the list, this returns null.

Parameters

in unsigned long index

 

Index into the collection.

Return value

SVGElementInstance

 

The SVGElementInstance object at the indexth position in the SVGElementInstanceList, or null if that is not a valid index.

No Exceptions

 

Interface SVGImageElement

The SVGImageElementinterface corresponds to the 'image' element.


IDL Definition

 
interface SVGImageElement : 
                SVGElement,
                SVGURIReference,
                SVGTests,
                SVGLangSpace,
                SVGExternalResourcesRequired,
                SVGStylable,
                SVGTransformable,
                events::EventTarget { 
 
  readonly attribute SVGAnimatedLength x;
  readonly attribute SVGAnimatedLength y;
  readonly attribute SVGAnimatedLength width;
  readonly attribute SVGAnimatedLength height;
  readonly attribute SVGAnimatedPreserveAspectRatio preserveAspectRatio;
};

 

Attributes

readonly SVGAnimatedLength x

Corresponds toattribute x on the given 'image'element.

readonly SVGAnimatedLength y

Corresponds toattribute y on the given 'image'element.

readonly SVGAnimatedLength width

Corresponds toattribute width on the given 'image' element.

readonly SVGAnimatedLength height

Corresponds toattribute height on the given 'image' element.

readonly SVGAnimatedPreserveAspectRatio preserveAspectRatio

Corresponds toattribute preserveAspectRatio on the givenelement.

 

Interface SVGSwitchElement

The SVGSwitchElementinterface corresponds to the 'switch' element.


IDL Definition

 
interface SVGSwitchElement : 
                SVGElement,
                SVGTests,
                SVGLangSpace,
                SVGExternalResourcesRequired,
                SVGStylable,
                SVGTransformable,
                events::EventTarget {};

 

 

Interface GetSVGDocument

In the case where an SVG document is embedded by reference,such as when an XHTML document has an 'object'element whose href (or equivalent) attributereferences an SVG document (i.e., a document whose MIME type is"image/svg+xml" and whose root element is thus an 'svg' element), the SVG user agent is required toimplement the GetSVGDocument interface forthe element which references the SVG document (e.g., the HTML 'object' or comparable referencing elements).


IDL Definition

 
interface GetSVGDocument { 
 
  SVGDocument getSVGDocument (  )
                  raises( DOMException );
};

 

Methods

getSVGDocument

Returns the SVGDocumentobject for the referenced SVG document.

No Parameters

Return value

SVGDocument

 

The SVGDocument object for the referenced SVG document.

Exceptions

DOMException

 

NOT_SUPPORTED_ERR: No SVGDocument object is available.


previous next   contents   elements   attributes   properties   index  

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值