WRITE

The WRITE command serializes the document object out to a specified file. It is used as the final step in creating an XML document from fields set inside your program. You will use the SET command one or more times prior to using the WRITE command to set up the data in the document.

 

                                                          Required

 

 WRITE ---------- FILE --------------- file path ---------------->

 

                                                          Optional

 

              >-- INDENT ------------- *NO ---------------------->

                                       *YES

 

              >-- IDENT-AMOUNT ------- value -------------------->

 

              >-- DOCTYPE ------------ value -------------------->

 

              >-- PUBLIC ------------- value -------------------->

 

              >-- OMIT-DECLARATION --- *NO ---------------------->

                                       *YES

 

              >-- ENCODING ----------- value -------------------->

 

              >-- BINDTRACE ---------- *NO ---------------------->

                                       *YES

 

              >-- FILTER ------------- value --------------------|

 

Keywords

FILE

This keyword is used to specify the file name and path of the XML document to be created.

It is recommended to use the forward slash as the path separator and to avoid the use of the DOS drive designator.

The format of the path should be as follows:

For Windows you can specify:

Absolute path.
For example:
/orders/order.xml
C:/orders/order.xml

C:\orders\order.xml


or

Relative path.
For example, orders/order.xml (note, no '/' at the start), in which case the document order.xml will be placed in the orders directory under the JSM Instance directory on your server.

For the IBM i you can specify:

Absolute path.
For example:
/orders/order.xml

or

Relative path.
For example, orders/order.xml (note, no '/' at the start), in which case the document order.xml will be placed in the orders directory under the JSM Instance directory on your server.

Note: The directory structure must exist.

This keyword is mandatory.

INDENT

This keyword is used to specify whether or not you would like the XML content to be indented.

There are two options:

*YES - to indicate that you want the XML content to be indented.

*NO - to indicate that you do not want the XML content indented.

  • The default value is *NO.
  • This keyword is used in conjunction with the INDENT-AMOUNT keyword.

    This keyword is optional.

    INDENT-AMOUNT

    This keyword is used to specify the number of spaces to use for the indentation.

    The default value is 0 (which is akin to having indenting turned off).

    If the INDENT keyword is set to *NO then this keyword will have no effect.

    This keyword is optional.

    DOCTYPE

    This keyword is used to specify the system component of the document type declaration.

    Whatever value you specify here will be placed into the document as the document type declaration. It will be placed just after the XML declaration (if this is included).

    This keyword is optional.

    PUBLIC

    Conditional. The optional public component of the DOCTYPE declaration.

    OMIT-DECLARATION

    This keyword is used to specify whether you want to include the XML declaration or not.

    There are two options:

    *YES - to indicate that you want the XML declaration omitted.

    *NO - to indicate the you want the XML declaration to remain included.

    The default value is *NO.

    This keyword is optional.

    ENCODING

    Optional. See ENCODING.

    Default encoding is UTF-8.

    BINDTRACE

    This keyword is used to turn on tracing for the outbound bind result.

    There are two options:

    *YES - to switch tracing on.

    *NO - to switch tracing off.

    This keyword is optional.

    FILTER

    Refer to FILTER for more complete information on this keyword.

    This keyword is optional.

     

    Examples

    RDML

     

    * Define the fields used by the JSM Commands

    DEFINE FIELD(#JSMSTS) TYPE(*CHAR) LENGTH(020)

    DEFINE FIELD(#JSMMSG) TYPE(*CHAR) LENGTH(256)

    DEFINE FIELD(#JSMCMD) TYPE(*CHAR) LENGTH(256)

     

    CHANGE FIELD(#JSMCMD) TO('WRITE FILE(response/rsp_order.xml) INDENT(*YES) INDENT-AMOUNT(1)')

    USE BUILTIN(JSM_COMMAND) WITH_ARGS(#JSMCMD) TO_GET(#JSMSTS #JSMMSG)

     

    RDMLX

     

    * Define the fields used by the JSM Commands

    Define FIELD(#JSMSTS) TYPE(*CHAR) LENGTH(020)

    Define FIELD(#JSMMSG) TYPE(*CHAR) LENGTH(256)

    Define FIELD(#JSMCMD) TYPE(*CHAR) LENGTH(256)

    Define FIELD(#JSMHND) TYPE(*CHAR) LENGTH(4)

     

    #JSMCMD := 'WRITE FILE(response/rsp_order.xml) INDENT(*YES) INDENT-AMOUNT(1)'

    Use BUILTIN(JSMX_COMMAND) WITH_ARGS(#JSMHND #JSMCMD) TO_GET(#JSMSTS #JSMMSG)