Feature Representation

In addition to the generic FME feature attributes that FME Workbench adds to all features (see About Feature Type Attributes), this format adds the format-specific attributes described in this topic.

Any feature that is sent to the SVG writer has several attributes that the writer uses to determine that feature’s geometric representation in SVG. The start of this processing occurs when the writer examines the feature’s svg_type attribute. Once the writer determines this attribute’s value, it can process the other attribute information required to complete the geometric conversion process. If, for example, the feature has an svg_type of svg_arc, then the writer will retrieve the svg_primary_axis, svg_secondary_axis, svg_start_angle and svg_rotation attributes to determine what geometric attribute values will exist in the feature’s path element representation.

All format-specific attributes begin with svg_ and are predefined in this section’s tables. In addition to format attributes, the SVG writer can process user-defined attributes. The writer extracts these user attributes from the incoming features and inserts them the output element’s attribute list. To determine which attributes to extract, the writer examines its mapping file’s DEF lines. The feature’s feature type must match the DEF lines type for this extraction to occur. The user-defined attributes are defined in the SVG element’s attribute list under the qualified name prefix fme. An extension to the SVG DTD is produced to accommodate these user-defined attributes. This extension is defined in the document’s internal document type declaration.

When producing an element’s attribute list, the writer will examine the contents of the attribute values to determine if there are any < or " characters. If these values are present, they are output using &lt; and &quot; respectively. Attribute values are embedded in an element’s attribute list using the quote (") delimiter.

The following table lists the format attributes that are common to all features sent to the SVG writer. Other than svg_color and svg_fill_color, all attributes in this table have a direct mapping to the attribute names that can be set on individual SVG elements. Selected SVG elements attribute names have been prepended with a svg_ string to produce the FME attribute names.

Attribute Name

Contents

svg_color

The color used to stroke an element. The string is formatted with three comma-separated values representing the ordered intensities red, green, and blue. The individual intensity values are character decimal character strings that can range in value from 0 to 1 with 1 being the highest. See note on color below.

Range:

string

0.0..1.0, 0.0..1.0, 0.0..1.0

Default: None

svg_fill_color

The color used to fill an element. The string is formatted with three comma-separated values representing the ordered intensities red, green, and blue. The individual intensity values represent decimals that can range in value from 0 to 1 with 1 being the highest. This value is not applicable to svg_line or svg_arc features. See note on color below.

Range:

string

0.0..1.0, 0.0..1.0, 0.0..1.0

Default: None

svg_id

An element’s unique identifier. Directly maps to an element’s id attribute. Refer to the XML 1.0 specification for applicable values. It is strongly recommended that users not create IDs that begin with “FME_”.

Range: string

Default: None

svg_class

Assigns a class name or set of class names to an element.

Directly maps to an element’s class attribute. Refer to the SVG 1.1 specification for applicable values.

Range: string

Default: None

svg_style

Specifies style information for an element. Directly maps to an element’s style attribute. Refer to the SVG 1.1 specification for applicable values.

Range: string

Default: None

svg_onfocusin

Identifies the script method to call when an element recieves focus. Directly maps to an element’s onfocusin attribute.

Range: string (must match an available script method ID)

Default: None

svg_onfocusout

Identifies the script method to call when an element loses focus. Directly maps to an element’s onfocusout attribute.

Range: string (must match an available script method ID)

Default: None

svg_onclick

Identifies the script method to call when a pointing device button is clicked over an element. Directly maps to an element’s onclick attribute.

Range: string (must match an available script method ID)

Default: None

svg_onmousedown

Identifies the script method to call when a pointing device button is pressed over an element. Directly maps to an element’s onmousedown attribute.

Range: string (must match an available script method ID)

Default: None

svg_onmouseup

Identifies the script method to call when a pointing device button is release over an element. Directly maps to an element’s onmouseup attribute.

Range: string (must match an available script method ID)

Default: None

svg_onmouseover

Identifies the script method to call when a pointing device button is moved on to an element. Directly maps to an element’s onmouseover attribute.

Range: string (must match an available script method ID)

Default: None

svg_onmousemove

Identifies the script method to call when a pointing device button is moved while it is over an element. Directly maps to an element’s onmousemove attribute.

Range: string (must match an available script method ID)

Default: None

svg_onmouseout

Identifies the script method to call when a pointing device button is moved away from an element. Directly maps to an element’s onmouseout attribute.

Range: string (must match an available script method ID)

Default: None

Note:

The attributes fme_color and svg_color can both be used to set the value on an element’s stroke attribute. fme_color and svg_color are translated to SVG’s RGB function syntax. For the case where more than one color attribute is specified on a feature, order of precedence is svg_color, and then fme_color.

The same processing occurs for the attribute fme_fill_color, svg_fill_color, except both values can be used to set the element’s ‘fill’ attribute.

In addition, if the values for the svg_color or svg_fill_color do not match the FME color specification, i.e., “r,g,b” where r,g,b are in [0..1], then the writer will plainly transfer the value specified into the SVG stroke and fill attributes respectively. This is useful if the user needs to by pass the FME “r,g,b” syntax, for example, to use the SVG’s predefined color names, “red”, “black”, etc..., or if the user wants to use gradient fill. A user-defined SVG template (see the writer’s TEMPLATE keyword) could define several gradients to be referenced by the FME feature’s svg_fill_color attribute.

Consider the following TEMPLATE for the SVG writer. It defines the MyGradient linearGradient that can be referenced by FME features by setting their svg_fill_color attribute to the value, url(#MyGradient):

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg">
   <defs>
      <linearGradient id="MyGradient">
        <stop offset="5%" stop-color="#F60" />
        <stop offset="95%" stop-color="#FF6" />
      </linearGradient>
   </defs>
</svg>