Writer Directives

The directives listed below are processed by the SVG writer. The suffixes shown are prefixed by the current <WriterKeyword> in a mapping file. By default, the <WriterKeyword> for the SVG writer is SVG.

DATASET

Required/Optional: Required

The value for this keyword is the pathname for the output SVG file. If a file with this pathname already exists, then it will be overwritten. A typical mapping file fragment specifying an output SVG dataset looks like:

SVG_DATASET /tmp/outputFile.svg

If the output filename’s extension is svgz, then the output document will be compressed using gzip compression.

Note that all SVG documents are written using UTF-8 encoding.

Workbench Parameter: Destination SVG File

TEMPLATE

Required/Optional: Optional

This optional parameter directs the writer to the location of the SVG document to use as the outline of the output dataset.

The syntax for this keyword’s value is:

<WriterKeyword>_TEMPLATE <value>

(where <value> is location of the template path)

If this keyword is not provided in the mapping file, then the file named defaultTemplate.svg under the svg folder in the FME home folder is used.

The template document has several uses including: the insertion of predefined geometric elements, the inclusion of Cascading Style Sheets, and the embedding of scripting information. There are a few issues that must be considered to ensure proper template processing. The template must conform to the non-extended SVG language defined by the SVG 1.1 specification. The encoding of the template must be one of the following: ASCII, UTF-8, UTF-16, UCS4, ISO-8859-1 or Windows-1252. Note that the encoding of the output SVG document is always UTF-8. Any document type declaration provided in the template will be overridden in the output document.

Two placeholder macros have been defined for use in the SVG template in order to retrieve information specified in other keywords:

  • $(FME_SVG_ATTR_NS_PREFIX) will be replaced with the value of the ATTR_NAMESPACE_PREFIX keyword, and
  • $(FME_SVG_ATTR_NS_URI) will be replaced with the value of the ATTR_NAMESPACE_URI keyword.

These macros will only work inside CDATA sections (<![CDATA[...]]>) of the SVG template. If they are found outside a CDATA section, they will remain unchanged.

Workbench Parameter: Template File

COORDINATE PRECISION

Required/Optional: Optional

This optional parameter specifies the number of decimal digits to use when writing an SVG element coordinate’s value. The default is 6. Specifying a larger value increases coordinate precision and may increase rendering precision.

Workbench Parameter: Precision

NORMALIZE

Required/Optional: Optional

This optional parameter will normalize the lower coordinate bounds of the writer’s feature set to (0,0). Normalization can reduce rendering inaccuracies by SVG viewers with small coordinate precision capability. A normalized document’s file size is typically smaller than a non-normalized version.

Workbench Parameter: Normalize

DEF

Required/Optional: Optional

The syntax for DEF is:

<WriterKeyword>_DEF  <FeatureType>
	SVG_PAINT_ORDER	 [0-9]+
	SVG_LAYER_STYLE string
		<UserAttributeName0> char([0-9]+)
		...
		<UserAttributeNameN> char([0-9]+)

The SVG_PAINT_ORDER parameter on a DEF line is used to determine the order of feature output. Features in layers that have a higher value for this parameter will be output last. Following SVG’s “painter” algorithm, features that are in layers with higher values will be painted last when the SVG document is rendered.

The SVG_LAYER_STYLE parameter on a DEF line is used to specify the value to set the layer’s STYLE attribute in the output layer group.

The user attribute keywords specify which FME attributes to extract from an incoming FME feature. The extracted FME attributes are embedded in the geometric element’s attribute list.

If there are no user attribute DEF line parameters specified, then no FME user attributes will be inserted in any SVG element’s attribute list, and no SVG DTD extension is produced.

ABSOLUTE_COORDINATES

Required/Optional: Optional

Allows absolute instead of relative coordinates to be used for lines and polygons that are written out as <path> elements. The valid values for this keyword are Yes and No; its default value is No.

Workbench Parameter: Use absolute Coordinate

WHITE_STROKES_TO_BLACK

Required/Optional: Optional

Determines whether the SVG writer should automatically switch white fme_color specifications into black. This directive does not affect the svg_color (that is, the svg_color attribute takes precedence over the fme_color). The valid values for this keyword are Yes and No; its default value is Yes.

Workbench Parameter: Automatically turn white strokes into black

DOCTYPE_EXTERNAL

Required/Optional: Optional

Determines if the SVG file depends on an external SVG DTD. The valid values for this keyword are Yes (default value) and No. When set to Yes the document type declaration’s public and system identifier for SVG 1.1 are used by default, but these default identifiers can also be overwritten with the DOCTYPE_PUBLIC_ID and DOCTYPE_SYSTEM_ID keywords.

Workbench Parameter: Reference external SVG DTD

DOCTYPE_PUBLIC_ID

Required/Optional: Optional

This keyword only applies when the DOCTYPE_EXTERNAL keyword is set to Yes. It specifies the public identifier for the document type declaration. This keyword must be used in conjunction with the DOCTYPE_SYSTEM_ID keyword, that is, a system identifier must also be simultaneously specified; otherwise, this keyword has no effect.

Workbench Parameter: DOCTYPE public identifier

DOCTYPE_SYSTEM_ID

Required/Optional: Optional

This keyword only applies when the DOCTYPE_EXTERNAL keyword is set to Yes. It specifies the system identifier for the document type declaration. This keyword can be used alone or in conjunction with the DOCTYPE_SYSTEM_ID keyword.

Workbench Parameter: DOCTYPE system identifier

ATTR_NAMESPACE_PREFIX

Required/Optional: Optional

This directive specifies the prefix which will be used to identify the namespace of all user attributes in the SVG document.

Each user attribute written to the SVG file will be written as an XML attribute with the format namespace_prefix:user_attr = “value”.

The default namespace prefix is “fme”.

Workbench Parameter: Attributes Namespace Prefix

ATTR_NAMESPACE_URI

Required/Optional: Optional

This directive specifies the URI with which the namespace prefix (specified by ATTR_NAMESPACE_PREFIX) will be associated. This will be the namespace URI for all user attributes in the SVG document. (Note that the writer does not check if this is a valid URI that complies with XML standards.)

The namespace will be defined as follows, where namespace_prefix is the value defined by ATTR_NAMESPACE_PREFIX and namespace_uri is defined by xmlns:namespace_prefix=“namespace_uri”

The default value is “http://www.safe.com/fme”

Workbench Parameter: Attributes Namespace URI

VIEWBOX_MINX, VIEWBOX_MINY, VIEWBOX_WIDTH, VIEWBOX_HEIGHT

Required/Optional: Optional

These directives allow the user to set viewbox size when writing to SVG format. By default, the viewbox is not available. Only when the user has set all four parameters (listed below), the viewbox will be displayed.

Syntax for the values is:

<WriterKeyword>_VIEWBOX_MINX<value>
<WriterKeyword>_VIEWBOX_MINY<value>
<WriterKeyword>_VIEWBOX_WIDTH<value>
<WriterKeyword>_VIEWBOX_HEIGHT<value>

All values must be specified in decimal, integer or scientific notation.

Workbench Parameter

Viewbox - Min x, Viewbox - Min y, Viewbox - Width, Viewbox - Height