OPEN (XFILE)
9.0D
A file must either be created or opened prior to any attempt to process data. The OPEN instruction initializes an XFILE using an existing physical XML file.
|
|
|
|
Where:
label
Optional. A Program Execution Label.
xfile
Required. A previously defined XFILE variable that is opened.
name
Required. A previously defined Character String Variable or literal containing the name of the XML format file to open.
option
Optional. One or more of the options from the table below.
Flags Affected: NONE
Note the following:
The {name} is the physical XML file to be opened. If a character string variable is specified, only the Logical String is used. If a literal is specified, the entire literal string within the operating system's limitations is used. The physical XML file cannot be opened using a Data Manager.
Naming conventions are the same as FILE except the XFILE does not support the Data Manager.
Attempting to OPEN a file that does not exist, results in a trappable I/O error (see TRAP).
The physical file is opened in EXCLUSIVE mode.
The {option} operand further defines the XFILE operations and must be from the following list:
|
Option |
Description |
|
DATA={svar} |
The XML document data is contained in the {svar}. |
|
MODE={nvar} |
Controls the mode of operation. |
|
RECORDSET={svar} |
Specifies the default recordset to access. |
|
SCHEMA={svar} |
Defines the name of schema file. |
If the RECORDSET option is used, all operations on the XFILE are restricted to that recordset. If the RECORDSET option is not used, the XFILE is restricted to one record. This one record may contain other recordsets.
The {option} "MODE=" followed by a decimal number or Numeric Variable (four byte INTEGER) containing bit maps as follows:
|
Keyword |
Value |
Meaning |
|
XFILE_NOCASE |
0x1 |
Data field and record set labels are not case sensitive. |
|
XFILE_CLOSEDSCHEMA |
0x2 |
Do not allow additions to schema. |
|
XFILE_KEEPOPEN |
0x4 |
Keep the physical file open. |
|
XFILE_WRITESCHEMA |
0x8 |
Write out the schema on a FLUSH or CLOSE statement. |
|
XFILE_NOLOADSCHEMA |
0x10 |
Do not load the schema from disk. |
|
XFILE_NOEMPTYFIELDS |
0x20 |
Error on reading an empty field. |
|
XFILE_ALLCHARS |
0x80 |
Allow all characters to be read for all XML data fields. When this bit mode is used, the character values less than 0x20 are not substituted by a white space. |
|
XFILE_OPENREADONLY |
0x100 |
Open XML and schema in READ Only. (9.1) |
|
XFILE_WRTISO8859 |
0x200 |
Encoding is set for ISO8859. This allows 8-bit character values in the XML file. |
|
XFILE_NOOUTPUTEMPTYFIELDS |
0x400 |
Do not write empty fields to a XML file. |
|
XFILE_FILTERNOCASE |
0x800 |
Execute filtered READs in a case insensitive mode. (9.3A) |
|
XFILE_XMLOUTFMTUSETABS |
0x1000 |
Use a tab character to indent when outputting XML tags. (9.5A) |
|
XFILE_XMLOUTFMTSPCSUPRESS |
0x2000 |
Suppress leading and trailing spaces when outputting XML data. (9.5A) |
|
XFILE_XMLOUTFMTESCALWAYS |
0x4000 |
Always escape double-quote (") and single-quote (') characters when outputting XML element data. This format control allows double-quote and single-quote characters to be escaped for the element data in the same manner as they are escaped for attribute data. When this control is not used, the default behavior is to only escape these characters in the attribute data as defined in the W3C XML specification. (9.5A) |
|
XFILE_XMLOUTFMTCVTTOSPC |
0x8000 |
Convert any character less than 0x20 to 0x20. This output format control should only be used when XML output data contains binary data that the user does not want to be escaped. (9.5A) |
|
XFILE_XMLOUTFMTNOEOR4BLKS |
0x10000 |
When this bit is turned on, the XFILE XML output does not generate a CR\LF eor after the <starttag> for an XML element when all of the XML element data are blank characters. (10.2) |
If the same XFILE Definition Label ({xfile}) is used for more than one OPEN instruction within the same program, the currently open file is CLOSEd before an attempt is made to initialize the new file.
Once the XML file is loaded into memory, the physical file is closed unless the XFILE_KEEPOPEN bit is set in the MODE.
The physical XML file is saved from memory when the XFILE is FLUSHed or CLOSEd.
See Also: XML Support
![]() |