Writer Directives

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

DATASET

Required/Optional: Required

This keyword specifies the location for the output XML document.

Workbench Parameter: Destination XML (Extensible Markup Language) File

Example:

XML_DATASET c:\data\purchases.xml

PRETTY_PRINT

Required/Optional: Optional

This directive specifies whether the output XML document should be pretty-printed with indentation. The valid values for this directive are YES and NO. The default value is NO.

XML_PRETTY_PRINT YES

Workbench Parameter: Pretty Print

INDENT_SIZE

Required/Optional: Optional

This directive takes effect when PRETTY_PRINT is set to YES. It specifies the indentation size. The valid values for this directive are the numbers 0 to 9. The default value for this directive is 1.

XML_INDENT_SIZE 3

Workbench Parameter: Indent Size

REPLACE_TABS_WITH_SPACES

Required/Optional: Optional

By default the Tab character is used to pretty-print the indentations; set this directive to YES to substitute the Tab character with a Space. The size of a single indentation is controlled by the INDENT_SIZE directive. The valid values for this directive are YES and NO. The default value is NO.

XML_REPLACE_TABS_WITH_SPACES YES

Workbench Parameter: Replace Tabs with Spaces

TEXT_INDENT

Required/Optional: Optional

TEXT_INDENT_NO

Workbench Parameter: Text Indent

XSD_DOC

Required/Optional

Optional

Specifies the location for the XML Schema document. This keyword is optional. If the keyword is not specified or if it does not contain a path, then the XML Schema document is generated in the same folder as the one specified through the DATASETkeyword. If this keyword is set to a URI, then XSD output will be suppressed.

Note: The XSD_DOC directive applies if any of the special feature types XML_ROOT_ELEMENT and XML_FRAGMENT are present.

Workbench Parameter: XML Schema Document

Example:

XML_XSD_DOC c:\data\purchases.xsd

TARGET_NS_URI

Required/Optional: Optional

This keyword allows the specification of the target namespace URI for the generated XML Schema document. All elements in the XML Schema document will reside in this namespace.

The default value for this keyword is:

http://www.safe.com/xml/xmltables

Workbench Parameter: Target Namespace URI

Example:

XML_TARGET_NS_URI http://www.mytables.com/purchases

TARGET_NS_PREFIX

This directive allows the specification of the target namespace prefix for the generated XML Schema document.

The default value depends on the value of TARGET_NS_URI. If TARGET_NS_URI is using the default value, the default value for this directive is fme. If TARGET_NS_URI is not using the default value, the default value for this directive becomes the default prefix, which is the empty string.

Required/Optional

Optional

Mapping File Syntax

XML_TARGET_NS_PREFIX ps

Workbench Parameter

Target Namespace Prefix

XML_NAMESPACE_DECLARATIONS

Required/Optional

Optional

This keyword specifies additional XML Namespace Declarations for the root element in the output dataset. The values for this directive are white space separated prefix and URIs pairs, no default namespace declarations are allowed with this directive.

Example

XML_NAMESPACE_DECLARATIONS gml http://www.opengis.net/gml xlink http://www.w3.org/1999/xlink

Workbench Parameter

XML Namespace Declarations

TABLES_SEQUENCE

Required/Optional

Optional

The sequence order for the rows in the output DATASET defaults to following the order of the XML DEF line specification in the FME mapping file. This keyword allows the user to change the order by specifying a sequence of table names; the sequence must be a subset of the tables defined by the DEF lines.

Example

If the XML DEF lines define four tables with names – state, river, city, and road – then the TABLES_SEQUENCE may be used to control the output sequence order to be city, state, river, and road by specifying:

XML_TABLES_SEQUENCE ‘city state river road’

or

XML_TABLES_SEQUENCE ‘city state’

The second alternative is valid since the remaining tables that are not listed will be output following the order of the mapping file XML DEF lines.

Note: The value of the XML_TABLES_SEQUENCE keyword must be enclosed in quotes if more than one table is listed.

TABLES_ROOT_ELEMENT

Required/Optional: Optional

Allows the specification of the root element name for the output DATASET. If it is not specified, the root element name defaults to xml-tables.

Workbench Parameter: Tables Root Element Name

Example:

XML_TABLES_ROOT_ELEMENT purchases

WRAP_TABLES

Required/Optional: Optional

The valid values for this keyword are yes and no. When this keyword is set to yes, the elements which represent the rows for a particular table within the output DATASET document will be wrapped by a container element. The default value for this keyword is yes.

The wrapper element name will be the name of the rows prepended by the value of the TABLE_WRAPPER_PREFIX and suffixed by the value of the TABLE_WRAPPER_SUFFIX.

Workbench Parameter: Wrap Table Elements

Example:

XML_WRAP_TABLES yes

TABLE_WRAPPER_PREFIX

Required/Optional: Optional

This keyword is used in conjunction with the WRAP_TABLES keyword, and will take effect only if that keyword is set to yes. The default value for this keyword is the empty string.

Workbench Parameter: Table Wrap Prefix

Example:

XML_TABLE_WRAPPER_PREFIX prefix-

TABLE_WRAPPER_SUFFIX

Required/Optional: Optional

This keyword is used in conjunction with the WRAP_TABLES keyword and will take effect only if that keyword is set to yes. The default value for this keyword is -table.

Workbench Parameter: Table Wrap Suffix

Example:

XML_TABLE_WRAPPER_SUFFIX -mytables

SUPPRESS_XML_DOCUMENT

Required/Optional: Optional

The valid values for this keyword are yes and no. This keyword allows the suppression of the actual XML document. The default value for this keyword is no.

Workbench Parameter: Suppress XML Document

Example:

XML_SUPPRESS_XML_DOCUMENT no

