Movatterモバイル変換


[0]ホーム

URL:


Chapter 16: Linking

16.1. References

16.1.1. Overview

On the Internet, resources are identified usingURLs(Internationalized Resource Identifiers). Forexample, an SVG file called someDrawing.svg located athttp://example.com might have the followingURL:

http://example.com/someDrawing.svg

AnURL can also address a particular element within an XMLdocument by including anURL fragmentidentifier as part of theURL. AnURL which includes anURL fragment identifier consists of an optional baseURL, followed by a "#" character,followed by theURL fragment identifier. For example, thefollowingURL can be used to specify the element whose ID is"Lamppost" within file someDrawing.svg:

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

16.1.2. Definitions

URL reference
An URL reference is an Internationalized Resource Identifier, as defined inInternationalized Resource Identifiers [rfc3987]. SeeReferences andReferences and the‘defs’ element.
URL reference with fragment identifier
An Internationalized Resource Identifier [rfc3987] that can include an <absoluteURL> or <relativeURL> and a identifier of the fragment in that resource. SeeReferences and the‘defs’ element. URL reference with fragment identifiers are commonly used to referencepaint servers.
external file reference
AURL reference orURL reference with fragment identifier which refers to a resource that is not part of the current document.
same-document URL reference
AURL reference with fragment identifier where the non-fragment part of the URL refers to the current document.
data URL
AURL reference to an embedded document specified using the"data" URL scheme [rfc2397]. Data URL references are neitherexternal file references norsame-document URL references.
circular reference
URL references that directly or indirectly reference themselves are treated as invalid circular references. What constitutes a circular reference will depend on how the referenced resource is used, and may include a reference to an ancestor of the current element.
unresolved reference
A reference that is still being processed, and has not yet resulted in either an error or an identified resource.
invalid reference

