On the Internet, resources are identified using URLs (Internationalized Resource Identifiers). For example, an SVG file called someDrawing.svg located at http://example.com might have the following URL:
http://example.com/someDrawing.svg
An URL can also address a particular element within an XML document by including an URL fragment identifier as part of the URL. An URL which includes an URL fragment identifier consists of an optional base URL, followed by a "#" character, followed by the URL fragment identifier. For example, the following URL can be used to specify the element whose ID is "Lamppost" within file someDrawing.svg:
http://example.com/someDrawing.svg#Lamppost
Internationalized Resource Identifiers (URLs) are a more generalized complement to Uniform Resource Identifiers (URIs). An URL is a sequence of characters from the Universal Character Set [UNICODE]. A URI is constructed from a much more restricted set of characters. All URIs are already conformant URLs. A mapping from URLs to URIs is defined by the URL specification, which means that URLs can be used instead of URIs in XML documents, to identify resources. URLs can be converted to URIs for resolution on a network, if the protocol does not support URLs directly.
Previous versions of SVG, following XLink, defined an URL reference type as a URI or as a sequence of characters which must result in an URL after a particular escaping procedure was applied. The escaping procedure was repeated in the XLink 1.0 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 URL specification was not yet standardized.
In this specification, the correct term URL is used for this "URI or sequence of characters plus an algorithm" and the escaping method, which turns URLs into URIs, is defined by reference to the URL 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 URL directly.
FuncURL has been removed. This section needs to be rewritten.
URLs are used in the 'animate/xlink:href' attribute. Some attributes allow both URLs and text strings as content. To disambiguate a text string from a relative URL, the functional notation FuncURL is used. This is simply an URL delimited with a functional notation. Note: For historical reasons, the delimiters are "url(" and ")", for compatibility with the CSS specifications. The FuncURL form is used in presentation attributes.
SVG makes extensive use of URL references, both absolute and relative, 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:
You then reference the linear gradient as the value of the 'fill' property for the rectangle, as in the following example:
SVG supports two types of URL references:
The following rules apply to the processing of URL references:
The following list describes the elements and properties that allow URL references and the valid target types for those references:
The following rules apply to the processing of invalid URL references:
URL references are normally specified with 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 is specified as 'xlink:href'. The value of this attribute forms a reference for the desired resource (or secondary resource, if there is a fragment identifier).
The value of the 'href' attribute must be an URL.
If the protocol, such as HTTP, does not support URLs directly, the URL is converted to a URI by the SVG implementation, as described in section 3.1 of the URL specification [RFC3987].
Because it is impractical for any application to check that a value is an URL reference, this specification follows the lead of the URL Specification in this matter and imposes no such conformance testing requirement on SVG applications.
If the URL reference is relative, its absolute version must be computed by the method described in XML Base before use [XML-BASE].
Identifies the type of XLink being used. In SVG 1.1, only simple links are available. Links are simple links by default, so the attribute xlink:type="simple" is optional and may be omitted on simple links. Refer to the XML Linking Language (XLink) [XLINK].
Animatable: no.
An optional URL reference that identifies some resource that describes the intended property. The value must be an URL reference as defined in [RFC3987], except that if the URL scheme used is allowed to have absolute and relative forms, the URL portion must be absolute. When no value is supplied, no particular role value shall be inferred. Refer to the XML Linking Language (XLink) [XLINK].
Animatable: no.
An optional URL reference that identifies some resource that describes the intended property. The value must be an URL reference as defined in [RFC3987], except that if the URL scheme used is allowed to have absolute and relative forms, the URL portion must be absolute. When no value is supplied, no particular role value shall be inferred. The arcrole attribute corresponds to the [RDF-PRIMER] 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.
The title attribute shall be 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 shall 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.
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.
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 either the "Namespaces in XML 1.0" or the "Namespaces in XML 1.1" Recommendation [XML-NS10][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:
]]>
SVG provides an 'a' element, to indicate links (also known as hyperlinks or Web links). The 'a' element may contain any element that its parent may contain, except itself.
SVG uses XLink ([XLink]) for all link definitions. SVG 1.1 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 an URL 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, an element within the current document, an element within a different document, etc.). By activating these links (by clicking with the mouse, through keyboard input, voice commands, etc.), users may visit these resources.
Example link01 assigns a link to an ellipse.
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.
Attribute definitions:
Name | Value | Lacuna value | Animatable |
---|---|---|---|
xlink:show | new | replace | (none) | no |
xlink:actuate | onRequest | (none) | no |
These attribute 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.
'xlink:actuate' indicates 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].
Name | Value | Lacuna value | Animatable |
---|---|---|---|
xlink:href | <url> | (none) | yes |
Name | Value | Lacuna value | Animatable |
---|---|---|---|
target | _replace | _self | _parent | _top | _blank | <XML-Name> | _self | yes |
This attribute should be 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, iframe, or object element) into which a document is to be opened when the link is activated:
Note: The value '_new' is not a legal value for target (use '_blank').
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.
SVG 2 Requirement: | Merge the SVG 1.1 SE text and the SVG Tiny 1.2 text on fragment identifiers link traversal and add media fragments. |
---|---|
Resolution: | SVG 2 will media fragment identifiers. |
Purpose: | To align with Media Fragments URI. |
Owner: | Cyril (ACTION-3442) |
To link into a particular view of an SVG document, the URL 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 URLs that locate resources of MIME media type "image/svg+xml".
An SVG fragment identifier can come in the following forms:
This implies that it is not possible anymore in SVG 2.0 to define id for elements starting with 'xywh=' or 't='.
An SVG fragment identifier is defined as follows:
SVGFragmentIdentifier ::= BareName *( "&" timesegment ) | SVGViewSpec *( "&" timesegment ) | spacesegment *( "&" timesegment ) | timesegment *( "&" spacesegment ) BareName ::= XML_Name SVGViewSpec ::= 'svgView(' SVGViewAttributes ')' SVGViewAttributes ::= SVGViewAttribute | SVGViewAttribute ';' SVGViewAttributes SVGViewAttribute ::= viewBoxSpec | preserveAspectRatioSpec | transformSpec | zoomAndPanSpec | viewTargetSpec viewBoxSpec ::= 'viewBox(' ViewBoxParams ')' preserveAspectRatioSpec = 'preserveAspectRatio(' AspectParams ')' transformSpec ::= 'transform(' TransformParams ')' zoomAndPanSpec ::= 'zoomAndPan(' ZoomAndPanParams ')' viewTargetSpec ::= 'viewTarget(' ViewTargetParams ')'
where:
Spaces are not allowed in fragment specifications; thus, commas are used to separate numeric values within an SVG view specification (e.g., #svgView(viewBox(0,0,200,200))) and semicolons are used to separate attributes (e.g., #svgView(viewBox(0,0,200,200);preserveAspectRatio(none))).
Semicolons used to separate 'SVGViewAttribute' in SVG fragments may be url-escaped (as %3B); this is useful when animating a (semi-colon separated) list of URLs because otherwise the semicolon would be interpreted as a list separator.
The five types of SVGViewAttribute may occur in any order, but each type may only occur at most one time in a correctly formed SVGViewSpec.
When a source document performs a link into an SVG document, for example via an HTML anchor element ([HTML4], section 12.2; 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:
Do we allow the "pixel:" or "percent:" part of the spatial identifier? If yes, how do they map onto SVG user units?
The 'view' element is defined as follows:
Attribute definitions:
Name | Value | Lacuna value | Animatable |
---|---|---|---|
viewTarget | <XML-Name> | (none) | no |
It is helpful to users if the target element(s) are highlighted. The visual styling of this highlight should be decided by the document author, because the SVG user agent has no way to determine what changes would make the elements more visible.
The CSS :target selector ([SELECTORS], section 6.2.2) may be used in a stylesheet to provide alternate styling for elements which are the target of links. For example:
The SVGAElement interface corresponds to the 'a' element.
interface SVGAElement : SVGGraphicsElement { readonly attribute SVGAnimatedString target; }; SVGAElement implements SVGURIReference;
The SVGViewElement interface corresponds to the 'view' element.
interface SVGViewElement : SVGElement { readonly attribute SVGStringList viewTarget; }; SVGViewElement implements SVGFitToViewBox; SVGViewElement implements SVGZoomAndPan;