z/TPF

z/TPF

z/TPF

The z/TPF group is dedicated to sharing news, knowledge, and insights about the z/TPF product family. Consisting of IBMers and users, this community collaborates to advance the potential of high-volume, high-throughput transaction technology.

 View Only

PJ45953 - DFDL support for C constructs

By Bradd Kadlecik posted Thu May 28, 2020 01:48 PM

  

With DFDL support for C constructs, the z/TPF DFDL parser can be used for common C constructs such as null terminated strings, double pointers, and pointers to variable size arrays. This is achieved by specifying a dfdl:lengthKind value of "delimited" for null terminated strings and specifying a tddt:indirectKind value of "pointer" on an enclosing sequence statement for double pointers and pointers to variable size arrays.

For example, the following C definition it typically used to define a pointer to a null-terminated string:
char *Name;

This can now be defined in DFDL as follows:
<xs:element name="Name" type="xs:string" tddt:indirectKind="pointer" tddt:indirectLength="8" dfdl:lengthKind="delimited" dfdl:lengthUnits="bytes" dfdl:terminator="%NUL;" dfdl:textTrimKind="none" default=""/>

A pointer to a variable size array would typically defined as something like the following:
int customersItemCount;
customerInfo *customers;

This can now be defined in DFDL as follows:
<xs:element name="customersItemCount" type="xs:int" dfdl:lengthKind="explicit" dfdl:length="4" dfdl:lengthUnits="bytes" dfdl:outputValueCalc="{fn:count(../customers)}" default="0"/>
<xs:sequence tddt:indirectKind="pointer" tddt:indirectLength="8" dfdl:leadingSkip="4" dfdl:alignmentUnits="bytes">
    <xs:element name="customers" type="customerInfo" dfdl:lengthKind="implicit" minOccurs="0" maxOccurs="unbounded" dfdl:occursCountKind="expression" dfdl:occursCount="{../customersItemCount}"/>
</xs:sequence>

REST provider and consumer are updated to support an array of items for path, query, or header parameters with the default delimiter being comma separated values (csv) as per the OpenAPI specification. Additional delimiters of pipes or space (ssv) can be specified in the OpenAPI descriptor as well.

The restriction that header, query, and path parameter names be unique can be removed by specifying a new property in the z/TPF service descriptor of "DFDLFormat":"OAS". This requires a specific data layout that separates out parameters by HTTP request/response location by using an element named "body", "header", "query", or "path" to encapsulate the data.  This is briefly illustrated in the following C structure:
struct {
   struct {
      char *Authorization;
   } header;
   struct {
      char queryParm[12];
   } query;
   struct {
     ...
   } body;
} request;

0 comments
18 views

Permalink