Any of the following are invalid references:

  • A circular reference.
  • AURL reference that results in an error duringprocessing.
  • AURL reference that cannot be resolved.
  • AURL references to elements which are inappropriate targets for the given reference shall be treated as invalid references (seeValid URL targets for appropriate targets). For example, theclip-path property can only refer toclipPath elements. The property settingclip-path:url(#MyElement) is an invalid reference if the referenced element is not aclipPath.

Invalid references may or may not be an error (seeError processing), depending on whether the referencing property or attribute defines fallback behavior.

16.1.3. URLs and URIs

Internationalized Resource Identifiers (URLs) are a more generalizedcomplement to Uniform Resource Identifiers (URIs). AnURL is a sequenceof characters from the Universal Character Set [UNICODE].A URI is constructed from a much more restricted set of characters. All URIs arealready conformantURLs. A mapping fromURLs to URIs is defined bytheURL specification, which means that URLs can be used instead of URIsin XML documents, to identify resources.URLs can be converted to URIsfor resolution on a network, if the protocol does not supportURLsdirectly.

Previous versions of SVG, following XLink, defined an URL reference typeas a URIor as a sequence of characters which must result in an URL after aparticular escaping procedure was applied. The escaping procedure was repeated in theXLink 1.0 specification [xlink], and in theW3C XML Schema Part 2: Datatypes specification [xmlschema-2].This copying introduced the possibility of error and divergence, but was donebecause theURL specification was not yet standardized.

In this specification, the correct termURL is used for this "URI or sequence of charactersplus an algorithm" and the escaping method, which turns URLs into URIs, is defined by reference to theURL specification [rfc3987],which has since become an IETF Proposed Standard. Other W3C specifications areexpected to be revised over time to remove these duplicate descriptions of theescaping procedure and to refer toURL directly.

16.1.4. Syntactic forms: URL and <url>

In SVG, most structural relationships between two elementsare specified using a URL value in an‘href’ attribute.However, manypresentation attributes allow both URLs and text strings as content.To disambiguate a text string from a relative URL, the<url>production is used for presentation attributes,and their corresponding CSS properties [css-values].This is simply a URL delimited with a functional notation.

SVG makes extensive use ofURL references, both absolute and relative,to other objects.For example, alinearGradient elementmay be based on another gradient element,so that only the differences between the two need to be specified,by referencing the source gradient with a URL in thehref attribute:

<linearGradient>...</linearGradient><linearGradient                href="#SourceGradient">...</linearGradient>

To fill a rectangle with that gradient,the value of the rectangle'sfill property may be set so as toinclude a URL reference to the relevantlinearGradient element;here is an example:

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

16.1.5. URL reference attributes

URL references are normally specified with an‘href’ attribute.The value of this attribute forms a reference for the desired resource (orsecondary resource, if there is a fragment identifier).The value of the‘href’attribute must be a URL.

Because it is impractical for any application to check thata value is anURL reference, this specification follows the leadof theURL Specificationin this matter and imposes no such conformance testingrequirement onSVG authoring tools.An invalid URL does not make an SVG document non-conforming.SVG user agents are only required to process URLs when needed,as specified inProcessing of URL references.

16.1.6. Deprecated XLink URL reference attributes

In previous versions of SVG, the‘href’attribute was specified in the XLink namespace [xlink] namespace.This usage is now deprecated and insteadURL references should bespecified using the‘href’ attribute withouta namespace.

For backwards compatibility, the deprecatedxlink:href attributeis defined below along with thexlink:title attribute which has alsobeen deprecated.

Attribute definitions:

NameValueInitial valueAnimatable
xlink:hrefURL[URL](none)(see below)

For backwards compatibility, elements with an‘href’ attribute also recognize an‘href’ attribute in the XLink namespace [xlink].

When the‘href’ attribute is present inboth the XLink namespace and without a namespace, the value of the attribute without a namespace shall be used. The attribute in the XLink namespace shall be ignored.

Aconforming SVG generator must generate‘href’ attributes without a namespace. However, it mayalso generate‘href’ attributes in the XLink namespace to provide backwards compatibility.

This attribute isAnimatable if and only if the corresponding‘href’ attribute is defined to be animatable.

NameValueInitial valueAnimatable
xlink:title<anything>(none)no

Deprecated attribute to describe the meaning of a link or resource in a human-readable fashion. New content should use a‘title’ child element rather than a‘xlink: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.

The‘title’ attribute, if used, must be in the XLink namespace. Refer to theXML Linking Language (XLink) [xlink].

When using the deprecated XLink attributesxlink:href orxlink:title an explicit XLink namespace declaration must be provided[xml-names],One simple way to provide such an XLink namespace declarationis to include an‘xmlns’ attributefor the XLink namespace on thesvg element for content that usesXLink attributes. For example:

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

16.1.7. Processing of URL references

URLs are processed to identify a resource at the time they are needed, as follows:

Legacyxlink:href attributes are processed at the time a correspondinghref attribute would be processed, but only if no suchhref attribute exists on the element.

Processing a URL involves three steps: generating the absolute URL; fetching the document (if required); identifying the target element (if required).

A URL reference isunresolved until processing either results in aninvalid reference or in the identification of the target resource. Unresolved references in the non-presentation attributes ofstructurally external elements prevent theload event from firing. User agents may place time limits on the resolution of references that are notsame-document URL references, after which the reference is treated as a network error (and therefore as aninvalid reference).

Forsame-document URL references in a dynamic document, modifications or animations of attributes or properties, or removal of elements from the DOM, may cause an URL reference to return to theunresolved state. The user agent must once again attempt to resolve the URI to identify the referenced resource.

16.1.7.1. Generating the absolute URL

If theURL reference is relative, its absolute version must be computed before use.The absolute URL should be generated using one of the following methods:

The‘xml:base’ attribute will only have an effect in XML documents; this includes SVG documents and XHTML documents but not HTML documents that are not XML. In contrast, abase element affects relative URLs in any SVG or HTML document, by altering thedocument base URL.

If the protocol, such as HTTP, does not supportURLs directly,theURL must be converted to a URI by the user agent, as describedin section 3.1 of theURL specification [rfc3987].

After generating the absolute URL:

As defined inCSS Values and Units, a fragment-only URL in a style property must be treated as asame-document URL reference, regardless of the file in which the property was declared.

16.1.7.2. Fetching the document

SVG properties and attributes may reference other documents. When processing such a URL, the user agent should fetch the referenced document as described in this section, except under the following conditions:

When fetching external resources from the Internet, user agents must use apotentially CORS-enabled request as defined in HTML [HTML] with thecorsAttributeState as follows:

base

The request'sorigin is computed using thesame rules as HTML, with an SVGscript element treated like an HTMLscript element, and an SVGimage element treated like an HTMLimg element. Thedefault origin behaviour must be set totaint.

A future SVG specification may enable CORS references on other SVG elements withhref attributes.

If the fetching algorithm results in an error or an empty response body, the reference URL is treated as aninvalid reference.

If a valid response is returned, and thevalid URL targets for the reference include specific element types, the user agent must continue byProcessing the subresource document. Otherwise (if only entire-document the URL references are valid), then the fetched document is the referenced resource.

16.1.7.3. Processing the subresource document

Otherwise, the subresource must be parsed to identify the target element. If the fetched document is a type that the user agent can parse to create a document object model, it must process it insecure static mode (meaning, do not fetch any additional external resources and do not run scripts or play animations or video). The document model generated for an external subresource reference must be immutable (read-only) and cannot be modified.

If a document object model can be generated from the fetched file, processing the URL must continue as indicated inIdentifying the target element with the parsed subresource document as the referenced document. The user agent may commence the target-identification process prior to completely parsing the document.

User agents may maintain a list of external resource URLs and their associated parsed documents, and may re-use the documents for subsequent references, so long as doing so does not violate the processing mode, caching, and CORS requirements on the resource.

16.1.7.4. Identifying the target element

For URL references to a specific element, whether the reference is valid depends on whether the element can be located within the referenced document and whether it is of an allowed type.

Using the referenced document identified in previous processing steps (either an external subresource document or the current document), the target element is identified as follows:

The target element provides the referenced resource if (and only if) it is avalid URL target for the reference.

16.1.7.5. Valid URL targets

The valid target element types forhref (orxlink:href) attributes are based on the element that has the attribute, as follows:

The valid target element types for style properties defined in this specification are as follows:

For references that allow either a reference to a target element, or to an image file (such as theshape-inside,shape-subtract, andmask properties), the user agent must identify the target element and determine whether it is a valid target. If the resolved target element is not an allowed element type, the referenced resource is the entire document file; the target fragment is used in processing that file as with any other image.

In all other cases, if the resolved target element type (or document type) is not allowed for the URL reference, it is aninvalid reference.

16.2. Links out of SVG content: the‘a’ element

SVG provides ana element, to indicate links (also knownashyperlinks orWeb links).Ana element forms a link if it has ahref orxlink:href attribute; without these attributes thea element is an inactive placeholder for a link.

SVG 1.1 defined links in terms of the XLink specification ([XLink]),using attributes defined in the XLink namespace.SVG 2 uses an alternative set of attributes in the default namespace that are consistent with HTML links, anddeprecates the XLink attributes.

Thea element maycontain any element that its parent may contain, except for anothera element;the same element is used for both graphical and textual linked content.Links may not be nested;if ana element is a descendent of another hyperlink element(whether in the SVG namespace or another namespace),user agents must ignore its href attribute and treat it as inactive.The invalida element must still be rendered as a generic container element.

The rendering of invalid nested links is at risk, and will likely be synchronized with any decisions regarding the rendering ofunknown elements.

For pointer events processing,a linked hit region is defined for each separate rendered element containedwithin thea element (according to the value of theirpointer-events property),rather than for the bounding box of thea element itself.User agents must also ensure that all links arefocusable and can be activated by keyboard commands.

The remote resource (the destination for the link) is defined byaURL specified by thehref attribute on theaelement. The remote resource may be any Web resource (e.g., an image, a videoclip, a sound bite, a program, another SVG document, an HTML document, anelement within the current document, an element within a different document, etc.).In response to user activation of a link(by clicking with the mouse, through keyboard input, voice commands, etc.),user agents should attempt to fetch the specified resource document and either display it or make it available as a downloaded file.

Example link01 assignsa link to an ellipse.

<?xml version="1.0" standalone="no"?><svg width="5cm" height="3cm" viewBox="0 0 5 3" version="1.1"     xmlns="http://www.w3.org/2000/svg">  <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 href="http://www.w3.org">    <ellipse cx="2.5" cy="1.5" rx="2" ry="1"             fill="red" />  </a></svg>
Example link01 — a link on an ellipse

Example link01

View this example as SVG (SVG-enabled browsers only)

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

a
Categories:
Container element,renderable element
Content model:
Descriptive content, plus any element or text allowed by its parent's content model, except for another a element. If the parent is a switch element, use the content model of the nearest ancestor that isn't a switch.
Attributes:
DOM Interfaces:

Attribute definitions:

NameValueInitial valueAnimatable
hrefURL[URL](none)yes
The location of the referenced object, expressed as anURL reference. Refer to the common handling defined forURL reference attributes.
NameValueInitial valueAnimatable
target _self | _parent | _top | _blank | <XML-Name>_selfyes

This attribute should be used when there are multiple possible targets for the ending resource, such as when the parent document is embedded within an HTML or XHTML document, or is viewed with a tabbed browser. This attribute specifies the name of the browsing context (e.g., a browser tab or an SVG, HTML, or XHTML iframe or object element) into which a document is to be opened when the link is activated:

_self
The current SVG image is replaced by the linked content in the same browsing context as the current SVG image.
_parent
The immediate parent browsing context of the SVG image is replaced by the linked content, if it exists and can be securely accessed from this document.
_top
The content of the full active window or tab is replaced by the linked content, if it exists and can be securely accessed from this document
_blank
A new un-named window or tab is requested for the display of the linked content, if this document can securely do so. If the user agent does not support multiple windows/tabs, the result is the same as_top.
<XML-Name>
Specifies the name of the browsing context (tab, inline frame, object, etc.) for display of the linked content. If a context with this name already exists, and can be securely accessed from this document, 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). The name must be a valid XML Name [XML11], and should not start with an underscore (U+005F LOW LINE character), to meet the requirements of avalid browsing context name from HTML.

The normative definitions for browsing contexts and security restrictions on navigation actions between browsing contexts is HTML [HTML], specificallythe chapter on loading web pages.

Previous versions of SVG defined the special target value'_replace'. It was never well implemented, and the distinction between'_replace' and'_self' has been made redundant by changes in the HTML definition of browsing contexts. Use'_self' to replace the current SVG document.

The value'_new' isnot a legal value for target. Use'_blank' to open a document in a new tab/window.

NameValueInitial valueAnimatable
downloadany value (if non-empty, value represents a suggested file name)(none)no
pingspace-separated valid non-empty URL tokens[HTML](none)no
relspace-separated keyword tokens[HTML](none)no
hreflangA BCP 47 language tag string[HTML](none)no
typeA MIME type string[HTML](none)no
referrerPolicyA referrer policy string[REFERRERPOLICY](none)no
These attributes further describe the targetted resource and its relationship to the current document. Allowed values and meaning areas defined for thea element in HTML.

16.3. Linking into SVG content: URL fragments and SVG views

Because SVG content often represents a picture or drawingof something, a common need is to link into a particularview of the document, where a view indicatesthe initial transformations so as to present a closeup of a particularsection of the document.

16.3.1. SVG fragment identifiers

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 have media fragment identifiers.
Purpose:To align with Media Fragments URI.
Owner:Cyril (ACTION-3442)