SUPPRESS_XSD_DOCUMENT

Required/Optional: Optional

The valid values for this keyword are yes and no. This keyword allows the suppression of the XML Schema document. If the XSD_DOC keyword is set to a URI, XSD output is suppressed regardless of this value. The default value for this keyword is no.

Workbench Parameter: Suppress XSD Output

Example:

XML_SUPPRESS_XSD_DOCUMENT no

GENERATE_XFMAP

Note: This directive is deprecated as of FME 2013.

Required/Optional: Optional

The valid values for this keyword are yes and no. This keyword allows the generation of a tailored xfMap document that can be used by the XML Reader to read the output DATASET document back to the FME. The default value for this keyword is no.

Workbench Parameter: Generate XML Map Document

Example:

XML_GENERATE_XFMAP yes

XFMAP

Note: This directive is deprecated as of FME 2013.

Required/Optional: Optional

This keyword takes effect only if GENERATE_XFMAP is set to yes; it specifies the location and filename for the xfMap document to be generated. If it is not specified, then the location defaults to the same folder as the one in DATASET, and the filename becomes the basename DATASET plus the .xmp extension.

Workbench Parameter: XML Map Document

Example:

XML_XFMAP c:\data\purchases.xmp

GENERATE_ROW_ID

Required/Optional: Optional

The valid values for this keyword are yes and no. When this keyword is set to yes, an ID attribute of XML Schema type ID will be generated for each element that represents a row of a table. The name of the attribute may be set by the ROW_ID_ATTR_NAME keyword. The values generated for the ID attribute will be unique for the entire output DATASET. The unique values are simply generated from a positive integer number count starting from 1, and since the XML Schema ID type does not allow an ID to start with a digit, the ROW_ID_PREFIX keyword’s value is used to prefix the ID. The default value for this keyword is no.

Workbench Parameter: Generate Row ID Attributes

Example:

XML_GENERATE_ROW_ID yes

ROW_ID_ATTR_NAME

Required/Optional: Optional

This keyword only takes effect if GENERATE_ROW_ID is set to yes. It specifies the name for an ID attribute for each element that represents a row of a table. The default value for this keyword is “row-id”.

Workbench Parameter: Row ID Attribute Name

Example:

XML_ROW_ID_ATTR_NAME myID

ROW_ID_PREFIX

Required/Optional: Optional

This keyword only takes effect if GENERATE_ROW_ID is set to yes. It specifies the prefix for the unique positive integers that are generated as the values for the row IDs. This value may not start with a digit and its default value is “id”.

Workbench Parameter: Row ID Prefix

Example:

XML_ROW_ID_PREFIX fid

Will generate ID values: fid1, fid2, fid3, ....

APPLY_STYLESHEET

Required/Optional: Optional

This keyword allows an XSLT style sheet to be applied to the final output DATASET document. The STYLESHEET_RESULT keyword may be used in conjunction with this keyword to specify the location and filename of the resulting transformation. There are no default values for this keyword.

Workbench Parameter: XSLT Style Sheet to Apply

Example:

XML_APPLY_STYLESHEET c:\data\myTransform.xsl

STYLESHEET_RESULT

Required/Optional: Optional

This keyword only takes effect if APPLY_STYLESHEET is specified. When this keyword is not present or its value is the empty string, then the resulting XSLT transformation will have the same location and filename as the output DATASET with the exception that the filename will be prefixed with transformed_.

Workbench Parameter: Style Sheet File to Write

Example:

XML_STYLESHEET_RESULT c:\data\myTransformedDoc.xml

OUTPUT_ENCODING

Required/Optional: Optional

Specifies the encoding for the output DATASET document. The default value for this keyword is UTF-8.

Workbench Parameter: Output Dataset Encoding

Example:

XML_OUTPUT_ENCODING UTF-16

XML_ROOT_ELEMENT_APPEND_PATH

Required/Optional: Optional

This keyword specifies a single element, or a path to a single element, in the document specified by the XML_ROOT_ELEMENT feature type.

Each element in the path is separated by a forward slash, ‘/’, a wildcard, ‘*’, may also be used as the prefix or local-name of the element, e.g., ‘*:e’, ‘p:*’, or just ‘*’, which translates to ‘*:*’.

The keyword default value is the empty string. This will match or select the root element.

Consider the following XML document:

<data>
  <metadata>…</metadata>
  <initialize>…</initialize>
  <!--Insert XML fragments here -->
  <finalize>…</finalize>
</data>

To insert fragments after the <initialize> element, we can either:

  1. Select XML_ROOT_ELEMENT_APPEND_PATH as “data/initialize”, and
  2. Set APPEND_XML_FRAGMENTS_AS as SUCCEEDING_SIBLINGS

or:

  1. Select XML_ROOT_ELEMENT_APPEND_PATH as “data/finalize”, and
  2. Set APPEND_XML_FRAGMENTS_AS as PRECEDING_SIBLINGS

Example

XML_XML_ROOT_ELEMENT_APPEND_PATH data/collection

Workbench Parameter

XML_ROOT_ELEMENT Append Path

APPEND_XML_FRAGMENTS_AS

Required/Optional: Optional

This keyword controls how the fragments are inserted into the document in relation to the selected or matched element. The possible values for the parameter are:

  • PRECEDING_CHILDREN
  • SUCCEEDING_CHILDREN
  • PRECEDING_SIBLINGS
  • SUCCEEDING_SIBLINGS

The values are to be understood in relation to the selected or matched element.

The default value for this keyword is SUCCEEDING_CHILDREN.

Workbench Parameter

Append XML_FRAGMENTs As

Example

XML_APPEND_XML_FRAGMENTS_AS PRECEDING_SIBLINGS