Copyright © 2004 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark, document use and software licensing rules apply.
This specification defines a simple mechanism to visually and logically connect two elements, as for an abstract graph. It introduces new elements, connector and point, and describes both the appearance and behavior of these elements, specifically in terms of rendering and navigation.
Although originally designed for use in SVG, some aspects of this specification are defined in XML and are accessed via presentation properties, and therefore could be used in other environments, such as HTML styled with CSS and XSL:FO. This module is intended for implementation by SVG 1.1 or SVG Tiny 1.2 user agents as a compatible extension of those specifications, and will be incorporated into the SVG 2.0 specification.
This document defines the markup used by SVG Connector. There is an accompanying primer document that lists the ways SVG Connector may be used.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. The latest status of this document series is maintained at the W3C.
Warning! This specification is still a proposal in early Editor's Draft state, and is not yet ready for public comments. Subsequent drafts will include contact information for review comments.
There is an accompanying SVG Connector 1.0, Part 1: Primer that lists the ways SVG Connector may be used.
This document has been produced by the W3C SVG Working Group as part of the W3C Graphics Activity within the Interaction Domain.
The latest information regarding patent disclosures related to this document is available on the Web. As of this publication, the SVG Working Group are not aware of any royalty-bearing patents they believe to be essential to SVG.
Publication of this document does not imply endorsement by the W3C membership. A list of current W3C Recommendations and other technical documents can be found at http://www.w3.org/TR/. W3C publications may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to cite a W3C Working Draft as anything other than a work in progress.
This draft of SVG Connector introduces new Connector syntax and markup for the SVG language. One of the goals is that this specification can be re-used more easily by other specifications that want to have advanced Connector features. This specification introduces syntax that may not be backwards compatible with older SVG User Agents, and the use of this syntax should be accompanied by a fallback using the 'switch' element.
The main purpose of this document is to encourage public feedback. The best way to give feedback is by sending an email to www-svg@w3.org. Please include some kind of keyword that identifies the area of the specification the comment is referring to in the subject line of your message (e.g "Section X.Y - Foo attribute values" or "Connector Functionality"). If you have comments on multiple areas of this document, then it is probably best to split those comments into multiple messages.
The public are welcome to comment on any aspect in this document, but there are a few areas in which the SVG Working Group are explicitly requesting feedback. These areas are noted in place within this document. There is also a specific area related to the specification that is listed here:
This specification defines a simple mechanism to visually and logically connect two elements, for such use cases as flow charts, circuit diagrams, org charts, or any kind of node-edge graph. It includes the ability to automatically draw and update the connector line as a straight line along the shortest path between the elements, or to allow the shape of the connector to be defined using the syntax of the path element. It also introduces the point element, which may be used as a connection point within shape definitions or a routing point for the connector element.
This specification also describes the manner in which the connector element establishes an implicit navigation relationship between connected elements.
Finally, this specification defines several new values for the role
attribute and provides guidance for other use of metadata, to facilitate transformation to and from graph description languages.
Note that even though this specification references parts of SVG 1.1 and SVG Tiny 1.2 it does not require a complete implementation of those specifications.
This document is normative, except where otherwise indicated.
This document contains explicit conformance criteria that overlap with some RNG definitions in requirements. If there is any conflict between the two, the explicit conformance criteria are the definitive reference.
This specification concentrates on the visual and behavioral treatment of graphs and graph-like features, rather than the semantic or topological characteristics of graphs. It is not within the scope of this specification to provide any automatic graph layout algorithms, or any edge routing beyond the simple cases described in the algorithm found in Automatic Connector Rendering. Other specifications may define advanced SVG layout which can be used with this specification, and future versions of this specification may provide more powerful edge routing, contingent on feedback from authors and implementers.
While the title
and desc
elements allow human-readable text descriptions of edges and nodes, there is no special facility in this specification for the visual labeling of nodes and edges, either in semantic terms or positionally. Textul elements, including the textPath
elements, may be used instead.
This specification does not define a generic graph description language, though most common features of graphs can be represented using this functionality. Instead, it defines the appearance and behavior of concepts found in many graph formats, which may also be used in a non-graph and quasi-graph manner.
There are minimal semantics defined for expressing complex features of graphs, with no formal treatment of hyperedges, hierarchical graphs, or nested graphs, and no provision to express graph characteristics such as planarity, connectedness, completeness, or Euler or Hamiltonian paths or circuits. However, the native SVG metadata features described in SVG Tiny 1.2, in combination with such metadata formats as RDFa, may be used to express more complex relationships.
The connectors, points, and metadata features of SVG are designed to allow easy transformation to and from graph definition and exchange languages, including:
Below is an example of a purely semantic graph, stripped of any specific graphical representation. Note that because the empty 'g'
elements do not render and have no positional characteristics, the 'connector'
elements will not render; if these groups were filled with shapes, however, a conforming user agent would draw would draw lines between the centroids of those shapes. The use of SVG as a purely semantic graph description exchange format is strongly discouraged, since users expect to see visual output when viewing an SVG file; all SVG files should include graphical content, even if that content is only 'circle'
or 'text'
elements.
<svg xmlns="http://www.w3.org/2000/svg" role="graph" directed="false">
<title>K3,3 Graph</title>
<desc>
The famous non-planar basic graph: a complete bipartite graph of six vertices,
three of which connect to each of the other three
</desc>
<g role="node" id="n-1" />
<g role="node" id="n-2" />
<g role="node" id="n-3" />
<g role="node" id="n-4" />
<g role="node" id="n-5" />
<g role="node" id="n-6" />
<connector role="edge" n1="#n-1" n2="#n-4" />
<connector role="edge" n1="#n-1" n2="#n-5" />
<connector role="edge" n1="#n-1" n2="#n-6" />
<connector role="edge" n1="#n-2" n2="#n-4" />
<connector role="edge" n1="#n-2" n2="#n-5" />
<connector role="edge" n1="#n-2" n2="#n-6" />
<connector role="edge" n1="#n-3" n2="#n-4" />
<connector role="edge" n1="#n-3" n2="#n-5" />
<connector role="edge" n1="#n-3" n2="#n-6" />
</svg>
Connectors may be used in many applications, not all of which are necessarily intuitive:
The following stylistic conventions are followed in this specification:
'This is a keyword or value'
This is a link to a definition in the glossary
This is a note.
This is a warning. It is used on security notes.
This is an example.
This is a feature at risk, which is likely to be removed from the specification.
This is a proposed new feature.
@@ This is an open issue.
Feedback on features at risk, new features, and open issues is especially appreciated.
In addition, certain terms are used in this specification with particular meanings. The term "implementation" applies to a browser, authoring tool, or other user agent that implements this specification, while an author is a person who writes script or code that takes advantage of the interfaces, methods, attributes, events, and other features described in this specification in order to make Web applications, and a user is the person who uses those Web applications in an implementation.
Within this specification, the key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" are to be interpreted as described in RFC 2119 [RFC2119]. However, for readability, these words do not necessarily appear in uppercase in this specification.
The role
attribute may be used to provide additional semantics to an element, particularly for use in converting or transforming from SVG into another graph format. This specification defines several new role values to allow explicit notation of elements for ease of metadata transformations and analysis, but the use of these role values is not necessary for connector functionality. Note: This specification does not define any specific functionality for these role values in the SVG context.
graph
This role value indicates that the container element is the root of a graph. A graph in this sense is an abstract mathematical representation of a set of objects in which some pairs of the objects (nodes) may be connected by links (edges).
An element with this role attribute value which is the child of another element with the graph
role attribute value must be interpreted as a nested graph (also referred to as a sub-graph). A document with nested graphs is referred to a hierarchical graph.
node
This role value indicates that the element is a node (or vertex or point) of a graph. A graph node represents an object, which is normally connected to another object by an edge; it may also be thought of as the point at which two or more edges meet or intersect.
In the case of elements joined by connector
elements, the node role may be inferred, but elements intended to be nodes which are not referents of a connector
element may not enjoy the same role inference, especially in scenarios where graph content is mixed with other graphical content, such as UI controls.
Note that an element with the node
role value may also have the graph
role value, if it is a container element which contains a nested graph.
edge
This role value indicates that the element is an edge (or line or arc) of a graph. An edge is a link between two objects (nodes) in a graph. An arc is specifically a directed edge.
A connector
element may be implicitly assumed to be a edge. The edge
role indicates a link between two nodes only; for an edge which connects more than two nodes, the hyperedge
role value should be used.
port
This role value indicates that the element is a port on a node of a graph. A port is a logical or positional point of connection within a node. For a flowchart, this may be the midpoint of a polygon side or the corners of a shape, and for a circuit, this may be an input or output socket or the legs on a chip. One node
may have many port
s defined, with different positions and characteristics.
A point
element as a child of a node
element (that is, an element with a role attribute value of node
or a referent of a connector
element) may be implicitly assumed to be a port.
When used with other, more specific supplementary roles (not defined in this specification), a the role of a port
may be used to determine which of several ports a connector
element will join to; see the definitions for connector
and point
elements, and Automatic Connector Rendering.
hyperedge
This role value indicates that the element is an edge of a graph which joins multiple nodes. An edge is a link between three or more objects (nodes) in a graph. For an edge which connects only two nodes, the edge
role value should be used.
SVG does not define any behavior for hyperedges, nor any semantic means to relate one connector
element with this role value to another as a multi-segment hyperedge; other roles or classes, or other forms of metadata, may be used for this purpose as appropriate.
Connectors represent a visual or logical connection between two elements, which may be styled with a stroke to illustrate the connection between elements, or hidden and used only for its navigational or logical aspects. In terms of graph theory, the target elements are vertices and connector elements are edges.
The outline of a connector may be styled in the same manner as the path element, but unlike the path element, a connector must not be filled, even in the case where it defines a closed shape. The stroking effects are defined in Filling, Stroking and Paint Servers in SVG Tiny 1.2.
A connector is either described using the explicit syntax of the path element, or is generated automatically using the implicit relationship between the indicated elements as modified by any child point elements of the connector element or of the target shapes.
This section describes the syntax and behavior for SVG connectors. Various implementation notes for SVG connectors can be found in 'connector' element implementation notes.
A connector is defined in SVG using the 'connector' element.
<define name='connector'> <element name='connector'> <ref name='connector.AT'/> <zeroOrMore><ref name='shapeCommon.CM'/></zeroOrMore> </element> </define> <define name='connector.AT' combine='interleave'> <ref name='svg.N1N2.attr'/> <ref name='svg.ShapeCommon.attr'/> <ref name='svg.D.attr'/> <optional> <ref name='svg.Directed.attr'/> <ref name='svg.N1portN2port.attr'/> <attribute name='connectorLength' svg:animatable='true' svg:inheritable='false'> <ref name='Number.datatype'/> </attribute> </optional> </define>
Attribute definitions:
An IRI reference to an element within an SVG document, which represents the visual and semantic starting point of a connection. An invalid IRI reference is an unsupported value. An empty attribute value (n1="") disables rendering of the element. The lacuna value is the empty string.
Animatable: yes.
An IRI reference to an element within an SVG document, which represents the visual and semantic ending point of a connection. An invalid IRI reference is an unsupported value. An empty attribute value (n2="") disables rendering of the element. The lacuna value is the empty string.
Animatable: yes.
An indicator for selecting a point
element which is a child of the element indicated in the n1 attribute, as either an IRI reference to an id
attribute value, or a string corresponding to a role
attribute value. If an appropriate point
element exists which matches the value of this attribute, that point shall serve as a candidate for the terminus of the connector stroke for that target element, in a manner described in the Automatic Connector Rendering algorithm. If this attribute is omitted, or if it does not match the value of an id
or role
attribute which is a child of the target element, the terminus of the connector stroke for that target element must be the centroid. The lacuna value is the empty string.
Animatable: yes.
An indicator for selecting a point
element which is a child of the element indicated in the n2 attribute, as either an IRI reference to an id
attribute value, or a string corresponding to a role
attribute value. If an appropriate point
element exists which matches the value of this attribute, that point shall serve as a candidate for the terminus of the connector stroke for that target element, in a manner described in the Automatic Connector Rendering algorithm. If this attribute is omitted, or if it does not match the value of an id
or role
attribute which is a child of the target element, the terminus of the connector stroke for that target element must be the centroid. The lacuna value is the empty string.
Animatable: yes.
A boolean value for indicating whether the connector is directed, i.e. whether it is a one-way connection. If the value of this attribute is "true", then . Note that the value of this attribute does not automatically render an arrow or directional indicator on the connector
element; the author must still provide a suitable graphical shape with the right positioning and orientation properties and apply it to the connector
element via the marker-end
property. The lacuna value is "false".
Animatable: yes.
The definition of the stroke of a connector. See Connector data. An empty attribute value (d="") or missing attribute automates the rendering of the element according to the algorithm in Automatic Connector Rendering. The lacuna value is the empty string.
Animatable: yes, but see restrictions described in Animating connector data.
The authoring length of the connector, in user units. This value is used to calibrate the user agent's own distance-along-a-path calculations with that of the author. The user agent shall scale all distance-along-a-path computations by the ratio of 'pathLength' to the user agent's own computed value for total connector length. 'pathLength' potentially affects calculations for motion animation and various stroke operations.
A negative value is an unsupported value.
Animatable: yes.
See attribute definition for description.
Animatable: yes.
See definition.
When the d attribute is not specified, the user agent must render the connector element as a line of one or more segments between the elements indicated by the n1 and n2 attributes, passing through the point element children of the connector element in document order, and with the terminus of each end of the connector at the appropriate point of the target elements.
The target elements of a connector are those elements indicated by the n1 and n2 attributes of the connector element. By default, an automatically-generated connector terminates at the centroid of a target element. Markers on the connector, such as arrowheads, may be obscured by the target element if the target element is later in document order than the connector; authors may generically position markers along the connector using the marker element's refX and refX attributes to prevent them from being obscured, though this may leave artifacts of the connector stroke between the end of the marker and the target element.
A more sophisticated and visually clear method for indicating the terminus of the connector is to provide connection points on the target shape in the form of point elements. One or more point elements may be declared as child nodes of the target elements; point child elements are used by the user agent as Each of these point elements may have an id attribute and role attribute which can be used to
'none'
, the element is not rendered. Note that the logical connection established by the element still exists, and must be exposed to the user as a navigation option, described below.'none'
. Automatic rendering must not be done, even if the connector does not intersect with one or either of the target elements.@@ describe what happens for 'use' elements with child 'point' elements
@@ provide an API to get the start and end points (coordinates and point element) of the automatic connector?
@@ add '@r' or '@attraction' to the 'point' element for use in rounded corners on connectors?
@@ add '@autoclip' to marker to trim the stroke past the end of the marker?
Interpolated connector data animation is only possible when each normalized connector data specification within an animation specification has exactly the same list of connector data commands as the 'd' attribute after normalization. This means that each connector data specification and the 'd' attribute would have the exact same list of commands if normalized as defined in Connector Normalization. If an animation is specified and the list of connector data commands is not the same, then the animation specification must be ignored as unsupported. The animation engine shall interpolate each parameter to each connector data command separately based upon the attributes on the given animation element.
Non-interpolated (i.e. calcMode="discrete") connector data animation is always possible.
A connector is defined by including a 'connector' element which contains a 'd' attribute, where the 'd' attribute contains the moveto, line, curve (both cubic and quadratic Béziers) and closeconnector instructions.
Warning! This section is a placeholder for reference, and is not part of the connectors spec.
When a 'use' references another element which is another 'use' or whose content contains a 'use' element, then the deep cloning approach described above is recursive. However, a set of references that directly or indirectly reference a element to create a circular dependency is an error, as described in the References section.
<define name='use'> <element name='use'> <ref name='use.AT'/> <ref name='use.CM'/> </element> </define> <define name='use.AT' combine='interleave'> <ref name='svg.Properties.attr'/> <ref name='svg.FocusHighlight.attr'/> <ref name='svg.Core.attr'/> <ref name='svg.Conditional.attr'/> <ref name='svg.Transform.attr'/> <ref name='svg.XLinkEmbed.attr'/> <ref name='svg.Focus.attr'/> <ref name='svg.External.attr'/> <ref name='svg.XY.attr'/> </define> <define name='use.CM'> <zeroOrMore> <choice> <ref name='svg.Desc.group'/> <ref name='svg.Animate.group'/> <ref name='svg.Handler.group'/> </choice> </zeroOrMore> </define>
Attribute definitions:
The x-axis coordinate of one corner of the rectangular region into which the referenced element is placed.
The lacuna value is '0'.
Animatable: yes.
The y-axis coordinate of one corner of the rectangular region into which the referenced element is placed.
The lacuna value is '0'.
Animatable: yes.
An IRI reference to an element/fragment within an SVG document. An invalid IRI reference is an unsupported value. An empty attribute value (xlink:href="") disables rendering of the element. The lacuna value is the empty string.
Animatable: yes.
See attribute definition for description.
Animatable: yes.
See definition.
The 'point' element defines a point based on a vertical and a horizontal coordinate, within the current user coordinate system.
The 'point' element simply defines a mathematical point, without width or height, and thus does not itself render, regardless of any styling applied to it. However, if the ‘marker’ property is specified on the 'point' element, the marker will render, and will be affected by any styling applied to the 'point' element, if applicable. For example, if the ‘marker’ element indicated by the ‘marker’ property has a ‘markerUnits’ attribute value of 'strokeWidth', the value of the ‘stroke-width’ attribute on the 'point' element will affect the rendering of the marker as if it were also applied to the 'point' element. @@ should we allow the author to control the orientation, as well? Should it be yoked to the orientation at the same point on the parent shape (I think this is too complicated)?
This element is intended to serve as a reference point for calculations, orientation, or animations, or for use in direct conjunction with other elements. It may be declared as a child of any other element, or directly in the root. When declared as a child of a rendering element, any marker instances for the 'point' element will be drawn on top of the parent element, in document order.
In the context of the connector element, as described in
<define name='point'> <element name='point'> <ref name='point.AT'/> <zeroOrMore><ref name='shapeCommon.CM'/></zeroOrMore> </element> </define> <define name='point.AT' combine='interleave'> <ref name='svg.ShapeCommon.attr'/> <ref name='svg.XY.attr'/> </define>
Attribute definitions:
The x-axis coordinate of the point. The lacuna value is '0'.
Animatable: yes.
The y-axis coordinate of the point. The lacuna value is '0'.
Animatable: yes.
See attribute definition for description.
Animatable: yes.
See definition.
Example point01 consists of a 'point' element which is a child of another element, and styled with a marker.
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0 200 150"> <title>Point Marker</title> <desc>Example point01: An illustration of a marker on a 'point' element which is a child of another element.</desc> <defs> <marker id="dot" viewBox="0 0 10 10" refX="5" refY="5" markerUnits="strokeWidth" markerWidth="5" markerHeight="5" orient="auto"> <circle cx="5" cy="5" r="2.5" fill="cornflowerblue" stroke="blue" /> </marker> </defs> <polygon id="decision" points="100,50 150,75 100,100 50,75" stroke="black" fill="gray"> <point x="100" y="50" stroke-width="2" marker="url(#dot)"/> </polygon> </svg>
The schema for SVG Connector 1.0 is written in RelaxNG [RelaxNG], a namespace-aware schema language that uses the datatypes from XML Schema Part 2 [Schema2]. This allows namespaces and modularity to be much more naturally expressed than using DTD syntax. The RelaxNG schema for SVG Filter 1.2 may be imported by other RelaxNG schemas, or combined with other schemas in other languages into a multi-namespace, multi-grammar schema using Namespace-based Validation Dispatching Language [NVDL].
Unlike a DTD, the schema used for validation is not hardcoded into the document instance. There is no equivalent to the DOCTYPE declaration. Simply point your editor or other validation tool to the IRI of the schema (or your local cached copy, as you prefer).
The RNG is under construction, and only the individual RNG snippets are available at this time. They have not yet been integrated into a functional schema. The individual RNG files are available here.
The following interfaces are defined below: RandomInterface.
The RandomInterface interface corresponds to the 'RandomInterface' element.
interface RandomInterface : SVGElement { readonly attribute InterfaceString foo; };
The editors would like to acknowledge and thank the following people for substantive aid with this specification: Andrew Shellshear, David Dailey, Cyril Concolato, Erik Dahlström, Jonathan Watt, Anthony Grasso, Chris Lilley.