SVG Tiny 1.2 - 20050413

14 Linking

Contents

14.1 References

14.1.1 Overview

SVG makes extensive use of IRI references [IRI] to other objects. For example, to fill a rectangle with a linear gradient, you first define a 'linearGradient' element and give it an ID, as in:

Example: 05_07.xml
<linearGradient id="MyGradient">...</linearGradient>
    

You then reference the linear gradient as the value of the 'fill' property for the rectangle, as in:

Example: 05_08.xml
<rect fill="url(#MyGradient)"/>
    

IRI references are defined in the following form:

      <iri-reference> = [ <absoluteIRI> | <relativeIRI> ] [ "#" <elementID> ]    

where <elementID> is the ID of the referenced element.

(Note that the bare name form above (i.e., #<elementID>) is formulated in a syntax compatible with "XPointer Framework" [XPTRFW].

SVG supports two types of IRI references:

The following rules apply to the processing of IRI references:

The following list describes the elements and properties that allow IRI references and the valid target types for those references:

The following rules apply to the processing of invalid IRI references:

It is recommended that, wherever possible, referenced elements be defined inside of a 'defs' element. Among the elements that are always referenced are 'linearGradient' and 'radialGradient'. Defining these elements inside of a 'defs' element promotes understandability of the SVG content and thus promotes accessibility.

14.1.2 IRIs and URIs

Internationalized Resource Identifiers (IRIs) are a more generalized complement to Uniform Resource Identifiers (URIs). An IRI is a sequence of characters from the Universal Character Set [Unicode40]. A URI is constructed from a much more restricted set of characters. All URIs are already conformant IRIs. A mapping from IRIs to URIs is defined by the IRI specification, which means that IRIs can be used instead of URIs in XML documents, to identify resources. IRIs can be converted to URIs for resolution on a network, if the protocol does not support IRIs directly.

Previous versions of SVG, following XLink, defined a [IRI Reference] type as a URI or as a sequence of characters which must result in a URI reference after a particular escaping procedure was applied. The escaping procedure was repeated in the XLink specification [XLink], and in the W3C XML Schema Part 2: Datatypes specification [Schema2]. This copying introduced the possibility of error and divergence, but was done because the IRI specification was not yet standardized.

In this specification, the correct term "IRI' is used for this 'URI or sequence of characters plus an algorithm' and the escaping method is defined by reference to the IRI specification [RFC3987], which has since become an IETF Proposed Standard. Other W3C specifications are expected to be revised over time to remove these duplicate descriptions of the escaping procedure and to refer to IRI directly.

14.1.3 IRI reference attributes

A IRI reference is specified within an href attribute in the XLink [XLINK] namespace. For example, if the prefix of 'xlink' is used for attributes in the XLink namespace, then the attribute will be specified as xlink:href. The value of this attribute is a IRI reference for the desired resource (or secondary resource, if there is a fragment identifier).

The value of the href attribute must be a IRI reference as defined in [RFC3987].

If the protocol, such as HTTP, does not support IRIs directly, the IRI is converted to a URI by the SVG implementation, as described in section 3.1 of the IRI specification.

Because it is impractical for any application to check that a value is an IRI reference, this specification follows the lead of [RFC3986] in this matter and imposes no such conformance testing requirement on SVG applications.

If the IRI reference is relative, its absolute version must be computed by the method of [XML-Base] before use.

Additional XLink attributes can be specified that provide supplemental information regarding the referenced resource.

Schema: xlinkatt
  <define name='svg.XLinkBase.attr' combine='interleave'>
    <optional>
      <attribute name='xlink:type' svg:animatable='true' svg:inheritable='false'>
        <value>simple</value>
      </attribute>
    </optional>
    <optional>
      <attribute name='xlink:role' svg:animatable='false' svg:inheritable='false'>
        <ref name='IRI.datatype'/>
      </attribute>
    </optional>
    <optional>
      <attribute name='xlink:arcrole' svg:animatable='false' svg:inheritable='false'>
        <ref name='IRI.datatype'/>
      </attribute>
    </optional>
    <optional>
      <attribute name='xlink:title' svg:animatable='false' svg:inheritable='false'><text/></attribute>
    </optional>
  </define>

  <define name='svg.XLinkHrefRequired.attr' combine='interleave'>
    <attribute name='xlink:href' svg:animatable='true' svg:inheritable='false'>
      <ref name='IRI.datatype'/>
    </attribute>
  </define>

  <define name='svg.XLinkBaseRequired.attr' combine='interleave'>
    <ref name='svg.XLinkBase.attr'/>
    <ref name='svg.XLinkHrefRequired.attr'/>
  </define>


  <define name='svg.XLinkActuateOnLoad.attr' combine='interleave'>
    <optional>
      <attribute name='xlink:actuate' svg:animatable='false' svg:inheritable='false'>
        <value>onLoad</value>
      </attribute>
    </optional>
  </define>

  <define name='svg.XLinkShowOther.attr' combine='interleave'>
    <optional>
      <attribute name='xlink:show' svg:animatable='false' svg:inheritable='false'>
        <value>other</value>
      </attribute>
    </optional>
  </define>

  <define name='svg.XLinkEmbed.attr' combine='interleave'>
    <optional>
      <attribute name='xlink:show' svg:animatable='false' svg:inheritable='false'>
        <value>embed</value>
      </attribute>
    </optional>
    <ref name='svg.XLinkActuateOnLoad.attr'/>
    <ref name='svg.XLinkBaseRequired.attr'/>
  </define>


  <define name='svg.XLinkRequired.attr' combine='interleave'>
    <ref name='svg.XLinkShowOther.attr'/>
    <ref name='svg.XLinkActuateOnLoad.attr'/>
    <ref name='svg.XLinkBaseRequired.attr'/>
  </define>


  <define name='svg.XLinkReplace.attr' combine='interleave'>
    <optional>
      <attribute name='xlink:show' a:defaultValue='replace' svg:animatable='false' svg:inheritable='false'>
        <choice>
          <value>new</value>
          <value>replace</value>
        </choice>
      </attribute>
    </optional>
    <optional>
      <attribute name='xlink:actuate' svg:animatable='false' svg:inheritable='false'>
        <value>onRequest</value>
      </attribute>
    </optional>
    <ref name='svg.XLinkBaseRequired.attr'/>
  </define>

  <define name='svg.XLink.attr' combine='interleave'>
    <optional>
      <ref name='svg.XLinkHrefRequired.attr'/>
    </optional>
    <ref name='svg.XLinkShowOther.attr'/>
    <ref name='svg.XLinkActuateOnLoad.attr'/>
    <ref name='svg.XLinkBase.attr'/>
  </define>
    
xlink:type = 'simple'
Identifies the type of XLink being used. In SVG Tiny 1.2, only simple links are available. All links are simple links by default, so the attribute xlink:type="simple" is optional and need not be explicitly stated. Refer to the "XML Linking Language (XLink)" [XLink].

Animatable: no.
xlink:role = '<iri>'
An optional IRI reference that identifies some resource that describes the intended property. The value must be a IRI reference as defined in [RFC2396], except that if the IRI scheme used is allowed to have absolute and relative forms, the IRI portion must be absolute. When no value is supplied, no particular role value is to be inferred. Refer to the "XML Linking Language (XLink)" [XLink].

Animatable: no.
xlink:arcrole = '<iri>'
An optional IRI reference that identifies some resource that describes the intended property. The value must be a IRI reference as defined in [RFC2396], except that if the IRI scheme used is allowed to have absolute and relative forms, the IRI portion must be absolute. When no value is supplied, no particular role value is to be inferred. The arcrole attribute corresponds to the [RDF] notion of a property, where the role can be interpreted as stating that "starting-resource HAS arc-role ending-resource." This contextual role can differ from the meaning of an ending resource when taken outside the context of this particular arc. For example, a resource might generically represent a "person," but in the context of a particular arc it might have the role of "mother" and in the context of a different arc it might have the role of "daughter." Refer to the "XML Linking Language (XLink)" [XLink].

Animatable: no.
xlink:title = '<string>'
The title attribute is used to describe the meaning of a link or resource in a human-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 that describes the resource. In general it is preferable to use a 'title' child element rather than a 'title' attribute. The use of this information is highly dependent on the type of processing being done. It may be used, for example, to make titles available to 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 hover over a starting resource. Refer to the "XML Linking Language (XLink)" [XLink].

Animatable: no.
xlink:show = 'new' | 'replace' | 'embed' | 'other' | 'none'
This attribute is provided for backwards compatibility with SVG 1.1. It provides documentation to XLink-aware processors. In case of a conflict, the target attribute has priority, since it can express a wider range of values. Refer to the "XML Linking Language (XLink)" [XLink].

Animatable: no.
xlink:actuate = 'onLoad'
This attribute is provided for backwards compatibility with SVG 1.1. It provides documentation to XLink-aware processors. Refer to the "XML Linking Language (XLink)" [XLink].

Animatable: no.

In all cases, for compliance with the "Namespaces in XML 1.1" Recommendation [XML-NS], an explicit XLink namespace declaration must be provided whenever one of the above XLink attributes is used within SVG content. One simple way to provide such an XLink namespace declaration is to include an xmlns attribute for the XLink namespace on the 'svg' element for content that uses XLink attributes. For example:

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

14.1.4 Externally referenced documents

In this section, the term "primary document" refers to an outermost SVG document or SVG document fragment. If an SVG document is loaded directly by a web browser (e.g., the browser views file foo.svg), then it is the primary document. If an SVG document as a whole is referenced for inclusion by a parent document, such as using the HTML object or SVG animation elements, then that document itself is also a primary document. If an SVG document fragment is embedded inline within a non-SVG document, then the outermost svg element defines the root element for a subtree which acts as a primary document.

Implementations are free to optimize for the case of large resource library loaded into multiple primary documents, but logically each primary document represents its own separate, self-contained document instance. In particular, the conceptual processing model is that events (e.g., the document load event) are fired; scripts are executed in normal fashion and resource documents are modifiable by scripts; coordinate systems transformations are applied; timelines are initiated and animations execute; etc. For example, if document A.svg includes an svg:animation element which refers to B.svg, then both are primary documents, and both represent separate, self-contained documents with their own scripting contexts and animation timelines.

The term "resource document" refers to a complete, self-contained SVG document which has at least one of its elements referenced as a resource by a primary document. For example, suppose document A.svg is loaded into a browser for viewing, and this document refers to a gradient element within B.svg via a IRI reference. In this case, A.svg is a primary document and B.svg is a resource document.

Each primary document has an associated dictionary that maps all IRIs for resource documents it references; initially it is populated only with the primary document itself. Each resource or subresource loaded directly or indirectly is resolved through that dictionary with resource documents downloaded as needed.

The conceptual model is that each resource document is loaded only once; if the same resource document is referenced multiple times directly or indirectly by the same primary document, that resource document is only retrieved and processed one time.

The conceptual processing model for resource documents is that the document is processed as a complete and separate SVG document instance. The only difference between a resource document and a primary document is that the primary document is rendered directly to the canvas, whereas all resource documents are conceptually rendered to an invisible (offscreen) canvas. In particular, the conceptual processing model is that events (e.g., the document load event) are fired; scripts are executed in normal fashion and resource documents are modifiable by scripts; coordinate systems transformations are applied; stylesheets are applied and the CSS cascade is run (not relevant to SVGT1.2); timelines are initiated and animations execute; sXBL transformations are applied (not relevant to SVGT1.2); etc.

Because of HTTP redirects, the same source document might be retrieved from multiple different source IRIs. The rule for SVG is that documents are considered to be unique based on string comparisons of the full IRI after resolving relative IRIs into absolute IRIs and after taking into account HTTP redirects (i.e., use the post-redirect IRI instead of the original source IRI).

14.2 Links out of SVG content: the 'a' element

SVG provides an 'a' element, analogous to HTML's 'a' element, to indicate links (also known as hyperlinks or Web links). SVG uses XLink ([XLink]) for all link definitions.

SVG Tiny 1.2 only requires that user agents support XLink's notion of simple links. Each simple link associates exactly two resources, one local and one remote, with an arc going from the former to the latter.

A simple link is defined for each separate rendered element contained within the 'a' element; thus, if the 'a' element contains three 'circle' elements, a link is created for each circle. For each rendered element within an 'a' element, the given rendered element is the local resource (the source anchor for the link).

The remote resource (the destination for the link) is defined by a IRI specified by the XLink href attribute on the 'a' element. The remote resource may be any Web resource (e.g., an image, a video clip, a sound bite, a program, another SVG document, an HTML document, etc.). By activating these links (by clicking with the mouse, through keyboard input, voice commands, etc.), users may traverse hyperlinks to these resources.

Example link01 assigns a link to an ellipse.

Example: 17_01.svg
<?xml version="1.0" standalone="no"?>
<svg width="5cm" height="3cm" viewBox="0 0 5 3" version="1.2" baseProfile="tiny"
     xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <desc>Example link01 - a link on an ellipse
  </desc>
  <rect x=".01" y=".01" width="4.98" height="2.98" 
        fill="none" stroke="blue"  stroke-width=".03"/>
  <a xlink:href="http://www.w3.org">
    <ellipse cx="2.5" cy="1.5" rx="2" ry="1"
             fill="red" />
  </a>
</svg>
    
Rendering of 17_01.svg

If the above SVG file is viewed by a user agent that supports both SVG and HTML, then clicking on the ellipse will cause the current window or frame to be replaced by the W3C home page.

Schema: a
  <element name='a'>
      <ref name='a.AT'/>
      <!-- the content model of 'a' is defined in the 
           context of its containing element -->
  </element>


  <define name='a.AT' combine='interleave'>
    <ref name='svg.Core.attr'/>
    <ref name='svg.Conditional.attr'/>
    <ref name='svg.Properties.attr'/>
    <ref name='svg.External.attr'/>
    <ref name='svg.Focus.attr'/>
    <ref name='svg.Transform.attr'/>
    <ref name='svg.XLinkReplace.attr'/>
    <optional>
      <attribute name='target' svg:animatable='true' svg:inheritable='false'>
        <ref name='LinkTarget.datatype'/>
      </attribute>
    </optional>
  </define>
    

Attribute definitions:

xlink:type = 'simple'
Optional. (See generic description of xlink:type attribute.)
xlink:role = '<iri>'
Optional. (See generic description of xlink:role attribute.)
xlink:arcrole = '<iri>'
Optional. (See generic description of xlink:arcrole attribute.)
xlink:title = '<string>'
(See generic description of xlink:title attribute.)
xlink:show = 'new' | 'replace'
This optional attribute is provided for backwards compatibility with SVG 1.1. It provides documentation to XLink-aware processors. If target="_blank" then use xlink:show="new" else use "replace". In case of a conflict, the target attribute has priority, since it can express a wider range of values. Refer to the "XML Linking Language (XLink)" [XLink].

Animatable: no.
xlink:actuate = 'onRequest'
This optional attribute is provided for backwards compatibility with SVG 1.1. It provides documentation to XLink-aware processors that an application should traverse from the starting resource to the ending resource only on a post-loading event triggered for the purpose of traversal. Refer to the "XML Linking Language (XLink)" [XLink].

Animatable: no.
xlink:href = "<iri>"
The location of the referenced object, expressed as a IRI reference. Refer to the "XML Linking Language (XLink)" [XLink].

Animatable: yes.
target = '_replace' | '_self' | '_parent' | '_top' | '_blank' | "<frame-target>"

This attribute is used when there are multiple possible targets for the ending resource, such as when the parent document is a multi-frame HTML or XHTML document. This attribute specifies the name or portion of the target window, frame, pane, tab, or other relevant presentation context (e.g., an HTML or XHTML frame) into which a document is to be opened when the link is activated. The values and semantics of this attribute are the same as the WebCGM Picture Behavior values [WebCGM]:

_replace
The current SVG image is replaced by the linked content in the same rectangular area in the same frame as the current SVG image. This is the default value, if the target attribute is not specified.
_self
The current SVG image is replaced by the linked content in the same frame as the current SVG image.
_parent
The immediate frameset parent of the SVG image is replaced by the linked content.
_top
The content of the full window or tab, including any frames, is replaced by the linked content
_blank
A new un-named window or tab is requested for the display of the linked content. If this fails, the result is the same as _top
"<frame-target>"
Specified the name of the frame, pane, or other relevant presentation context for display of the linked content. If this already exists, it is re-used, replacing the existing content. if it does not exist, it is created (the same as _blank, except that it now has a name). frame-target must be an XML name [XML] so it must start with a name start alphabetic character (a-zA-Z).

Note: The value _new is not a legal value for target (use _blank).

Animatable: yes.

14.3 Linking into SVG content: IRI fragments and SVG views

14.3.1 Introduction: IRI fragments and SVG views

On the Internet, resources are identified using IRIs (International Resource Identifiers) [RFC3987]. For example, an SVG file called MyDrawing.svg located at http://example.com might have the following IRI:

http://example.com/MyDrawing.svg

An IRI can also address a particular element within an XML document by including a IRI fragment identifier as part of the IRI. An IRI which includes a IRI fragment identifier consists of an optional base IRI, followed by a "#" character, followed by the IRI fragment identifier. For example, the following IRI can be used to specify the element whose ID is "Lamppost" within file MyDrawing.svg:

http://example.com/MyDrawing.svg#Lamppost

Because SVG content often represents a picture or drawing of something, a common need is to link into a particular view of the document, where a view indicates the initial transformations so as to present a closeup of a particular section of the document.

14.3.2 SVG fragment identifiers

To link into a particular view of an SVG document, the IRI fragment identifier needs to be a correctly formed SVG fragment identifier. An SVG fragment identifier defines the meaning of the "selector" or "fragment identifier" portion of IRIs that locate resources of MIME media type "image/svg+xml".

An SVG fragment identifier can come in two forms:

  1. Shorthand bare name form of addressing (e.g., MyDrawing.svg#MyView). This form of addressing, which allows addressing an SVG element by its ID, is compatible with the fragment addressing mechanism for older versions of HTML and the shorthand bare name formulation in "XPointer Framework" [XPTRFW].
  2. SVG view specification (e.g., MyDrawing.svg#svgView(transform(scale(2))). This form of addressing specifies the desired view of the document (e.g., the region of the document to view, the initial zoom level) completely within the SVG fragment specification. The contents of the SVG view specification is transform(...) whose parameters have the same meaning as the corresponding attribute has on a 'g' element).

An SVG fragment identifier is defined as follows:

SVGFragmentIdentifier ::= BareName |
                          SVGViewSpec

BareName ::= XML_Name
SVGViewSpec ::= 'svgView(' SVGViewAttributes ')'
SVGViewAttributes ::= SVGViewAttribute |
                      SVGViewAttribute ';' SVGViewAttributes

SVGViewAttribute ::= transformSpec
transformSpec ::= 'transform(' TransformParams ')'

where:

Spaces are not allowed in fragment specifications; thus, commas are used to separate numeric values within an SVG view specification (e.g., #svgView(transform(scale(5),translate(100,100)))) and semicolons are used to separate attributes (e.g., #svgView(scale(2);rotate(45))).

Note: characters in fragment identifiers that are outside the repertoire of US-ASCII must be encoded using UTF-8 and %HH escaping if the value of the XLink href attribute is converted to a URI for resolution. [RFC3987]

When a source document performs a link into an SVG document via an HTML [HTML4] anchor element (i.e., <a href=...> element in HTML) or an XLink specification [XLINK], then the SVG fragment identifier specifies the initial view into the SVG document, as follows:

14.4 Hyperlinking Module

The Hyperlinking Module contains the following element:

The XLink Attribute Module contains the following attributes: