Working with DFDL messages and bit streams

Use the ASBITSTREAM function and the CREATE statement to manage DFDL-described message content.

About this task

Note: The folder BitStream is not supported when manipulating messages in the DFDL domain.

The ASBITSTREAM function

If you code an ASBITSTREAM function to parse your message tree to a bit stream, and the parser mode option is set to RootBitStream , the result is a DFDL document that is built from the children of the target element in the normal way. This algorithm is identical to the algorithm that is used to generate the normal output bit stream. Because the target element is not included in the output bit stream, you must ensure that the children of the target element follow the constraints for a DFDL document.

One constraint is that there must be only one body element in the message. You can use a well-formed bit stream that is obtained in this way to re-create the original logical tree by using a CREATE statement that includes a PARSE clause.

For more information about the ASBITSTREAM function, and some examples of its use, see ASBITSTREAM function.

The CREATE statement with a PARSE clause

If you code a CREATE statement with a PARSE clause to parse your bit stream to a message tree, and the parser mode option is set to RootBitStream, the expected bit stream is a normal DFDL-described message. An element is created in the logical tree for each element that is identified in the bit stream. This algorithm is identical to the algorithm that is used when parsing a bit stream from an input node.

The following example enables the content of an object in an Amazon S3 bucket to be extracted and parsed, and it must be parsed with the correct domain. For example, if the object contains a CSV file, you can define a DFDL schema to model the data and deploy it in a shared library, and then use a Compute node after the Amazon S3 Get Object operation, with code similar to the following example:

        CALL CopyMessageHeaders();
        -- Get the content we want to parse with another parser
        DECLARE InnerElement CHARACTER InputBody.Data.content;
        -- Now convert that string element to a bitstream as that's required for parsing
        DECLARE InnerBits BLOB CAST(InnerElement AS BLOB CCSID 1208);
        -- Pass the bitsteam to the DFDL parser, note the '{' '}' braces around the message set
        -- this is required because it's in a Shared Library.
        CREATE LASTCHILD OF OutputRoot DOMAIN('DFDL') PARSE(InnerBits CCSID 1208 SET '{MyMessages}' TYPE 'Books');
        RETURN TRUE;

This example includes a shared library that is called MyMessages with a DFDL schema called Books. The ESQL code selects the content element of the input message, converts it to binary format, and then passes it to the DFDL parser. The result is the parsed content of the Amazon S3 object. For more information, see Using Amazon S3 with IBM App Connect Enterprise.

For more information about the CREATE statement, and examples of its use, see CREATE statement.