PREPARE (XFILE)


9.0D

 

A file must either be created or opened prior to any attempt to process data against it. The PREPARE instruction initializes an empty XML document.

 

[label]

PREPARE

{xfile},{name},{root}[,{option}][,{option}..]

 

Where:

label

Optional. A Program Execution Label.

xfile

Required. A previously defined XFILE variable that is to be opened.

name

Required. A previously defined Character String Variable or literal containing the name of the XML format file to create.

root

Required. A previously defined Character String Variable or Literal containing the root tag name.

option

Optional. One or more of the options from the table below.

Flags Affected: NONE

Note the following:

  1. 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.

  2. If the {name} is empty, the XFILE is a memory image only file.

  3. The {option} operand further defines the XFILE operations and must be from the following list:

  4.  

    Option

    Description

    MODE={nvar}

    Controls the mode of operation

    RECORDSET={svar}

    Specifies the default recordset to access

    SCHEMA={svar}

    Defines the schema file to use.

 

  1. 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.

  2. The {option} is "MODE=" followed by a decimal number or Numeric Variable (four byte INTEGER) containing bit maps as follows:

  3.  

    Keyword

    Value

    Meaning

    XFILE_NOCASE

    0x1

    Data field and recordset labels are not case sensitive.

    XFILE_CLOSEDSCHEMA

    0x2

    Do not allow additions to schema.

    XFILE_WRITESCHEMA

    0x8

    Write 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_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_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)

     

  1. 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.

  2. The physical XML file is saved from memory when the XFILE is FLUSHed, or CLOSEd and is not a memory image only file.

 

 

See Also: XML Support



PL/B Language Reference POSITEOF (XFILE) READ (XFILE)