- 26 Aug 2024
- 7 minute read
- Print
- DarkLight
- PDF
Format Definition XML
- Updated 26 Aug 2024
- 7 minute read
- Print
- DarkLight
- PDF
When creating or editing a source format, the XML setting on the Format Definition tab tells Slate how it should parse incoming data. Each setting is listed here, followed by examples for common source data formats.
✨ TipWe recommend finding one of our example format definitions for flat files or web services, copying the XML, and modifying as needed.
Format definition XML always begins with a <layout>
node. This node can have several attributes:
The
b
attribute indicates the separator. For example, useb=","
for a comma-delimited file.The
h
attribute indicates whether the data contains a header row. Useh="1"
if your data has a header row. If there's no header row, this attribute can be set to0
or simply excluded.The
t
attribute indicates the text qualifiers. For example, uset="""
for files where each data element is contained in double quotes.The
type
attribute is used when the incoming data is not a text file, and can be set to one of the following values:type="convert"
is used for Excel files.type="xml"
andtype="json"
are used for XML and JSON files, respectively.
The
width
attribute is used in fixed-width files to define how many characters each row of the file has.
When the incoming data does not have a header row, <f>
nodes contained within the <layout>
node are required. Each <f>
node represents a single field to be mapped in the source format, and can have the following attributes:
Required: The
id
attribute is what the ID of the field should be. It should be unique among the other fields in the Source Format. This is also what you will see as the "Source" field when you are mapping the values on the Remap page. Note: this ID should be no more than 64 characters in length.Required: The
s
attribute defines where to find the field in the source data. The examples below demonstrate how to use this attribute for various format types.The
w
attribute is used in fixed-width files to define the character length of the field.
Defining Multiple Namespaces in an XML file:
Multiple namespaces can be declared in the Format Definition for an XML file. This is useful when an XML file contains more than one namespace URI. To avoid conflicts between XML elements with the same name, a unique prefix attribute can be added to each namespace node, which is then associated with the specific namespace URI.
The following format definition examples are for defining multiple namespaces in an XML file:
<layout type="xml" node="/ns1:UCRecords/UCRecord">
<namespace prefix="ns1" uri="http://www.ucop.edu/schema/UCRecord" />
<namespace prefix="AdmApp" uri="http://www.pesc.org/message/AdmissionsApplication" />
</layout>
<layout type="xml" node="/AcRecBat:AcademicRecordBatch/HSTrn:HighSchoolTranscript">
<namespace prefix="HSTrn" uri="urn:org:pesc:message:HighSchoolTranscript:v1.3.0" />
<namespace prefix="AcRecBat" uri="urn:org:pesc:message:AcademicRecordBatch:v1.0.0" />
</layout>
Flat File Examples
The following format definition examples are for flat files, like CSV, Excel, and fixed-width files.The following format definition examples are for flat files, like CSV, Excel, and fixed-width files.
CSV file with a header row and double quotes around each element: |
---|
This format definition works if the source data looks like this:
Double-quotes are wrapped around each field, while a comma separates each field. By including the quotes, Slate interprets "1745 E. New St., Apt. 22" as one field rather than two. |
Tab-separated file with a header row and no text qualifiers: |
---|
|
Pipe-separated file with a header row and no text qualifiers: |
---|
|
Excel file with a header row: |
---|
|
CSV file without a header row: |
---|
The
|
A fixed-width file with no delimiters, where the beginning and end of each field is defined based on the specific location in the row: |
---|
The
|
Web Services Examples
The following examples are for XML and JSON formats, which are commonly imported via web services.
XML: |
---|
This format definition works if your incoming data is structured like this:
In the Each
The last two
|
JSON: |
---|
This format definition works if your incoming data is structured like this:
In this format, the Each
The last two
|