To link into a particular view of an SVG document, theURL reference with fragmentidentifier needs to be a correctly formedSVGfragment identifier. An SVG fragment identifier defines themeaning of the "selector" or "fragment identifier" portion of URLs thatlocate resources of MIME media type "image/svg+xml".

An SVG fragment identifier can come in the following forms:

16.3.2. SVG fragment identifiers definitions

An SVG fragment identifier is defined as follows:

SVGFragmentIdentifier ::= BareName *( "&"timesegment ) |                          SVGViewSpec *( "&"timesegment ) |spacesegment *( "&" timesegment ) |timesegment *( "&" spacesegment )BareName ::= XML_NameSVGViewSpec ::= 'svgView(' SVGViewAttributes ')'SVGViewAttributes ::= SVGViewAttribute |                      SVGViewAttribute ';' SVGViewAttributesSVGViewAttribute ::= viewBoxSpec |                     preserveAspectRatioSpec |                     transformSpec |                     zoomAndPanSpecviewBoxSpec ::= 'viewBox(' ViewBoxParams ')'preserveAspectRatioSpec = 'preserveAspectRatio(' AspectParams ')'transformSpec ::= 'transform(' TransformParams ')'zoomAndPanSpec ::= 'zoomAndPan(' ZoomAndPanParams ')'

