Thunder Suite   •  JSON Thunder   •  XML Thunder   •  FAQs   •  Tutorials   •  Wiki   •  Levelset History   •  JSON Thunder Technical Details   •  XML Thunder Technical Details

Thunder Wiki for Thunder Suite, JSON Thunder & XML Thunder

Page History: Thunder Special Fields

Compare Page Revisions



Older Revision - Back to Page History - Newer Revision


Page Revision: 2016/05/25 14:59


XML Thunder makes use of “special fields” to: * Provide additional information found by XML Readers when parsing; and,

  • Allow for greater control of XML output by XML Writers.  



XML Thunder provides 5 special fields.

# Optional Flag – to indicate if an optional field is populated (forReaders), or if it should be output (for Writers).

  1. Counter - for repeating structures – to indicate how many occurrenceswere found (Readers) or how many should be output (Writers).
  2. Length - for variable length fields – to indicate the length of a fieldfound (for Readers) or how many characters of the field to output (for Writers).
  3. Track Pointer – to indicate the start and end position of an element orattribute (for Readers).
  4. Floating Point - for control of decimal precision for decimal fields 




A special field exists in the program data fields (IDS) that make up the API into the Handler, but they do not exist in the XML structure.  Below is an IDS containing the all 5 special field types. IMAGE1 Counter Field The counter special field is used to control repeating structures.  A counter field is automatically inserted into the IDS for each repeating structure in the Handler Design.  The counter field is: * Returned bya Reader to indicate the number of occurrences found in the JSON/XML instancebeing parsed.  For a document-levelhandler, the counter field will contain the total number of occurrencesfound.  For a node-level handler, thecounter field will indicate if the Handler is returning the last occurrence ofa repeating structure (count = 1) or if there are still more to be returned(count > 1). 
  • Passed to aWriter to indicate how many occurrences of a repeating structure should bewritten out.  For a document-levelhandler, the counter field will contain the total number of occurrences towrite out.  For a node-level handler, thecounter field will indicate if the Handler is receiving the last occurrence ofa repeating structure or if there are still more to write out.


Optional Flag Field

When the Optional Flag Field property is set to “true” for a node, then the generated IDS will contain an additional “flag field” that is associated with the node. 

This property can only be set for non-repeating optional nodes.  For an optional repeating node, the count special field can be used.   An optional flag field is:

* Returned bya Reader to indicate if a node was found in the JSON/XML instance.  If the flag value is set to 1, the node wasfound and the content returned in the IDS field is the content found in thedocument.  If the flag value is 0, thenthe node was not found and the content returned in the IDS field is theinitialized value. 
  • Passed to aWriter to indicate if an optional node should be suppressed or not.  If the flag value is set to 1, then the nodewill be written out.  If the flag is setto 0, the node will not be written out.

Length Field The length field is used to control the length of a variable length field.  If the variable length property is set to “true” for a node, then a length field is automatically inserted into the IDS for the corresponding program data field.  The length field is: * Returned bya Reader to indicate the length of the field read. 
  •  Passedinto a Writer to indicate how many characters of the content should be writtenout for the node.  

    Track Pointers


    Track Pointers are used to indicate the start position of the open tag
    and the end position of a closing tag for a node.  If the Track Pointers property is set to
    “true”, then 2 fields (one for the starting position and one for the end) will
    be automatically inserted in the IDS for the corresponding program data field.



Track pointers are only used by Readers.  The Reader will return the start and end position of the particular JSON/XML node.    Extended Precision

The extended precision special field is used by a Writer to control the decimal precision for a numeric field containing decimals. When the property is set to “true”, an extended precision field is automatically inserted into the IDS and the original field is converted to an integer definition (with no decimal places). For example, a field with a COBOL declaration of PIC 9(11)V9(2) will convert to two fields:

  • One with a declaration of PIC 9(13) to hold all digits in the content (integer and decimal).
  • One with a declaration of PIC S9(3) to hold how many decimal positions the value contains (e.g. -3 indicates that there are 3 decimal positions.



The extended precision field is returned by a Reader to indicate how many decimal positions were found in the document.

Generating Special Fields to a Separate Area in the IDS

Thunder allows you to control how the special fields are generated into the IDS. By default, they are generated directly above their associated field as shown below.

Image

If desired, Thunder provides a setting to generate the special fields to a separate area in the IDS. This can be set at the Toolset or Handler level.

To generate special fields to a separate area at the Handler level, go to Handler -> Properties -> Code Generation and choose “More Options”

Image

Change the Special field setting to “Generate as a separate structure”.

Image

The result will be that that the special fields will be generated to their own separate 01 level in the IDS.

Image