XSD-Driven XML Reader/Writer

FME can read and write XML documents based on the schema from XML Schema (W3C XSD) documents.

This chapter assumes familiarity with XML and XML Schemas.

Note  This format does not directly support geometry reading or writing. An XML read may include geometry, but geometry will only be read as XML blobs. The XML schema may include geometry definition, but this writer will not automatically extract FME geometry and write it out to XML geometry objects. All such geometry handling – converting between FME geometry and XML – must be processed in a workspace. For XML that is a hybrid of XML and GML, the OGC GML (Geography Markup Language) Reader/Writer may be flexible enough to work with it directly and handle the geometry. For additional information, see the FME Community article, How to Consume and Produce XML using Application Schemas with the XSD-Driven XML Writer; or view FME Support resources.

XSD-Driven XML Product and System Requirements

Format

FME Platform

Operating System

Reader/Writer

FME Form

FME Flow

FME Flow Hosted

Windows 64-bit

Linux

Mac

Reader

Yes

Yes

Yes

Yes

Yes

Yes

Writer

Yes

Yes

Yes

Yes

Yes

Yes

Overview

This Reader/Writer allows FME to read and write any XML document that conforms to the application schema provided. XML documents must be instances of a conforming application schema. Application schemas are to be defined with the W3C’s XML Schema language.

XML and XML Schemas (W3C XSDs) are recommendations of the World Wide Web Consortium (W3C). More information on XML and W3C XSDs can be found in the W3C website.

The XSD-Driven XML reader/writer provides two mechanisms to map elements declared in the XSD Schemas into features:

1. By specifying a list of top-level element declarations from the XSD Schemas, via the “Feature Paths” parameter.
2. By specifying a list of complex type definitions that are used as the type in the XSD Schemas’ element declarations.

Reader Overview

The XSD-Driven XML reader maps XML elements into FME features.

These XML elements must correspond to top level element declarations, or reachable via top-level element declarations, in the XSD Schemas. The top-level element declarations from the XSD Schemas can be identified with the reader’s Feature Paths parameter.

Multi-value properties (that is, declared with a maxOccurs that is greater than 1 or unbounded) are supported and are mapped into list attributes. Null values are not read unless they are nillable. XML elements that are defined as complex types are supported – these nested elements are mapped as structured list attributes.

Writer Overview

The XSD-Driven XML writer writes XML documents conforming to an existing (W3C XSD) XML Schema document.

The FME feature types must correspond to top-level element declarations, or elements reachable via top-level element declarations, in the XSD Schemas. The top-level element declarations from the XSD Schemas can be identified with the writer’s Feature Paths parameter.

The writer writes a single XML document. If multiple features are routed into the writer, they must be composable into a single rooted tree via the xml_id and xml_parent_id attributes. Each feature (if it is to be composed into a single rooted tree) must have a unique xml_id. Each feature (if it is not the root) must have also have an xml_parent_id pointing back to its parent xml_id attribute value.

Note  The xml_id must be unique for the entire dataset. FME will use the xml_id to make the associations between the XML objects. If you already have an id in your data (my_id), you can use a prefix to make it unique.
For example:
customer-@Value(my_id)

The writer’s XML Appender parameters may be used to help compose the final document. If the XML Document parameter is non-empty, then the specified document will be written as the output. Each rooted feature (features with no xml_parent_id), that is sent to the writer will be inserted into the XML Document. By default, the features that are mapped into XML according to the XSD are inserted right before the end tag of XML Document's root element. The append path and the manner of insertion can be controlled by the XML Document Append Path and XML Document Append As parameters. In addition, each of the rooted features may be further wrapped. This is useful if the features need to be wrapped in an element in the XML Document, say, <os:member>. See the XML Wrapper, XML Wrapper Append Path, and XML Wrapper Append As parameters.