where:

SVG view box parameters are applied in order, as defined inCSS Transforms specification (e.g. SVG view is transformed as defined inViewBoxParams,then as defined inTransformParams).

Spaces are allowed in fragment specifications. Commasare 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))).

Fragment identifiers may be url-escaped according to the rules defined inCSS Object Model (CSSOM) specification. For example semicolons can be escaped as %3B to allow animating a (semi-colon separated) list of URLs because otherwise the semicolon would be interpreted as a list separator.

The four types ofSVGViewAttribute may occurin any order, but each type may only occur at most one time in a correctlyformedSVGViewSpec.

When a source document performs a link into an SVG document, for examplevia anHTML anchor element([HTML]; i.e.,<a href=...> element in HTML) or anXLink specification [xlink], thenthe SVG fragment identifier specifies the initial view into the SVG document,as follows:

16.3.3. Predefined views: the‘view’ element

The‘view’ element is defined as follows:

view
Categories:
None
Content model:
Any number of the following elements, in any order:script,style
Attributes:
DOM Interfaces:

We have resolved to remove viewTarget attribute.

Resolution: Paris 2015 F2F Day 3.

Owner: BogdanBrinza.

16.4. DOM interfaces

16.4.1. Interface SVGAElement

AnSVGElement object represents ana element in the DOM.

[Exposed=Window]interfaceSVGAElement :SVGGraphicsElement {  [SameObject] readonly attributeSVGAnimatedStringtarget;  attribute DOMStringdownload;  attribute USVStringping;  attribute DOMStringrel;  [SameObject, PutsForward=value] readonly attributeDOMTokenListrelList;  attribute DOMStringhreflang;  attribute DOMStringtype;  attribute DOMStringtext;  attribute DOMStringreferrerPolicy;};SVGAElement includesSVGURIReference;SVGAElement includesHTMLHyperlinkElementUtils;

Thetarget,download,ping,rel,hreflang,type, IDL attributesreflect the content attributes of the same name.

TherelList IDL attributereflects therel content attribute.

ThereferrerPolicy IDL attributereflects thereferrerpolicy content attribute,limited to only known values.

Thetext IDL attribute, on getting, must return the same value as thetextContent IDL attribute on the element, and on setting, must act as if thetextContent IDL attribute on the element had been set to the new value.

16.4.2. Interface SVGViewElement

AnSVGViewElement object represents aview element in the DOM.

[Exposed=Window]interfaceSVGViewElement :SVGElement {};SVGViewElement includesSVGFitToViewBox;SVGViewElement includesSVGZoomAndPan;

[8]ページ先頭

©2009-2025 Movatter.jp