IMPORT XML command
Concept Information
Creates an Analytics table by defining and importing an XML file.
Syntax
IMPORT XML TO table import_filename FROM source_filename [field_syntax] <...n>
field_syntax ::=
FIELD name type AT start_position DEC value WID bytes PIC format AS display_name RULE xpath_expression
Parameters
Name | Description | ||||
---|---|---|---|---|---|
TO table |
The name of the Analytics table to import the data into. Note Table names are limited to 64 alphanumeric characters. The name can include the underscore character ( _ ), but no other special characters, or any spaces. The name cannot start with a number. |
||||
import_filename |
The name of the Analytics data file to create. Specify import_filename as a quoted string with a .FIL file extension. For example, "Invoices.FIL". By default, the data file (.FIL) is saved to the folder containing the Analytics project. Use either an absolute or relative file path to save the data file to a different, existing folder:
|
||||
FROM source_filename |
The name of the source data file. source_filename must be a quoted string. If the source data file is not located in the same directory as the Analytics project, you must use an absolute path or a relative path to specify the file location:
|
||||
FIELD name type |
The individual fields to import from the source data file, including the name and data type of the field. To exclude a field from being imported, do not specify it. For information about type, see Identifiers for field data types. |
||||
AT start_position |
The starting byte position of the field in the Analytics data file. Note
In Unicode Analytics, typically you should specify an odd-numbered starting byte position. Specifying an even-numbered starting position can cause characters to display incorrectly. |
||||
DEC value |
The number of decimals for numeric fields. |
||||
WID bytes |
The length in bytes of the field in the Analytics table layout. Note
In Unicode Analytics, specify an even number of bytes only. Specifying an odd number of bytes can cause characters to display incorrectly. |
||||
PIC format |
Note Applies to numeric or datetime fields only.
format must be enclosed in quotation marks. |
||||
AS display_name |
The display name (alternate column title) for the field in the view in the new Analytics table. Specify display_name as a quoted string. Use a semi-colon (;) between words if you want a line break in the column title. AS is required when you are defining FIELD. To make the display name the same as the field name, enter a blank display_name value using the following syntax: AS "". Make sure there is no space between the two double quotation marks. |
||||
RULE xpath_expression |
The XPath expression used to select the field contents from the XML file. XPath is a standard way of accessing data from XML files. For example, acct/title/text() retrieves the text within the <title> tag in the XML file. |
Examples
Importing data from an XML file to an Analytics table
You import data from an XML file to an Analytics table named Employees:
IMPORT XML TO Employees "Employees.fil" FROM "emp.XML" FIELD "Empno" C AT 1 DEC 0 WID 6 PIC "" AS "" RULE "/RECORDS/RECORD/Empno/text()" FIELD "First" C AT 7 DEC 0 WID 13 PIC "" AS "" RULE "/RECORDS/RECORD/First/text()" FIELD "Last" C AT 20 DEC 0 WID 20 PIC "" AS "" RULE "/RECORDS/RECORD/Last/text()" FIELD "HireDate" D AT 40 DEC 0 WID 10 PIC "YYYY-MM-DD" AS "" RULE "/RECORDS/RECORD/HireDate/text()" FIELD "Salary" N AT 50 DEC 2 WID 8 PIC "" AS "" RULE "/RECORDS/RECORD/Salary/text()"
Remarks
For more information about how this command works, see Import an XML file.
Identifiers for field data types
The table below lists the letters that you must use when specifying type for FIELD. Each letter corresponds to an Analytics data type.
For example, if you are defining a Last Name field, which requires a character data type, you would specify "C": FIELD "Last_Name" C.
For more information, see Data types in Analytics.
Note
When you use the Data Definition Wizard to define a table that includes EBCDIC, Unicode, or ASCII fields, the fields are automatically assigned the letter "C" (for the CHARACTER type).
When you enter an IMPORT statement manually, or edit an existing IMPORT statement, you can substitute the more specific letters "E" or "U" for EBCDIC or Unicode fields.
Letter |
Analytics Data type |
---|---|
A |
ACL |
B |
BINARY |
C |
CHARACTER |
D |
DATETIME |
E |
EBCDIC |
F |
FLOAT |
G |
ACCPAC |
I |
IBMFLOAT |
K |
UNSIGNED |
L |
LOGICAL |
N |
|
P |
PACKED |
Q |
BASIC |
R |
MICRO |
S |
CUSTOM |
T |
PCASCII |
U |
UNICODE |
V |
VAXFLOAT |
X |
NUMERIC |
Y |
UNISYS |
Z |
ZONED |