#LyX 1.3 created this file. For more info see http://www.lyx.org/ \lyxformat 221 \textclass book \language american \inputencoding auto \fontscheme default \graphics default \paperfontsize default \spacing single \papersize a4paper \paperpackage a4 \use_geometry 0 \use_amsmath 0 \use_natbib 0 \use_numerical_citations 0 \paperorientation portrait \secnumdepth 3 \tocdepth 3 \paragraph_separation indent \defskip medskip \quotes_language swedish \quotes_times 1 \papercolumns 1 \papersides 1 \paperpagestyle default \layout Standard \pagebreak_bottom \align center \begin_inset ERT status Collapsed \layout Standard \backslash thispagestyle{empty} \end_inset \begin_inset Graphics filename image/txt2xml_107_A4.jpg width 80page% height 95page% BoundingBox 43mm 25mm 595bp 765bp \end_inset \layout Standard \added_space_top 5cm* \paragraph_spacing double \align center \begin_inset ERT status Collapsed \layout Standard \backslash thispagestyle{empty} \end_inset \series bold \size largest TXT2XML \series default : Conversion from text to XML and vice-versa using a COBOL copybook as reference. \layout Standard \added_space_bottom smallskip \paragraph_spacing double \align center \series bold \size largest XML2COB \series default : Generation of a COBOL copybook using an XML file as reference \layout Standard \align center \series bold \size larger Version 1.25 \series default \size default \begin_inset Foot collapsed false \layout Standard \align center copyright - see appendix A \end_inset \layout Standard \pagebreak_top \begin_inset LatexCommand \tableofcontents{} \end_inset \layout Part \begin_inset LatexCommand \label{par:TXT2XML} \end_inset T X T 2 X M L \layout Chapter \begin_inset LatexCommand \label{cha:Introduction} \end_inset Introduction \layout Standard COBOL, a forty years old computer language, and XML a new revolutionary format, seems to as near as the earth and the moon. However, if you look any further, you will notice some common concepts : \layout Standard \align left \begin_inset Tabular \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \size small XML \end_inset \begin_inset Text \layout Standard \size small COBOL \end_inset \begin_inset Text \layout Standard \align left \size small Hierarchy of data \end_inset \begin_inset Text \layout Standard \size small Root and child elements \end_inset \begin_inset Text \layout Standard \size small level 01 and other level items \end_inset \begin_inset Text \layout Standard \align left \size small Indentation for a better visualization \end_inset \begin_inset Text \layout Standard \size small \begin_inset Formula $\surd$ \end_inset \end_inset \begin_inset Text \layout Standard \size small \begin_inset Formula $\surd$ \end_inset \end_inset \begin_inset Text \layout Standard \align left \size small Structured data \end_inset \begin_inset Text \layout Standard \size small Simple and complex elements \end_inset \begin_inset Text \layout Standard \size small Items and grouping items \end_inset \begin_inset Text \layout Standard \align left \size small Occurrence of data \end_inset \begin_inset Text \layout Standard \size small Unique and multiple \end_inset \begin_inset Text \layout Standard \size small OCCURS clause \end_inset \end_inset \layout Standard The need to exchange data in XML between servers is continuously increasing and, in each mainframe around the world, there are plenty of COBOL copybooks and text files. So, was born the idea of TXT2XML : a bridge between the common concepts of COBOL and XML. It's not a GUI \begin_inset LatexCommand \index{GUI} \end_inset \begin_inset Foot collapsed true \layout Standard However, starting with version 1.25, a GUI front-end has been developed. See chapter \begin_inset LatexCommand \ref{cha:The-Graphical-User} \end_inset for more details. \end_inset tool, it's a Rexx script (for more info on Rexx see appendix \begin_inset LatexCommand \ref{cha:Internet-resources} \end_inset ) running in a DOS command interface for the Windows users, a shell for the Unix users, \begin_inset LatexCommand \index{ISPF} \end_inset ISPF or \begin_inset LatexCommand \index{JCL} \end_inset JCL for the mainframe users. \layout Standard TXT2XML is not an XML \begin_inset LatexCommand \index{parser} \end_inset parser written in Rexx, nor will support the entire XML specification. Some COBOL clauses are also not supported (like \begin_inset LatexCommand \index{REDEFINES} \end_inset REDEFINES, \begin_inset LatexCommand \index{DEPENDING} \end_inset DEPENDING, ... ). TXT2XML works in both directions, i.e. it can convert XML files to text files and vice-versa. The COBOL copybook is always mandatory to perform the conversion, because : \layout Itemize During XML to text conversion, XML element \begin_inset LatexCommand \index{element} \end_inset names are checked against the COBOL item names. For example, if there is an XML element like \emph on \emph default , there must be an item like \emph on COBOL-ITEM-01 \emph default in the COBOL copybook. \layout Itemize During text to XML conversion, the COBOL copybook item names are used to build the XML \begin_inset LatexCommand \index{element} \end_inset elements. \layout Itemize During XML to text conversion, if a COBOL item is \begin_inset LatexCommand \index{numeric} \end_inset numeric, the XML \begin_inset LatexCommand \index{content} \end_inset content is checked to see if it's also numeric. Otherwise conversion will fail. \layout Itemize ... \layout Standard TXT2XML was therefore developed primarily to convert data files typically used on a mainframe. TXT2XML works only with \begin_inset LatexCommand \index{well-formed XML document} \end_inset well-formed XML documents and \begin_inset LatexCommand \index{valid COBOL copybook} \end_inset valid COBOL copybooks. TXT2XML will never check for COBOL syntax errors or missing XML closing \begin_inset LatexCommand \index{tag} \end_inset tags. TXT2XML generates 100 % compatible and \begin_inset LatexCommand \index{well-formed XML document} \end_inset well-formed XML files, but it's still your responsibility to validate them against a \begin_inset LatexCommand \index{DTD} \end_inset DTD with an XML \begin_inset LatexCommand \index{parser} \end_inset parser. \layout Standard TXT2XML was originally written on an IBM mainframe running \begin_inset LatexCommand \index{OS/390} \end_inset OS/390 V2R10. But, starting with version 1.15, TXT2XML should also run on the following \begin_inset LatexCommand \index{platform} \end_inset platforms : \layout Itemize Linux, \layout Itemize FreeBSD, \layout Itemize Solaris, \layout Itemize AIX, \layout Itemize HP-UX, \layout Itemize OS/2, \layout Itemize eCS, \layout Itemize DOS, \layout Itemize Win9x/Me/NT/2k/XP, \layout Itemize Amiga, \layout Itemize AROS, \layout Itemize QNX4.x, \layout Itemize QNX6.x, \layout Itemize BeOS, \layout Itemize MacOS X, \layout Itemize EPOC32, \layout Itemize AtheOS, \layout Itemize OpenVMS, \layout Itemize SkyOS, \layout Itemize OpenEdition. \layout Standard As it's impossible to run all those OS, TXT2XML was tested successfully on : \layout Itemize Windows 2K, \layout Itemize Linux Mandrake 10.0, \layout Itemize \begin_inset LatexCommand \index{MVS} \end_inset MVS ( \begin_inset LatexCommand \index{OS/390} \end_inset OS/390 V2R10). \layout Standard It should work without problems on the other \begin_inset LatexCommand \index{platform} \end_inset platforms \begin_inset Foot collapsed false \layout Standard with the exception of binary and packed data. \end_inset . To run TXT2XML on non-mainframe \begin_inset LatexCommand \index{platform} \end_inset platforms, you must first install \begin_inset LatexCommand \index{Regina} \end_inset Regina Rexx or for windows only, Reginald (see chapter \emph on \begin_inset LatexCommand \ref{cha:Installation} \end_inset \emph default ). Should you succeed or encounter problems in running TXT2XML on a non-tested \begin_inset LatexCommand \index{platform} \end_inset platform, please send an e-mail to : \layout Quotation \series bold sunuraxi@users.sourceforge.net \layout Standard TXT2XML is released under the GPL \begin_inset LatexCommand \index{license} \end_inset license (see appendix \begin_inset LatexCommand \ref{cha:License} \end_inset ). \layout Chapter \begin_inset LatexCommand \label{cha:Principles-of-conversion} \end_inset Principles of conversion \layout Standard As said early, conversion occurs only if a \begin_inset LatexCommand \index{valid COBOL copybook} \end_inset valid COBOL copybook is present. The first step in the conversion process is the ... \layout Section \begin_inset LatexCommand \label{sec:COBOL-copybook-analysis} \end_inset COBOL copybook analysis \layout Standard The analysis take place in 3 phases : \layout Subsection \begin_inset LatexCommand \label{sub:Cleaning-the-copybook} \end_inset \begin_inset Quotes erd \end_inset Cleaning \begin_inset Quotes erd \end_inset the copybook \layout Standard In this phase, the copybook is read and : \layout Itemize \begin_inset LatexCommand \index{comment} \end_inset comments are skipped, \layout Itemize Multi-line COBOL declaration are concatenated in one line. \layout Itemize \begin_inset LatexCommand \index{PICTURE} \end_inset PICTURE clauses are replaced by PIC, \layout Itemize \begin_inset LatexCommand \index{sign} \end_inset SIGN clauses are ignored, \layout Itemize IS clauses are ignored, \layout Itemize \begin_inset LatexCommand \index{NATIVE} \end_inset NATIVE clauses are skipped, \layout Itemize X(4) and 9(6) symbols are replaced respectively by XXXX and 999999, \layout Itemize Final dot of COBOL declarations is suppressed, \layout Itemize \align left COBOL declarations are \begin_inset LatexCommand \index{capitalize} \end_inset capitalized. \begin_inset Foot collapsed false \layout Standard According to IBM's COBOL Language Reference (IGYLR204), paragraph 1.1.1.1 COBOL Words with Single-Byte Characters : \begin_inset Quotes erd \end_inset Each lowercase letter is considered to be equivalent to its corresponding uppercase letter, except in non numeric literals \begin_inset Quotes erd \end_inset \end_inset \layout Subsection \begin_inset LatexCommand \label{sub:Extracting-the-meta-data} \end_inset Extracting the meta-data \layout Standard In this phase, the following \begin_inset LatexCommand \index{meta-data} \end_inset meta-data are extracted : \layout Standard \align left \begin_inset Tabular \begin_inset Text \layout Standard Meta-data \end_inset \begin_inset Text \layout Standard Usage \end_inset \begin_inset Text \layout Standard COBOL level \end_inset \begin_inset Text \layout Standard To indent XML element \end_inset \begin_inset Text \layout Standard Name \end_inset \begin_inset Text \layout Standard To create or check XML element tags \end_inset \begin_inset Text \layout Standard Type of data \end_inset \begin_inset Text \layout Standard To check XML data during text to XML conversion \end_inset \begin_inset Text \layout Standard Sign \end_inset \begin_inset Text \layout Standard When converting signed and/or binary data \end_inset \begin_inset Text \layout Standard Sign position \end_inset \begin_inset Text \layout Standard When converting \begin_inset LatexCommand \index{numeric} \end_inset numeric data \end_inset \begin_inset Text \layout Standard Starting position \end_inset \begin_inset Text \layout Standard To create the XML content or a text record \end_inset \begin_inset Text \layout Standard Length \end_inset \begin_inset Text \layout Standard To create the XML content or a text record \end_inset \begin_inset Text \layout Standard Default value \end_inset \begin_inset Text \layout Standard To initialize a text record when converting from XML to text \end_inset \end_inset \layout Standard \begin_inset LatexCommand \index{FILLER} \end_inset FILLER clauses are not skipped. They are used to compute the starting positions of all COBOL items. They never appears in the XML file when the text to XML conversion process ends. The copybook is also checked for unsupported COBOL clauses : \layout Itemize \begin_inset LatexCommand \index{REDEFINES} \end_inset REDEFINES \layout Itemize \begin_inset LatexCommand \index{DEPENDING} \end_inset DEPENDING ON \layout Itemize \align left \begin_inset LatexCommand \index{COMP, COMPUTATIONAL} \end_inset COMPUTATIONAL-1, COMPUTATIONAL-2, COMPUTATIONAL-5, COMP-1, COMP-2, and COMP-5. \layout Itemize \begin_inset LatexCommand \index{POINTER} \end_inset POINTER, PROCEDURE-POINTER and FUNCTION-POINTER \layout Itemize \begin_inset LatexCommand \index{OBJECT REFERENCE} \end_inset OBJECT REFERENCE \layout Itemize \begin_inset LatexCommand \index{NATIONAL} \end_inset NATIONAL \layout Itemize \begin_inset LatexCommand \index{DISPLAY-1} \end_inset DISPLAY-1 \begin_inset Foot collapsed false \layout Standard DBCS items are not supported \end_inset \layout Itemize P symbol (decimal scaling position) \layout Itemize \begin_inset LatexCommand \index{INDEX} \end_inset INDEX \layout Itemize \align left \begin_inset LatexCommand \index{level 66, 77, 88} \end_inset level 66, 77, 88, \begin_inset Foot collapsed false \layout Standard Those levels generate only a warning message and conversion continues. \end_inset \layout Itemize \begin_inset LatexCommand \index{numeric} \end_inset Non-numeric COBOL \begin_inset LatexCommand \index{level} \end_inset levels or COBOL levels greater than 49, \layout Itemize \begin_inset LatexCommand \index{DBCS} \end_inset DBCS \begin_inset LatexCommand \index{PICTURE} \end_inset picture symbols. \layout Standard and for partially supported COBOL clauses : \layout Itemize \begin_inset LatexCommand \index{OCCURS, occurence} \end_inset OCCURS for \begin_inset LatexCommand \index{elementary item} \end_inset elementary and \begin_inset LatexCommand \index{group item} \end_inset group item with only one dimension, \layout Itemize \begin_inset LatexCommand \index{VALUE} \end_inset VALUES except for QUOTES and NULL clauses. \layout Subsection \begin_inset LatexCommand \label{sub:Renumbering-the-COBOL} \end_inset Renumbering the COBOL item levels \layout Standard As COBOL item \begin_inset LatexCommand \index{level} \end_inset levels are used to indent \begin_inset LatexCommand \index{tag} \end_inset tags during text to XML conversion, they are internally renumbered to have a smoother indentation. For example, the following COBOL copybooks : \layout LyX-Code \begin_inset Float figure placement H wide false collapsed false \layout Caption \series bold A sample COBOL copybook \layout LyX-Code \series bold 01 COBOL-ITEM-01. \begin_deeper \layout LyX-Code \series bold 05 FILLER PIC IS X. \layout LyX-Code \series bold 05 COBOL-ITEM-02 PIC IS X(5). \end_inset \layout LyX-Code \layout Standard and \layout LyX-Code \series bold \begin_inset Float figure placement H wide false collapsed false \layout Caption \series bold Same sample COBOL copybook with different levels \layout LyX-Code \series bold 10 COBOL-ITEM-01. \begin_deeper \layout LyX-Code \series bold 20 FILLER PIC IS X. \layout LyX-Code \series bold 20 COBOL-ITEM-02 PIC IS X(5). \end_inset \layout LyX-Code \layout Standard will always give the same indentation, like in the following XML file : \layout LyX-Code \begin_inset Float figure placement H wide false collapsed false \layout Caption Resulting XML file after conversion \layout LyX-Code \series bold \layout LyX-Code \series bold \begin_deeper \layout LyX-Code \series bold \begin_deeper \layout LyX-Code \series bold 12345 \end_deeper \layout LyX-Code \series bold \end_deeper \layout LyX-Code \series bold \end_inset \layout Standard \series bold The original COBOL copybook is never modified by TXT2XML \series default and if the conversion ends without errors, a report of this analysis is printed. \layout Section \begin_inset LatexCommand \label{sec:Text-to-XML} \end_inset Text to XML conversion \layout Standard This is the easiest conversion. An XML header ( \emph on \emph default ) is first created. Then, one text record is read, item data is extracted from the current text record and the XML \begin_inset LatexCommand \index{element} \end_inset elements and their \begin_inset LatexCommand \index{content} \end_inset content are written one by one. The conversion process continues until the end of the text file. The XML \begin_inset LatexCommand \index{element} \end_inset elements can be classified in 3 categories : \layout Itemize \series bold \begin_inset LatexCommand \index{root} \end_inset Root \series default : this \begin_inset LatexCommand \index{element} \end_inset element must be unique in the whole XML file. That's why, DATA, a COBOL reserved word, was chosen as \series bold \begin_inset LatexCommand \index{root} \end_inset \series default root element name. It has no \begin_inset LatexCommand \index{equivalent} \end_inset equivalent in the COBOL copybook. \layout Itemize \series bold \begin_inset LatexCommand \index{First child} \end_inset First child \series default : it appears each time a text record is read. It corresponds to the \begin_inset LatexCommand \index{level} \end_inset level of the first COBOL item in the copybook. As this \series bold \begin_inset LatexCommand \index{First child} \end_inset \series default first child \begin_inset LatexCommand \index{element} \end_inset element will include all the other XML elements, this COBOL item needs to be a \begin_inset LatexCommand \index{group item} \end_inset grouping item,with the lowest \begin_inset LatexCommand \index{level} \end_inset level and ideally with a unique \begin_inset LatexCommand \index{OCCURS, occurence} \end_inset occurrence. \layout Itemize \series bold Other \begin_inset LatexCommand \index{child} \end_inset child elements \series default : The other XML \begin_inset LatexCommand \index{element} \end_inset elements. \layout Standard All of them are built using the following rules : \layout Itemize The name of the XML \begin_inset LatexCommand \index{element} \end_inset element is the \begin_inset LatexCommand \index{capitalize} \end_inset capitalized COBOL item name with \begin_inset LatexCommand \index{dash} \end_inset dashes ( \begin_inset Quotes erd \end_inset \series bold - \series default \begin_inset Quotes erd \end_inset ) translated to \begin_inset LatexCommand \index{underscore} \end_inset underscore ( \begin_inset Quotes erd \end_inset \series bold _ \series default \begin_inset Quotes erd \end_inset ). For example : \emph on COBOL-ITEM-01 \emph default will become \emph on , \layout Itemize \begin_inset LatexCommand \index{content} \end_inset Content of the XML \begin_inset LatexCommand \index{element} \end_inset element is extracted from the current text record (using the starting position and the length computed in section \begin_inset LatexCommand \ref{sec:COBOL-copybook-analysis} \end_inset ). Characters are \begin_inset LatexCommand \index{escape} \end_inset escaped if necessary \begin_inset Foot collapsed false \layout Standard & < > \begin_inset Quotes eld \end_inset and ' need to be converted to & < > " ' respectively. \end_inset , \layout Itemize \begin_inset LatexCommand \index{FILLER} \end_inset FILLER clauses are skipped. \layout Itemize Opened XML \begin_inset LatexCommand \index{tag} \end_inset tags are closed : \begin_deeper \layout Itemize immediately after the \begin_inset LatexCommand \index{content} \end_inset content of an XML \begin_inset LatexCommand \index{element} \end_inset element, \layout Itemize at the end of each COBOL \begin_inset LatexCommand \index{group item} \end_inset grouping item, \layout Itemize at then end of the text record, \layout Itemize at the end of the text file. \end_deeper \layout Standard If requested, TXT2XML can create a \begin_inset LatexCommand \index{DTD} \end_inset DTD (Document Type Definition), based on the COBOL copybook, which describes the XML structure. This \begin_inset LatexCommand \index{DTD} \end_inset DTD can be internal : \layout Standard \begin_inset Float figure placement H wide false collapsed false \layout Caption Internal DTD \layout LyX-Code \layout LyX-Code \end_deeper \layout LyX-Code \end_deeper \layout LyX-Code \layout LyX-Code \layout LyX-Code \layout LyX-Code \layout LyX-Code \layout LyX-Code \layout LyX-Code \layout LyX-Code \layout LyX-Code \layout LyX-Code \layout LyX-Code \layout LyX-Code \end_deeper \layout LyX-Code \layout LyX-Code \layout LyX-Code \layout LyX-Code \end_deeper \layout LyX-Code \layout LyX-Code \layout LyX-Code \end_deeper \layout LyX-Code ]> \layout LyX-Code \begin_deeper \layout LyX-Code \end_deeper \layout LyX-Code ... \end_inset \layout Standard or external : \layout Standard \begin_inset Float figure placement H wide false collapsed false \layout Caption XML file with an external DTD reference \layout LyX-Code \layout LyX-Code \layout LyX-Code \begin_deeper \layout LyX-Code \layout LyX-Code ... \end_inset \layout Section \begin_inset LatexCommand \label{sec:XML-to-text} \end_inset XML to text conversion \layout Standard This conversion is a little bit more difficult and even in some cases impossible. Remember, TXT2XML implements only a subset of XML and COBOL. For example, this XML file : \begin_inset Float figure placement H wide false collapsed false \layout Caption Nonconvertible XML file \layout LyX-Code \series bold \layout LyX-Code \series bold \begin_deeper \layout LyX-Code \series bold \begin_deeper \layout LyX-Code \series bold Blue \layout LyX-Code \series bold Hot and sunny \end_deeper \layout LyX-Code \series bold \end_deeper \layout LyX-Code \series bold \end_inset \layout Standard In this file, the XML \begin_inset LatexCommand \index{element} \end_inset element \series bold city \series default is a complex one. It includes the simple \begin_inset LatexCommand \index{element} \end_inset element \series bold sky \series default but also a \begin_inset LatexCommand \index{content} \end_inset content ( \series bold Hot and sunny \series default ). The corresponding COBOL copybook would be something like : \layout Standard \begin_inset Float figure placement H wide false collapsed false \layout Caption Corresponding COBOL copybook \layout LyX-Code \series bold 01 city pic x(20). \begin_deeper \layout LyX-Code \series bold 03 name pic x(20). \layout LyX-Code \series bold 03 sky pic x(8). \end_inset \layout Standard \align left This is impossible in COBOL : a \begin_inset LatexCommand \index{group item} \end_inset grouping item can't have a \begin_inset LatexCommand \index{PICTURE} \end_inset picture clause. \size footnotesize \begin_inset Foot collapsed false \layout Standard \size footnotesize COBOL for MVS & VM V1R2.2 Language Reference (IGYLR204) paragraph 5.3.11 PICTURE Clause : \begin_inset Quotes eld \end_inset The PICTURE clause can be specified only at the elementary level. \begin_inset Quotes erd \end_inset \end_inset \layout Standard So, not all the XML files can be converted. But, with a \begin_inset LatexCommand \index{valid COBOL copybook} \end_inset valid COBOL copybook, the XML file is read one line at the time and data is extracted using the following rules : \layout Itemize \begin_inset LatexCommand \index{Mixed XML content} \end_inset Mixed XML \begin_inset LatexCommand \index{content} \end_inset content is \series bold not supported \series default , \layout Itemize All the XML \begin_inset LatexCommand \index{tag} \end_inset tags and \begin_inset LatexCommand \index{content} \end_inset contents may expand on more than one line, \layout Itemize XML headers starting with \emph on \emph default are skipped, \layout Itemize XML entities starting with \emph on \begin_inset LatexCommand \index{ENTITY} \end_inset \emph default are \series bold not supported \series default . If such a declaration is found, the conversion process is aborted, \layout Itemize XML internal and external document type declaration starting with \emph on \emph default or \emph on ]> \emph default are skipped, \layout Itemize XML \begin_inset LatexCommand \index{comment} \end_inset comments starting with \emph on \emph default are skipped, \layout Itemize The \series bold \begin_inset LatexCommand \index{First child} \end_inset \series default first child \begin_inset LatexCommand \index{element} \end_inset element is then searched. Each time an XML first child closing \begin_inset LatexCommand \index{tag} \end_inset tag is found, a text record is written and a new text record is initialized with \begin_inset LatexCommand \index{default value} \end_inset default values from the COBOL copybook, \layout Itemize \begin_inset LatexCommand \index{Attribute} \end_inset Attributes of the \series bold \begin_inset LatexCommand \index{First child} \end_inset \series default first child \begin_inset LatexCommand \index{element} \end_inset element are supported. But, attributes of the \series bold \begin_inset LatexCommand \index{root} \end_inset \series default root element are ignored. \layout Itemize Each XML \begin_inset LatexCommand \index{element} \end_inset element, even without a \begin_inset LatexCommand \index{content} \end_inset content, \series bold must \series default have an \begin_inset LatexCommand \index{equivalent} \end_inset equivalent in the COBOL copybook. To find it, the XML element name is \begin_inset LatexCommand \index{capitalize} \end_inset capitalized and \begin_inset LatexCommand \index{underscore} \end_inset underscores are translated to \begin_inset LatexCommand \index{dash} \end_inset dashes. For example : \emph on \emph default will become \emph on COBOL-ITEM-01 \emph default and is searched in the COBOL copybook \emph on , \layout Itemize Each XML \begin_inset LatexCommand \index{attribute} \end_inset attribute \series bold may \series default have an \begin_inset LatexCommand \index{equivalent} \end_inset equivalent in the COBOL copybook, \layout Itemize XML attributes like xml:space are ignored, \layout Itemize Each time a \begin_inset LatexCommand \index{content} \end_inset content is found, it's length and data type are checked against the characterist ics of the corresponding COBOL item. \begin_inset LatexCommand \index{numeric} \end_inset Numeric items are right justified and left zero filled. If necessary characters are \begin_inset LatexCommand \index{escape} \end_inset escaped. \begin_inset Foot collapsed false \layout Standard & < > " ' are converted to & < > \begin_inset Quotes eld \end_inset and ' respectively or content is extracted from CDATA section starting with \emph on \end_inset \layout Itemize If some XML \begin_inset LatexCommand \index{element} \end_inset elements or \begin_inset LatexCommand \index{attribute} \end_inset attributes are missing, conversion continues with the new element found. Missing COBOL items are left to their \begin_inset LatexCommand \index{default value} \end_inset default value (see section \begin_inset LatexCommand \ref{sec:COBOL-copybook-analysis} \end_inset ). \layout Itemize Empty XML \begin_inset LatexCommand \index{element} \end_inset elements, even with \begin_inset LatexCommand \index{attribute} \end_inset attributes, are supported. \layout Chapter \begin_inset LatexCommand \label{cha:Signed-and-binary} \end_inset Signed and binary data \layout Section Warning \layout Standard \added_space_bottom bigskip \begin_inset LatexCommand \index{sign} \end_inset Signed an \begin_inset LatexCommand \index{binary} \end_inset binary data are hardly bound with the operating system and the hardware running TXT2XML. On a PC, binary (and not \begin_inset LatexCommand \index{numeric} \end_inset numeric and \begin_inset LatexCommand \index{packed-decimal} \end_inset packed-decimal) data is stored in \begin_inset LatexCommand \index{little endian} \end_inset little endian mode. It means that the low-order byte of the number is stored in memory at the lowest address, and the high-order byte at the highest address. On a IBM \begin_inset LatexCommand \index{MVS} \end_inset MVS mainframe, \begin_inset LatexCommand \index{binary} \end_inset binary data are stored in the opposite mode : \begin_inset LatexCommand \index{big endian} \end_inset big endian. For example : \layout Standard \begin_inset Tabular \begin_inset Text \layout Standard Hexadecimal data \end_inset \begin_inset Text \layout Standard Little endian (PC) \end_inset \begin_inset Text \layout Standard Big endian (MVS) \end_inset \begin_inset Text \layout Standard x'01 02 03 04 \begin_inset Quotes srs \end_inset \end_inset \begin_inset Text \layout Standard 04 03 02 01 \end_inset \begin_inset Text \layout Standard 01 02 03 04 \end_inset \end_inset \layout Description Conclusion : although TXT2XML runs on multiple \begin_inset LatexCommand \index{platform} \end_inset platforms, you should always run TXT2XML on the platform where you will use the \begin_inset LatexCommand \index{binary} \end_inset binary and/or \begin_inset LatexCommand \index{sign} \end_inset signed converted data. \layout Standard So, forget the idea to run TXT2XML on one \begin_inset LatexCommand \index{platform} \end_inset platform (i.e a PC running Windows) and to transfer the converted file on another platform (i.e. an IBM mainframe). \begin_inset LatexCommand \index{file transfer} \end_inset File transfer means code page (character set) translation which \begin_inset LatexCommand \index{binary} \end_inset binary, \begin_inset LatexCommand \index{packed-decimal} \end_inset packed-decimal and even \begin_inset LatexCommand \index{numeric} \end_inset numeric data don't support. Don't try also to convert a pure EBCDIC file on a non-mainframe \begin_inset LatexCommand \index{platform} \end_inset platform : TXT2XML will never find the XML \begin_inset LatexCommand \index{element} \end_inset element delimiters '<', '/' and '>' or the COBOL \begin_inset LatexCommand \index{equivalent} \end_inset equivalent of an XML \begin_inset LatexCommand \index{element} \end_inset element. In all cases, conversion will stop with an error message. \layout Section COBOL compilers \layout Standard Even if COBOL is standardized, internal representation of \begin_inset LatexCommand \index{sign} \end_inset signed and \begin_inset LatexCommand \index{binary} \end_inset binary data may differ from a compiler to another, from a \begin_inset LatexCommand \index{platform} \end_inset platform to another one, etc. That's why, a small COBOL program was written to create \begin_inset LatexCommand \index{binary} \end_inset binary, \begin_inset LatexCommand \index{packed-decimal} \end_inset packed-decimal and \begin_inset LatexCommand \index{numeric} \end_inset numeric reference data. On IBM mainframe running \begin_inset LatexCommand \index{MVS} \end_inset MVS, compiling it is easy, using a one of the \begin_inset Quotes sls \end_inset Enterprise COBOL for Z/OS' product family. But on Windows and Linux/Unix, there are few compilers, with a active project status, available. On of them is : \begin_inset LatexCommand \index{Tiny-Cobol} \end_inset Tiny-Cobol that you can download from : \layout Quotation \series bold http://tiny-cobol.sourceforge.net/ \layout Standard \begin_inset LatexCommand \index{Tiny-Cobol} \end_inset Tiny-Cobol runs on : \layout Itemize BeOS, \layout Itemize FreeBSD, \layout Itemize Linux, \layout Itemize Windows (with MinGW or Cygwin). \layout Section Internal representation \layout Standard The results of execution of this program on the 3 \begin_inset LatexCommand \index{platform} \end_inset platforms is showed below : \layout Standard \begin_inset Float figure placement H wide false collapsed false \layout Caption Binary, packed-decimal and \begin_inset LatexCommand \index{numeric} \end_inset numeric internal representation \layout Standard \begin_inset Tabular \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \series bold \size scriptsize Internal representation \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \series bold \size scriptsize Numeric type \end_inset \begin_inset Text \layout Standard \series bold \size scriptsize COBOL clauses \end_inset \begin_inset Text \layout Standard \series bold \size scriptsize Value \end_inset \begin_inset Text \layout Standard \series bold \size scriptsize MVS \end_inset \begin_inset Text \layout Standard \series bold \size scriptsize Linux/Unix \end_inset \begin_inset Text \layout Standard \series bold \size scriptsize Windows \end_inset \begin_inset Text \layout Standard \series bold \size scriptsize External decimal \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \align left \size scriptsize PIC 9999 DISPLAY \end_inset \begin_inset Text \layout Standard \size scriptsize 1234 \end_inset \begin_inset Text \layout Standard \size scriptsize F1 F2 F3 F4 \end_inset \begin_inset Text \layout Standard \size scriptsize 31 32 33 34 \end_inset \begin_inset Text \layout Standard \size scriptsize 31 32 33 34 \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \align left \size scriptsize PIC S9999 DISPLAY \end_inset \begin_inset Text \layout Standard \size scriptsize +1234 \end_inset \begin_inset Text \layout Standard \size scriptsize F1 F2 F3 C4 \end_inset \begin_inset Text \layout Standard \size scriptsize 31 32 33 44 \end_inset \begin_inset Text \layout Standard \size scriptsize 31 32 33 44 \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \size scriptsize -1234 \end_inset \begin_inset Text \layout Standard \size scriptsize F1 F2 F3 D4 \end_inset \begin_inset Text \layout Standard \size scriptsize 31 32 33 D4 \end_inset \begin_inset Text \layout Standard \size scriptsize 31 32 33 D4 \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \align left \size scriptsize PIC S9999 DISPLAY SIGN LEADING \end_inset \begin_inset Text \layout Standard \size scriptsize +1234 \end_inset \begin_inset Text \layout Standard \size scriptsize C1 F2 F3 F4 \end_inset \begin_inset Text \layout Standard \size scriptsize 41 32 33 34 \end_inset \begin_inset Text \layout Standard \size scriptsize 41 32 33 34 \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \size scriptsize -1234 \end_inset \begin_inset Text \layout Standard \size scriptsize D1 F2 F3 F4 \end_inset \begin_inset Text \layout Standard \size scriptsize D1 32 33 34 \end_inset \begin_inset Text \layout Standard \size scriptsize D1 32 33 34 \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \align left \size scriptsize PIC S9999 DISPLAY SIGN TRAILING \end_inset \begin_inset Text \layout Standard \size scriptsize +1234 \end_inset \begin_inset Text \layout Standard \size scriptsize F1 F2 F3 C4 \end_inset \begin_inset Text \layout Standard \size scriptsize 31 32 33 44 \end_inset \begin_inset Text \layout Standard \size scriptsize 31 32 33 44 \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \size scriptsize -1234 \end_inset \begin_inset Text \layout Standard \size scriptsize F1 F2 F3 D4 \end_inset \begin_inset Text \layout Standard \size scriptsize 31 32 33 D4 \end_inset \begin_inset Text \layout Standard \size scriptsize 31 32 33 D4 \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \align left \size scriptsize PIC S9999 DISPLAY SIGN LEADING SEPARATE \end_inset \begin_inset Text \layout Standard \size scriptsize +1234 \end_inset \begin_inset Text \layout Standard \size scriptsize 4E F1 F2 F3 F4 \end_inset \begin_inset Text \layout Standard \size scriptsize 4E 31 32 33 34 \end_inset \begin_inset Text \layout Standard \size scriptsize 4E 31 32 33 34 \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \size scriptsize -1234 \end_inset \begin_inset Text \layout Standard \size scriptsize 60 F1 F2 F3 F4 \end_inset \begin_inset Text \layout Standard \size scriptsize 60 31 32 33 34 \end_inset \begin_inset Text \layout Standard \size scriptsize 60 31 32 33 34 \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \align left \size scriptsize PIC S9999 DISPLAY SIGN TRAILING SEPARATE \end_inset \begin_inset Text \layout Standard \size scriptsize +1234 \end_inset \begin_inset Text \layout Standard \size scriptsize F1 F2 F3 F4 4E \end_inset \begin_inset Text \layout Standard \size scriptsize 31 32 33 34 4E \end_inset \begin_inset Text \layout Standard \size scriptsize 31 32 33 34 4E \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \size scriptsize -1234 \end_inset \begin_inset Text \layout Standard \size scriptsize F1 F2 F3 F4 60 \end_inset \begin_inset Text \layout Standard \size scriptsize 31 32 33 34 60 \end_inset \begin_inset Text \layout Standard \size scriptsize 31 32 33 34 60 \end_inset \begin_inset Text \layout Standard \series bold \size scriptsize Binary \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \align left \size scriptsize PIC 9999 COMP-4 \end_inset \begin_inset Text \layout Standard \size scriptsize 1234 \end_inset \begin_inset Text \layout Standard \size scriptsize 04 D2 \end_inset \begin_inset Text \layout Standard \size scriptsize D2 04 \end_inset \begin_inset Text \layout Standard \size scriptsize D2 04 \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \align left \size scriptsize PIC S9999 COMP-4 \end_inset \begin_inset Text \layout Standard \size scriptsize +1234 \end_inset \begin_inset Text \layout Standard \size scriptsize 04 D2 \end_inset \begin_inset Text \layout Standard \size scriptsize D2 04 \end_inset \begin_inset Text \layout Standard \size scriptsize D2 04 \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \size scriptsize -1234 \end_inset \begin_inset Text \layout Standard \size scriptsize FB 2E \end_inset \begin_inset Text \layout Standard \size scriptsize 2E FB \end_inset \begin_inset Text \layout Standard \size scriptsize 2E FB \end_inset \begin_inset Text \layout Standard \series bold \size scriptsize Packed-decimal \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \align left \size scriptsize PIC 9999 COMP-3 \end_inset \begin_inset Text \layout Standard \size scriptsize 1234 \end_inset \begin_inset Text \layout Standard \size scriptsize 01 23 4F \end_inset \begin_inset Text \layout Standard \size scriptsize 01 23 4F \end_inset \begin_inset Text \layout Standard \size scriptsize 01 23 4F \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \align left \size scriptsize PIC S9999 COMP-3 \end_inset \begin_inset Text \layout Standard \size scriptsize +1234 \end_inset \begin_inset Text \layout Standard \size scriptsize 01 23 4C \end_inset \begin_inset Text \layout Standard \size scriptsize 01 23 4C \end_inset \begin_inset Text \layout Standard \size scriptsize 01 23 4C \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \end_inset \begin_inset Text \layout Standard \size scriptsize -1234 \end_inset \begin_inset Text \layout Standard \size scriptsize 01 23 4D \end_inset \begin_inset Text \layout Standard \size scriptsize 01 23 4C \end_inset \begin_inset Text \layout Standard \size scriptsize 01 23 4C \end_inset \end_inset \end_inset \layout Section Low-values, high-values and spaces \layout Standard By default, space-only \begin_inset LatexCommand \index{content} \end_inset contents are ignored in XML. To preserve them, they are included in a \begin_inset LatexCommand \index{CDATA} \end_inset CDATA \begin_inset LatexCommand \index{tag} \end_inset tag. \begin_inset LatexCommand \index{high-value} \end_inset High-values (x'FF') and \begin_inset LatexCommand \index{low-value} \end_inset low-values (x'00') are \begin_inset LatexCommand \index{escape} \end_inset escaped : i.e. converted in a \begin_inset LatexCommand \index{tag} \end_inset tag like � or ÿ respectively. \layout Section Functions \layout Standard To convert text data to and from \begin_inset LatexCommand \index{binary} \end_inset binary, \begin_inset LatexCommand \index{packed-decimal} \end_inset packed-decimal and \begin_inset LatexCommand \index{numeric} \end_inset numeric data, six functions have been written : \layout Subsection* txt2bin \layout Standard It converts text data to \begin_inset LatexCommand \index{binary} \end_inset binary. The parameters of the function are \layout Itemize \series bold \bar under text \series default \bar default is the text to convert. \layout Itemize \series bold \bar under length \series default \bar default is the length in bytes of \begin_inset LatexCommand \index{binary} \end_inset binary data. May only be 2, 4 or 8. \layout Itemize \begin_inset LatexCommand \index{sign} \end_inset \series bold \bar under signed \series default \bar default is a flag to tell that the \begin_inset LatexCommand \index{binary} \end_inset binary item is signed. May only be "Y" or "N". \layout Standard If text data is \begin_inset LatexCommand \index{sign} \end_inset signed and negative, then text data is converted to \begin_inset LatexCommand \index{binary} \end_inset binary and \begin_inset LatexCommand \index{ two's complement} \end_inset two's complement is performed. Returned data is justified to the right and padded with x'00' or x'FF' according to the sign. Finally, \begin_inset LatexCommand \index{binary} \end_inset binary data is reversed for \begin_inset LatexCommand \index{little endian} \end_inset little endian systems. \layout Subsection* txt2pack \layout Standard It converts text data to \begin_inset LatexCommand \index{packed-decimal} \end_inset packed-decimal. The parameters of the function are : \layout Itemize \series bold \bar under text \series default \bar default is the text to convert. \layout Itemize \series bold \bar under length \series default \bar default is the length in bytes of \begin_inset LatexCommand \index{packed-decimal} \end_inset packed-decimal data. \layout Itemize \begin_inset LatexCommand \index{sign} \end_inset \series bold \bar under signed \series default \bar default is a flag to tell that the \begin_inset LatexCommand \index{packed-decimal} \end_inset packed-decimal item is signed. May only be "Y" or "N". \layout Standard If necessary, a leading zero is added to the \begin_inset LatexCommand \index{packed-decimal} \end_inset packed-decimal data so that the number of half-bytes is always odd. Returned data is justified to the right and padded with x'00'. \layout Subsection* txt2num \layout Standard It converts text data to \begin_inset LatexCommand \index{numeric} \end_inset numeric. The parameters of the function are : \layout Itemize \series bold \bar under text \series default \bar default is the text to convert. \layout Itemize \series bold \bar under length \series default \bar default is the length in bytes of \begin_inset LatexCommand \index{numeric} \end_inset numeric data. \layout Itemize \begin_inset LatexCommand \index{sign} \end_inset \series bold \bar under signed \series default \bar default is a flag to tell that the \begin_inset LatexCommand \index{numeric} \end_inset numeric item is signed. May only be "Y" or "N". \layout Itemize \begin_inset LatexCommand \index{sign} \end_inset \series bold \bar under sign position \series default \bar default is a flag to tell where the sign is located. Allowed values are : \begin_inset Quotes sls \end_inset \begin_inset Quotes srs \end_inset (empty quotes - for unsigned data), "L" (for LEADING sign), "T" (for TRAILING sign), "LS" (for LEADING SEPARATE sign) and "TS" (for TRAILING SEPARATE sign). \layout Standard \begin_inset LatexCommand \index{numeric} \end_inset Non-numeric data, like $ or '.', is converted in hexadecimal. Returned data is justified to the right and padded with zeroes. \layout Subsection* bin2txt \layout Standard It converts \begin_inset LatexCommand \index{binary} \end_inset binary data to text. The parameters of the function are \layout Itemize \series bold bin \series default is the binary to convert. \layout Itemize \series bold \bar under length \series default \bar default is the length in bytes of \begin_inset LatexCommand \index{binary} \end_inset binary data. May only be 2, 4 or 8. \layout Itemize \begin_inset LatexCommand \index{sign} \end_inset \series bold \bar under signed \series default \bar default is a flag to tell that the \begin_inset LatexCommand \index{binary} \end_inset binary item is signed. May only be "Y" or "N". \layout Standard Firstly, \begin_inset LatexCommand \index{binary} \end_inset binary data is reversed for \begin_inset LatexCommand \index{little endian} \end_inset little endian systems. If it is \begin_inset LatexCommand \index{sign} \end_inset signed and negative, then \begin_inset LatexCommand \index{ two's complement} \end_inset two's complement is performed before converting it to text. Leading zeroes are removed and eventually the \begin_inset LatexCommand \index{sign} \end_inset sign is added before returning the text data. \layout Subsection* pack2txt \layout Standard It converts \begin_inset LatexCommand \index{packed-decimal} \end_inset packed-decimal data to text. The parameter of the function is : \layout Itemize \series bold \bar under pack \series default \bar default is the \begin_inset LatexCommand \index{packed-decimal} \end_inset packed-decimal data to convert. \layout Standard \begin_inset LatexCommand \index{sign} \end_inset Sign is extracted from the last half-byte of the \begin_inset LatexCommand \index{packed-decimal} \end_inset packed-decimal. Leading zeroes are removed and eventually the sign is added before returning the text data. \layout Subsection* num2txt \layout Standard It converts \begin_inset LatexCommand \index{numeric} \end_inset numeric data to text. The parameters of the function are : \layout Itemize \series bold \bar under num \series default \bar default is the \begin_inset LatexCommand \index{numeric} \end_inset numeric data to convert. \layout Itemize \begin_inset LatexCommand \index{sign} \end_inset \series bold \bar under signed \series default \bar default is a flag to tell that the \begin_inset LatexCommand \index{binary} \end_inset binary item is signed. May only be "Y" or "N". \layout Itemize \begin_inset LatexCommand \index{sign} \end_inset \series bold \bar under sign position \series default \bar default is a flag to tell where the sign is located. Allowed values are : \begin_inset Quotes sls \end_inset \begin_inset Quotes srs \end_inset (empty quotes - for unsigned data), "L" (for LEADING sign), "T" (for TRAILING sign), "LS" (for LEADING SEPARATE sign) and "TS" (for TRAILING SEPARATE sign). \layout Standard \begin_inset LatexCommand \index{numeric} \end_inset Non-numeric data, like $ or '.', is converted from hexadecimal to characters. Leading zeroes are removed and eventually the \begin_inset LatexCommand \index{sign} \end_inset sign is added before returning the text data. \layout Chapter \begin_inset LatexCommand \label{cha:Installation} \end_inset Installation \layout Section \begin_inset LatexCommand \label{sec:Downloading-TXT2XML} \end_inset Downloading TXT2XML \layout Standard Download the latest TXT2XML version from : \layout Quotation \series bold http://sourceforge.net/projects/txt2xml-rexx/ \layout Standard \added_space_bottom medskip and corresponding to your \begin_inset LatexCommand \index{platform} \end_inset platform : \layout Standard \begin_inset Tabular \begin_inset Text \layout Standard File \end_inset \begin_inset Text \layout Standard Platform \end_inset \begin_inset Text \layout Standard txt2xml.v*r*.mvs.zip \end_inset \begin_inset Text \layout Standard MVS \end_inset \begin_inset Text \layout Standard txt2xml.v*r*.win.zip \end_inset \begin_inset Text \layout Standard Windows \end_inset \begin_inset Text \layout Standard txt2xml.v*r*.unix.tar.gz \end_inset \begin_inset Text \layout Standard Linux/Unix \end_inset \end_inset \layout Standard \added_space_top medskip where * are the version and release numbers. Create a new directory and decompress the archive file using your favorite decompression tool. For Unix environment, type in a console : \layout LyX-Code tar xvzf txt2xml.v*r*.unix.tar.gz \layout Standard For \begin_inset LatexCommand \index{MVS} \end_inset MVS \begin_inset LatexCommand \index{platform} \end_inset platform, the zip archive contains 2 files : a 'readme.txt' and an XMIT file that you will upload to the mainframe (see below). \layout Section \begin_inset LatexCommand \label{sec:Under-MVS} \end_inset Under MVS \layout Subsection \begin_inset LatexCommand \label{sub:Installation} \end_inset Installation \layout Standard The installation is straight forward : \layout Enumerate Before uploading TXT2XML on the mainframe, you need to allocate a new dataset with the following characteristics : \emph on recfm=fb \emph default and \emph on lrecl=80 \emph default , \layout Enumerate Unzip the TXT2XML archive and upload \series bold in \series default \begin_inset LatexCommand \index{binary} \end_inset \series bold binary mode \series default the TXT2XML.XMIT file to this dataset on your \begin_inset LatexCommand \index{MVS} \end_inset MVS, \layout Enumerate In TSO, issue the following command : \begin_deeper \layout LyX-Code RECEIVE INDATASET(your.TXT2XML.XMIT.dataset) \end_deeper \layout Enumerate Hit enter when it prompts you for restoring parameters. This will create a new dataset, \layout Enumerate Follow the instructions in the README member of this new dataset. Typically, you will have to exec a Rexx called \begin_inset Quotes erd \end_inset receive \begin_inset Quotes erd \end_inset that will create the TXT2XML EXEC, CNTL and PANEL datasets. \layout Subsection \begin_inset LatexCommand \label{sub:Tests} \end_inset Tests \layout Standard To run the IVP job, edit the TXT2XML member in the TXT2XML.CNTL dataset and change in the entire member : \layout Itemize USERID to your TSO userid, \layout Itemize HLQ to the high level qualifier of TXT2XML. \layout Standard and submit the job. The \begin_inset LatexCommand \index{JCL} \end_inset JCL step names ending with KO should end with a RC = 12 and the \begin_inset LatexCommand \index{JCL} \end_inset JCL step names ending with OK should end with a RC = 0 or 4. \layout Subsection \begin_inset LatexCommand \label{sub:Post-installation} \end_inset Post-installation \layout Standard If you want, you can copy : \layout Itemize the TXT2XML.PANEL(TXT2XML) to your \begin_inset LatexCommand \index{ISPF} \end_inset ISPF panel dataset. \layout Itemize the TXT2XML.EXEC(TXT2XML) to your \begin_inset LatexCommand \index{ISPF} \end_inset ISPF EXEC or REXX dataset. \layout Section \begin_inset LatexCommand \label{sec:Under-Windows} \end_inset Under Windows \layout Subsection \begin_inset LatexCommand \label{sub:Regina-or-Reginald} \end_inset Regina or Reginald Rexx \layout Standard This step is mandatory. You must first download and install the latest Windows version of \begin_inset LatexCommand \index{Regina} \end_inset Regina Rexx from : \layout Quotation \series bold http://sourceforge.net/projects/regina-rexx/ \layout Standard You can alternatively download and install Reginald Rexx from : \layout Quotation \series bold http://www.borg.com/~jglatt/rexx/reginald/reginald.htm \layout Standard Don't forget to add Rexx directory to the \emph on PATH \emph default environment variable (to access it : Start => Parameters => Configuration Panel => System => Advanced => Environment Variables). \layout Subsection Java \layout Standard This step is optional. Starting with version 1.25, a \begin_inset LatexCommand \index{java} \end_inset JAVA \begin_inset LatexCommand \index{GUI} \end_inset GUI front-end for non-mainframe \begin_inset LatexCommand \index{platform} \end_inset platforms has been written. If you want to use it, you must install \begin_inset LatexCommand \index{java} \end_inset Java. See section \begin_inset LatexCommand \ref{sec:Installation3} \end_inset for more details. \layout Subsection \begin_inset LatexCommand \label{sub:Tests-windows} \end_inset Tests \layout Standard In the TXT2XML directory, execute in a DOS command interface window the TXT2XML.BAT file. The first five tests should end with an error, the others not. \layout Section \begin_inset LatexCommand \label{sec:Under-Unix/linux-and} \end_inset Under Unix/Linux and other platforms \layout Subsection \begin_inset LatexCommand \label{sub:Regina-or-Reginald} \end_inset Regina \layout Standard You must first download and install the latest version of \begin_inset LatexCommand \index{Regina} \end_inset Regina Rexx corresponding to your OS from : \layout Quotation \series bold http://sourceforge.net/projects/regina-rexx/ \layout Standard The \begin_inset LatexCommand \index{Regina} \end_inset Regina \begin_inset LatexCommand \index{binary} \end_inset binary should be installed in /usr/bin/ . If it is not the case, modify in the rexx scripts (txt2xml.rexx & xml2cob.rexx), the \begin_inset LatexCommand \index{magic number} \end_inset magic number #!/usr/bin/rexx according to your needs. \layout Subsection Java \layout Standard This step is optional. Starting with version 1.25, a \begin_inset LatexCommand \index{java} \end_inset JAVA \begin_inset LatexCommand \index{GUI} \end_inset GUI front-end for non-mainframe \begin_inset LatexCommand \index{platform} \end_inset platforms has been written. If you want to use it, you must install \begin_inset LatexCommand \index{java} \end_inset Java. See section \begin_inset LatexCommand \ref{sec:Installation3} \end_inset for more details. \layout Subsection \begin_inset LatexCommand \label{sub:Tests-unix} \end_inset Tests \layout Standard In the TXT2XML directory, execute in a shell the ./txt2xml.sh script. The first five tests should end with an error, the others not. \layout Chapter \begin_inset LatexCommand \label{cha:Syntax} \end_inset Syntax \layout Standard The TXT2XML syntax is : \layout Standard \begin_inset Float figure placement H wide false collapsed false \layout Caption TXT2XML syntax \layout LyX-Code \series bold txt2xml \begin_deeper \layout LyX-Code \series bold TXT txt-file \layout LyX-Code \series bold COB cob-file \layout LyX-Code \series bold XML xml-file \layout LyX-Code \series bold FORMAT format \layout LyX-Code \series bold PREFIX prefix \layout LyX-Code \series bold DTD dtd-file \layout LyX-Code \series bold VERBOSE \layout LyX-Code \series bold BROWSE \end_inset \layout Standard All parameters can be typed in any \begin_inset LatexCommand \index{case} \end_inset case (upper, lower or mixed) and only in this order. But, on some \begin_inset LatexCommand \index{case} \end_inset case sensitive operating systems like Linux/Unix, file names must be typed with the correct \begin_inset LatexCommand \index{case} \end_inset case and the TXT2XML command must be typed in lower \begin_inset LatexCommand \index{case} \end_inset case. The file names may include space characters. TXT2XML parameters must be only one line, except if your operating systems allows \begin_inset LatexCommand \index{continuation character} \end_inset continuation characters. \layout Section \begin_inset LatexCommand \label{sec:Mandatory-parameters} \end_inset Mandatory parameters \layout Subsection \begin_inset LatexCommand \label{sub:TXT} \end_inset TXT txt-file \layout Standard It's the name of the input or output (depending on the direction of conversion) text file. There is no \begin_inset LatexCommand \index{default value} \end_inset default value for this parameter. \layout Subsubsection* Under \begin_inset LatexCommand \index{MVS} \end_inset MVS \layout Standard 'txt-file' can be one of the following : \layout Itemize a sequential dataset, \layout Itemize a member of a partitioned dataset, \layout Itemize a DDname. In this case, the DDname must be preceded by 'DD:'. \layout Standard Before running TXT2XML, txt-file must exist, except when doing an XML to text conversion under \begin_inset LatexCommand \index{ISPF} \end_inset ISPF. \layout Subsubsection* For all other \begin_inset LatexCommand \index{platform} \end_inset platforms \layout Standard txt-file has to be a correct file name. The file must exist before running TXT2XML for a text to XML conversion. \layout Subsection \begin_inset LatexCommand \label{sub:COB} \end_inset COB cob-file \layout Standard It's the name of the COBOL copybook file. There is no \begin_inset LatexCommand \index{default value} \end_inset default value for this parameter. \layout Subsubsection* Under \begin_inset LatexCommand \index{MVS} \end_inset MVS \layout Standard \begin_inset Quotes sls \end_inset cob-file \begin_inset Quotes srs \end_inset can be one of the following : \layout Itemize a sequential dataset, \layout Itemize a member of a partitioned dataset, \layout Itemize a DDname. In this case, the DDname must be preceded by 'DD:'. \layout Standard Before running TXT2XML, cob-file must \series bold always \series default exist. \layout Subsubsection* For all other \begin_inset LatexCommand \index{platform} \end_inset platforms \layout Standard cob-file has to be a correct file name. The file must \series bold always \series default exist before running TXT2XML. Since TXT2XML does not handle some COBOL clauses such as \begin_inset LatexCommand \index{REDEFINES} \end_inset \emph on REDEFINES \emph default , etc, it is best to \begin_inset Quotes sls \end_inset clean up \begin_inset Quotes srs \end_inset the copybook by removing all COBOL clauses not handled by the TXT2XML routines. \layout Subsection \begin_inset LatexCommand \label{sub:XML} \end_inset XML xml-file \layout Standard It's the name of the input or output (depending on the direction of conversion) XML file. There is no \begin_inset LatexCommand \index{default value} \end_inset default value for this parameter. \layout Subsubsection* Under \begin_inset LatexCommand \index{MVS} \end_inset MVS \layout Standard \begin_inset Quotes sls \end_inset xml-file \begin_inset Quotes srs \end_inset can be one of the following : \layout Itemize a sequential dataset, \layout Itemize a member of a partitioned dataset, \layout Itemize a DDname. In this case, the DDname must be preceded by 'DD:'. \layout Standard Before running TXT2XML, xml-file must exist, except when doing a text to XML conversion under \begin_inset LatexCommand \index{ISPF} \end_inset ISPF. \layout Subsubsection* For all other \begin_inset LatexCommand \index{platform} \end_inset platforms \layout Standard xml-file has to be a correct file name. The file must exist before running TXT2XML for an XML to text conversion. \layout Subsection \begin_inset LatexCommand \label{sub:FORMAT} \end_inset FORMAT format \layout Standard The value for this parameter may only be (all \begin_inset LatexCommand \index{platform} \end_inset platforms) : \layout Itemize X for text to XML conversion, \layout Itemize T to XML to text conversion. \layout Standard There is no \begin_inset LatexCommand \index{default value} \end_inset default value for this parameter. \layout Section \begin_inset LatexCommand \label{sec:Optional-parameters} \end_inset Optional parameters \layout Subsection \begin_inset LatexCommand \label{sub:Browse} \end_inset BROWSE \layout Standard The \begin_inset LatexCommand \index{default value} \end_inset default value for this parameter is no. \layout Subsubsection* Under \begin_inset LatexCommand \index{MVS} \end_inset MVS \layout Standard Only under \begin_inset LatexCommand \index{ISPF} \end_inset ISPF and if present, will browse the conversion results report. \layout Subsubsection* For all other \begin_inset LatexCommand \index{platform} \end_inset platforms \layout Standard On all other platforms, this parameter is ignored. \layout Subsection \begin_inset LatexCommand \label{sub:verbose} \end_inset VERBOSE \layout Standard If present, displays all the messages. The \begin_inset LatexCommand \index{default value} \end_inset default value is no, all messages are not displayed. \layout Subsection \begin_inset LatexCommand \label{sub:XML} \end_inset \begin_inset LatexCommand \index{DTD} \end_inset DTD dtd-file \layout Standard This parameter is only valid during text to XML conversion. It's the name of an optional output \begin_inset LatexCommand \index{DTD} \end_inset DTD file or the value \begin_inset Quotes sls \end_inset INTERNAL' for a DTD included in the XML file. There is no \begin_inset LatexCommand \index{default value} \end_inset default value for this parameter. if omitted, no \begin_inset LatexCommand \index{DTD} \end_inset DTD will be created. \layout Subsubsection* Under \begin_inset LatexCommand \index{MVS} \end_inset MVS \layout Standard \begin_inset Quotes sls \end_inset dtd-file \begin_inset Quotes srs \end_inset can be one of the following : \layout Itemize a sequential dataset, \layout Itemize a member of a partitioned dataset, \layout Itemize a DDname. In this case, the DDname must be preceded by 'DD:'. \layout Standard Before running TXT2XML under \begin_inset LatexCommand \index{ISPF} \end_inset ISPF, dtd-file must not exist. \layout Subsubsection* For all other \begin_inset LatexCommand \index{platform} \end_inset platforms \layout Standard dtd-file has to be a correct file name. \layout Subsection \begin_inset LatexCommand \label{sub:prefix} \end_inset PREFIX prefix \layout Standard If present : \layout Itemize During text to XML conversion, if prefix value is 'COBOL-' then the COBOL item COBOL-ITEM-01 will be converted to . \layout Itemize During XML to text conversion, if prefix value is 'COBOL-' then the XML \begin_inset LatexCommand \index{element} \end_inset element will be checked against the COBOL item COBOL-ITEM-01. \layout Standard There is no \begin_inset LatexCommand \index{default value} \end_inset default value for this parameter. \layout Subsubsection* Under \begin_inset LatexCommand \index{MVS} \end_inset MVS batch (JCL) \layout Standard The \begin_inset LatexCommand \index{dash} \end_inset dash ('-') used in COBOL item name, like COBOL-ITEM-01, is taken for a \begin_inset LatexCommand \index{continuation character} \end_inset continuation character in \begin_inset LatexCommand \index{JCL} \end_inset JCL. If you use prefix within a batch job, replace all \begin_inset LatexCommand \index{dash} \end_inset dashes ('-') in the COBOL item name by \begin_inset LatexCommand \index{underscore} \end_inset underscores ('_'). \layout Chapter \begin_inset LatexCommand \label{cha:Exemples} \end_inset Examples \layout Standard You will find here some examples of TXT2XML. You will find more examples in the test script files (see section \begin_inset LatexCommand \ref{sub:Tests} \end_inset , section \begin_inset LatexCommand \ref{sub:Tests-unix} \end_inset , or section \begin_inset LatexCommand \ref{sub:Tests-windows} \end_inset ) or in the IVP job. \layout Section \begin_inset LatexCommand \label{sec:MVS} \end_inset \begin_inset LatexCommand \index{MVS} \end_inset MVS \layout Subsection \begin_inset LatexCommand \label{sub:ISPF} \end_inset ISPF \layout Standard Just type \begin_inset Quotes sls \end_inset \series bold exec \series default ' in front of the TXT2XML member of the EXEC dataset and the \begin_inset LatexCommand \index{ISPF} \end_inset ISPF panel will appear : \layout Standard \begin_inset Float figure placement H wide false collapsed false \layout Caption ISPF panel \layout LyX-Code \align center \begin_inset Graphics filename image/tn3270_01.jpg width 80text% BoundingBox 20mm 0bp 972bp 669bp \end_inset \end_inset \layout Standard Fill the required parameters, hit enter and you will see : \layout Standard \begin_inset Float figure placement H wide false collapsed false \layout Caption Browsing result dataset \layout Standard \align center \begin_inset Graphics filename image/tn3270_02.jpg width 80text% BoundingBox 20mm 0bp 972bp 669bp \end_inset \end_inset \layout Subsection \begin_inset LatexCommand \label{sub:Batch} \end_inset Batch \layout Standard \align left If you submit the following \begin_inset LatexCommand \index{JCL} \end_inset JCL : \begin_inset Float figure placement H wide false collapsed false \layout Caption Job to be submitted \layout Standard \align center \begin_inset Graphics filename image/tn3270_03.jpg width 80text% BoundingBox 20mm 0bp 972bp 669bp \end_inset \end_inset \layout Standard You will get : \layout Standard \begin_inset Float figure placement H wide false collapsed false \layout Caption Resulting job log \layout Standard \align center \begin_inset Graphics filename image/tn3270_04.jpg width 80text% BoundingBox 20mm 0bp 972bp 669bp \end_inset \end_inset \layout Section \begin_inset LatexCommand \label{sec:Windows} \end_inset Windows \layout Standard In a DOS command interface window and in the TXT2XML directory, just type : \layout Standard \begin_inset Float figure placement H wide false collapsed false \layout Caption Windows example \layout Standard \align left \series bold \size footnotesize D: \backslash REXX \backslash txt2xml>txt2xml.rexx txt . \backslash sample \backslash txt \backslash database cob . \backslash sample \backslash cob \backslash database xml . \backslash sample \backslash xml \backslash database format txt \end_inset \layout Standard and you will get : \layout Standard \begin_inset Float figure placement H wide false collapsed false \layout Caption Resulting message log \layout LyX-Code \series bold \size footnotesize TXT2XML: Text from & to XML Conversion Utility. Version: 1.2 \layout LyX-Code \series bold \size footnotesize TXT2XML: \layout LyX-Code \series bold \size footnotesize TXT2XML: ==>Warning : in text record number 1 , COBOL item ADMINISTRATOR starting at 115 \layout LyX-Code \series bold \size footnotesize TXT2XML: is filled with default values because the corresponding XML equivalent was not found \layout LyX-Code \series bold \size footnotesize TXT2XML: ==>Warning : in text record number 1 , COBOL item EMAILALIAS starting at 135 \layout LyX-Code \series bold \size footnotesize TXT2XML: is filled with default values because the corresponding XML equivalent was not found \layout LyX-Code \series bold \size footnotesize TXT2XML: ==>Warning : in text record number 1 , COBOL item EXTENSION starting at 145 \layout LyX-Code \series bold \size footnotesize TXT2XML: is filled with default values because the corresponding XML equivalent was not found \layout LyX-Code \series bold \size footnotesize TXT2XML: ==>Warning : in text record number 1 , COBOL item ADMINISTRATOR starting at 149 \layout LyX-Code \series bold \size footnotesize TXT2XML: is filled with default values because the corresponding XML equivalent was not found \layout LyX-Code \series bold \size footnotesize TXT2XML: ==>Warning : in text record number 1 , COBOL item EMAILALIAS starting at 169 \layout LyX-Code \series bold \size footnotesize TXT2XML: is filled with default values because the corresponding XML equivalent was not found \layout LyX-Code \series bold \size footnotesize TXT2XML: ==>Warning : in text record number 1 , COBOL item EXTENSION starting at 179 \layout LyX-Code \series bold \size footnotesize TXT2XML: is filled with default values because the corresponding XML equivalent was not found \layout LyX-Code \series bold \size footnotesize TXT2XML: ==>Warning : in text record number 2 , COBOL item ADMINISTRATOR starting at 149 \layout LyX-Code \series bold \size footnotesize TXT2XML: is filled with default values because the corresponding XML equivalent was not found \layout LyX-Code \series bold \size footnotesize TXT2XML: ==>Warning : in text record number 2 , COBOL item EMAILALIAS starting at 169 \layout LyX-Code \series bold \size footnotesize TXT2XML: is filled with default values because the corresponding XML equivalent was not found \layout LyX-Code \series bold \size footnotesize TXT2XML: ==>Warning : in text record number 2 , COBOL item EXTENSION starting at 179 \layout LyX-Code \series bold \size footnotesize TXT2XML: is filled with default values because the corresponding XML equivalent was not found \layout LyX-Code \series bold \size footnotesize TXT2XML: ==>Warning : in text record number 3 , COBOL item EXTENSION starting at 179 \layout LyX-Code \series bold \size footnotesize TXT2XML: is filled with default values because the corresponding XML equivalent was not found \layout LyX-Code \series bold \size footnotesize TXT2XML: \layout LyX-Code \series bold \size footnotesize TXT2XML: Txt File: . \backslash sample \backslash txt \backslash database \layout LyX-Code \series bold \size footnotesize TXT2XML: Cobol File: . \backslash sample \backslash cob \backslash database \layout LyX-Code \series bold \size footnotesize TXT2XML: XML File: . \backslash sample \backslash xml \backslash database \layout LyX-Code \series bold \size footnotesize TXT2XML: Output data format: TXT \layout LyX-Code \series bold \size footnotesize TXT2XML: Text records: 3 processed in .29000 seconds \layout LyX-Code \series bold \size footnotesize ... \end_inset \layout Section \begin_inset LatexCommand \label{sec:Unix} \end_inset Unix/Linux \layout Standard In a shell, just type in lower \begin_inset LatexCommand \index{case} \end_inset case in the TXT2XML directory : \layout LyX-Code \begin_inset Float figure placement H wide false collapsed false \layout Caption Unix/Linux example. \layout LyX-Code \series bold ./txt2xml.rexx txt ./sample/txt/text01 cob \layout LyX-Code \series bold ./sample/cob/cobol01 xml ./sample/xml/xml01 format xml \end_inset \layout Standard The XML file should look like : \layout Standard \begin_inset Float figure placement H wide false collapsed false \layout Caption Resulting XML file \layout LyX-Code \series bold \size footnotesize \layout LyX-Code \series bold \size footnotesize \layout LyX-Code \series bold \size footnotesize \begin_deeper \layout LyX-Code \series bold \size footnotesize \begin_deeper \layout LyX-Code \series bold \size footnotesize 12<45 \layout LyX-Code \series bold \size footnotesize 67>90 \layout LyX-Code \series bold \size footnotesize \begin_deeper \layout LyX-Code \series bold \size footnotesize 1&3 \layout LyX-Code \series bold \size footnotesize 4 \layout LyX-Code \series bold \size footnotesize 5 \end_deeper \layout LyX-Code \series bold \size footnotesize \layout LyX-Code \series bold \size footnotesize \layout LyX-Code \series bold \size footnotesize 678 \begin_deeper \layout LyX-Code \series bold \size footnotesize 9 \layout LyX-Code \series bold \size footnotesize 0 \end_deeper \layout LyX-Code \series bold \size footnotesize \layout LyX-Code \series bold \size footnotesize \begin_deeper \layout LyX-Code \series bold \size footnotesize 123 \layout LyX-Code \series bold \size footnotesize 4 \layout LyX-Code \series bold \size footnotesize 5 \end_deeper \layout LyX-Code \series bold \size footnotesize \layout LyX-Code \series bold \size footnotesize \begin_deeper \layout LyX-Code \series bold \size footnotesize 678 \layout LyX-Code \series bold \size footnotesize 9 \layout LyX-Code \series bold \size footnotesize 0 \end_deeper \layout LyX-Code \series bold \size footnotesize \layout LyX-Code \series bold \size footnotesize 1234 \layout LyX-Code \series bold \size footnotesize 567890 \layout LyX-Code \series bold \size footnotesize \begin_deeper \layout LyX-Code \series bold \size footnotesize 12345 \layout LyX-Code \series bold \size footnotesize 67890 \layout LyX-Code \series bold \size footnotesize 12345 \layout LyX-Code \series bold \size footnotesize 67890 \layout LyX-Code \series bold \size footnotesize 123456789012345 \layout LyX-Code \series bold \size footnotesize 6789 \end_deeper \layout LyX-Code \series bold \size footnotesize \end_deeper \layout LyX-Code \series bold \size footnotesize \layout LyX-Code \series bold \size footnotesize ... \end_deeper \layout LyX-Code \series bold \size footnotesize \end_inset \layout Standard with this message log : \layout Standard \begin_inset Float figure placement H wide false collapsed false \layout Caption Log of the conversion \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: Text from & to XML Conversion Utility. Version: 1.2 \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: ==>Warning : in the COBOL copybook, level 66, 77, 88 items are ignored. \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: ==>Warning : in the COBOL copybook, level 66, 77, 88 items are ignored. \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: ==>Warning : in the COBOL copybook, level 66, 77, 88 items are ignored. \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: Txt File: ./sample/txt/text01 \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: Cobol File: ./sample/cob/cobol01 \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: XML File: ./sample/xml/xml01 \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: Output data format: XML \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: Text records: 10 processed in .03286 seconds \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: ======================================================================= ========= \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: COBOL copybook analysis \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: +-------+-------------------------------------+-------+-------+-------- +---------------+ \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | Level | Name | Type | Start | Length | Default value | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: +-------+-------------------------------------+-------+-------+-------- +---------------+ \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 1 | COBOL-ITEM-01 | GROUP | 1 | 0 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 2 | FILLER | CHAR | 1 | 1 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 2 | COBOL-ITEM-02 | CHAR | 2 | 5 | AB"CD | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 2 | COBOL-ITEM-02 | CHAR | 7 | 5 | AB"CD | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 2 | COBOL-ITEM-03 | GROUP | 12 | 0 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 3 | COBOL-ITEM-04 | CHAR | 12 | 3 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 3 | COBOL-ITEM-05 | CHAR | 15 | 1 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 3 | COBOL-ITEM-06 | NUM | 16 | 1 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 2 | COBOL-ITEM-03 | GROUP | 17 | 0 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 3 | COBOL-ITEM-04 | CHAR | 17 | 3 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 3 | COBOL-ITEM-05 | CHAR | 20 | 1 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 3 | COBOL-ITEM-06 | NUM | 21 | 1 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 2 | COBOL-ITEM-03 | GROUP | 22 | 0 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 3 | COBOL-ITEM-04 | CHAR | 22 | 3 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 3 | COBOL-ITEM-05 | CHAR | 25 | 1 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 3 | COBOL-ITEM-06 | NUM | 26 | 1 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 2 | COBOL-ITEM-03 | GROUP | 27 | 0 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 3 | COBOL-ITEM-04 | CHAR | 27 | 3 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 3 | COBOL-ITEM-05 | CHAR | 30 | 1 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 3 | COBOL-ITEM-06 | NUM | 31 | 1 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 2 | COBOL-ITEM-08 | NUM | 32 | 4 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 2 | COBOL-ITEM-09 | CHAR | 36 | 6 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 2 | COBOL-ITEM-12 | GROUP | 42 | 0 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 3 | COBOL-ITEM-13 | NUM | 42 | 5 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 3 | COBOL-ITEM-13 | NUM | 47 | 5 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 3 | COBOL-ITEM-13 | NUM | 52 | 5 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 3 | COBOL-ITEM-13 | NUM | 57 | 5 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 3 | COBOL-ITEM-14 | CHAR | 62 | 15 | | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: | 3 | COBOL-ITEM-15 | NUM | 77 | 4 | 0000 | \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: +-------+-------------------------------------+-------+-------+-------- +---------------+ \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: \layout LyX-Code \align block \series bold \size footnotesize TXT2XML: Total computed COBOL length : 80 \layout LyX-Code \end_inset \layout Part \pagebreak_top \pagebreak_bottom X M L 2 C O B \layout Chapter \begin_inset LatexCommand \label{cha:Introduction2} \end_inset Introduction \layout Standard XML2COB is a complementary tool of TXT2XML. It generates a COBOL copybook, using an XML file as template. Of course, you can use the generated COBOL copybook to convert, with TXT2XML, XML files to text files and vice-versa. However, like TXT2XML, it is not an XML \begin_inset LatexCommand \index{parser} \end_inset parser written in Rexx, nor will support the entire XML specification. \layout Standard XML2COB works only with \begin_inset LatexCommand \index{well-formed XML document} \end_inset well-formed XML documents. For example, it will never check for missing XML closing \begin_inset LatexCommand \index{tag} \end_inset tags. XML2COB generates \begin_inset LatexCommand \index{valid COBOL copybook} \end_inset valid COBOL copybooks, but it's still your responsibility to check COBOL clauses like : \layout Itemize \begin_inset LatexCommand \index{OCCURS, occurence} \end_inset OCCURS \layout Itemize \begin_inset LatexCommand \index{PICTURE} \end_inset PICTURE (symbol and length of the item). \layout Itemize \begin_inset LatexCommand \index{sign} \end_inset SIGN \layout Standard As TXT2XML, XML2COB was tested successfully on : \layout Itemize Windows 2K, \layout Itemize Linux Mandrake 10.1, \layout Itemize \begin_inset LatexCommand \index{MVS} \end_inset MVS ( \begin_inset LatexCommand \index{OS/390} \end_inset OS/390 V2R10). \layout Standard It should work without problems on other \begin_inset LatexCommand \index{platform} \end_inset platforms. To run XML2COB on non-mainframe platforms, you must first install \begin_inset LatexCommand \index{Regina} \end_inset Regina Rexx or for windows only, Reginald (see chapter \emph on \begin_inset LatexCommand \ref{cha:Installation} \end_inset \emph default ). Optionally, for the \begin_inset LatexCommand \index{GUI} \end_inset GUI front-end, you may also install \begin_inset LatexCommand \index{java} \end_inset Java (see \begin_inset LatexCommand \ref{sec:Installation3} \end_inset for more details). Should you succeed or encounter problems in running XML2COB on a non-tested \begin_inset LatexCommand \index{platform} \end_inset platform, please send an e-mail to : \layout Quotation \series bold sunuraxi@users.sourceforge.net \layout Standard XML2COB is released under the GPL \begin_inset LatexCommand \index{license} \end_inset license (see appendix \begin_inset LatexCommand \ref{cha:License} \end_inset ). \layout Chapter \begin_inset LatexCommand \label{cha:Principles-of-generation} \end_inset Principles of generation \layout Standard Except for some constraints (see section \begin_inset LatexCommand \ref{sec:Constraints} \end_inset ), there is no special requirements about the XML file used for the generation. However, there is a gold rule : the bigger the XML file is, more accurate will be the generated COBOL copybook. The reason is very simple : a bigger file means more \begin_inset LatexCommand \index{tag} \end_inset tags, more \begin_inset LatexCommand \index{content} \end_inset contents analyzed, and more accuracy in ... \layout Section \begin_inset LatexCommand \label{sec:The-meta-data} \end_inset The meta-data \layout Standard The following \begin_inset LatexCommand \index{meta-data} \end_inset meta-data are extracted from the XML \begin_inset LatexCommand \index{element} \end_inset elements, \begin_inset LatexCommand \index{attribute} \end_inset attributes and \begin_inset LatexCommand \index{content} \end_inset content : \layout Standard \align left \begin_inset Tabular \begin_inset Text \layout Standard Meta-data \end_inset \begin_inset Text \layout Standard Usage \end_inset \begin_inset Text \layout Standard Element name \end_inset \begin_inset Text \layout Standard To create the COBOL item names \end_inset \begin_inset Text \layout Standard Type of content \end_inset \begin_inset Text \layout Standard To create the PICTURE clause \end_inset \begin_inset Text \layout Standard Sign position \end_inset \begin_inset Text \layout Standard To create SIGN clause \end_inset \begin_inset Text \layout Standard Length \end_inset \begin_inset Text \layout Standard To create the PICTURE clause \end_inset \begin_inset Text \layout Standard Occurrence \end_inset \begin_inset Text \layout Standard To create the OCCURS clause \end_inset \end_inset \layout Section \begin_inset LatexCommand \label{sec:The-COBOL-copybook-generation} \end_inset The COBOL copybook generation \layout Standard In an XML file, the \begin_inset LatexCommand \index{element} \end_inset elements can be classified in 3 categories : \layout Itemize \series bold \begin_inset LatexCommand \index{root} \end_inset Root \series default : the first XML \begin_inset LatexCommand \index{element} \end_inset element. It's ignored in the generation process and is not part of the generated COBOL copybook. \layout Itemize \series bold \begin_inset LatexCommand \index{First child} \end_inset First child \series default : the second XML \begin_inset LatexCommand \index{element} \end_inset element. Each time it appears, the \begin_inset LatexCommand \index{meta-data} \end_inset meta-data analysis of the XML elements is (re-)started. It corresponds to the first COBOL item in the copybook. As this \series bold \begin_inset LatexCommand \index{First child} \end_inset \series default first child element includes all the other XML elements, its corresponding COBOL item is a \begin_inset LatexCommand \index{group item} \end_inset grouping item, with the lowest \begin_inset LatexCommand \index{level} \end_inset level and a unique \begin_inset LatexCommand \index{OCCURS, occurence} \end_inset occurrence. \layout Itemize \series bold Other \begin_inset LatexCommand \index{child} \end_inset child elements \series default : the other XML \begin_inset LatexCommand \index{element} \end_inset elements. They are analyzed to extract the \begin_inset LatexCommand \index{meta-data} \end_inset meta-data needed to build the rest of the COBOL copybook. \layout Standard The COBOL copybook generation process take place in the following steps : \layout Itemize The XML file is read record per record until the end of the file. \layout Itemize The \series bold \begin_inset LatexCommand \index{First child} \end_inset \series default first child is then searched. \layout Itemize Each XML \begin_inset LatexCommand \index{element} \end_inset element or attributes generates a COBOL item applying the following rules : \begin_deeper \layout Itemize The name of the XML \begin_inset LatexCommand \index{element} \end_inset element or \begin_inset LatexCommand \index{attribute} \end_inset attribute is \begin_inset LatexCommand \index{capitalize} \end_inset capitalized and \begin_inset LatexCommand \index{dash} \end_inset dashes ( \begin_inset Quotes erd \end_inset \series bold - \series default \begin_inset Quotes erd \end_inset ) are translated to \begin_inset LatexCommand \index{underscore} \end_inset underscore ( \begin_inset Quotes erd \end_inset \series bold _ \series default \begin_inset Quotes erd \end_inset ). For example : \emph on \emph default becomes \emph on COBOL-ITEM-01 \emph default . COBOL item names are checked against a COBOL reserved word list \begin_inset Foot collapsed false \layout Standard according to IBM's "Enterprise COBOL for z/OS V3R3 Language Reference "(IGY3LR20 ) \end_inset . A warning message is issued if the generated item name appears in this list, \layout Itemize \begin_inset LatexCommand \index{meta-data} \end_inset Meta-data of the \begin_inset LatexCommand \index{content} \end_inset content \begin_inset Foot collapsed false \layout Standard Content is escaped if necessary. Characters like & < > \begin_inset Quotes eld \end_inset and ' are converted to & < > " ' respectively. \end_inset of the XML \begin_inset LatexCommand \index{element} \end_inset element and \begin_inset LatexCommand \index{attribute} \end_inset attributes is extracted : length, type and \begin_inset LatexCommand \index{sign} \end_inset sign. \layout Itemize Length of item is rounded if requested (see sub-section \begin_inset LatexCommand \ref{sub:round} \end_inset ). A COBOL item is then created. \end_deeper \layout Itemize Each time the XML \series bold \begin_inset LatexCommand \index{First child} \end_inset \series default first child is found, the analysis is restarted and the \begin_inset LatexCommand \index{meta-data} \end_inset meta-data is updated if necessary. For example, if the \begin_inset LatexCommand \index{content} \end_inset content length of an XML \begin_inset LatexCommand \index{element} \end_inset element is greater than the current length of its corresponding COBOL item, the length is updated. The contrary is, of course, not true. \layout Itemize When the end of the XML file is reached : \begin_deeper \layout Itemize The item list is then checked against \begin_inset LatexCommand \index{elementary item} \end_inset elementary or \begin_inset LatexCommand \index{group item} \end_inset grouping items \begin_inset LatexCommand \index{OCCURS, occurence} \end_inset occurring more than one time. If this is the case, only the first occurrence of the item is kept, the others are deleted and an \begin_inset LatexCommand \index{OCCURS, occurence} \end_inset occurrence counter is created \layout Itemize The starting position of each COBOL item is computed. Although, it's not necessary for the COBOL copybook, it is used for final reporting. \layout Itemize The COBOL copybook is written, indenting the items according to their COBOL level. \end_deeper \layout Section \begin_inset LatexCommand \label{sec:COBOL-level} \end_inset COBOL level \layout Standard COBOL \begin_inset LatexCommand \index{level} \end_inset levels are not part of the XML file. They are computed using the following rules : \layout Itemize At each XML \series bold \begin_inset LatexCommand \index{First child} \end_inset \series default first child, \begin_inset LatexCommand \index{level} \end_inset level starts at 01 or 02 according to the \emph on level01 \emph default parameter (see sub-section \begin_inset LatexCommand \ref{sub:level01} \end_inset ) \layout Itemize The \begin_inset LatexCommand \index{level} \end_inset level of COBOL item increases : \begin_deeper \layout Itemize at each XML \begin_inset LatexCommand \index{element} \end_inset element \layout Itemize at each XML \begin_inset LatexCommand \index{content} \end_inset content \layout Itemize at each XML \begin_inset LatexCommand \index{attribute} \end_inset attribute \end_deeper \layout Itemize The \begin_inset LatexCommand \index{level} \end_inset level of COBOL item decreases : \begin_deeper \layout Itemize at each XML empty \begin_inset LatexCommand \index{element} \end_inset element \layout Itemize after each XML \begin_inset LatexCommand \index{content} \end_inset content \layout Itemize after each XML closing \begin_inset LatexCommand \index{tag} \end_inset tag, \layout Itemize after each XML \begin_inset LatexCommand \index{attribute} \end_inset attribute. \end_deeper \layout Standard For example, with the following XML file, \layout Standard \begin_inset Float figure placement H wide false collapsed false \layout Caption an XML file with attributes and content \layout LyX-Code \size small \layout LyX-Co