1- Why
If you frequently parse the same XML stream file to the same database file, after a while you will start
wondering about the opportunity of a single command that would easily take you through commands RNMXMLFLDS, CRTTODBF and XMLPARSE without having to key in each of them.
2- SUPERPARSE
That single command is named SUPERPARSE and looks as follow:
Super-Parse a XML stream file (SUPERPARSE)
Type choices, press Enter.
XML stream file . . . . . . . . STMF > '/ez4parse/examples/books.xml'
Path to the XML elements . . . . XMLPTH *AUTO
Number of segments in XMLPTH . . XMLPTHNBR 2 1-99
Intermediate XML stream file . . MIDSTMF > '/tmp/mybooks.xml'
Edit DDS for TOFILE creation . . EDTDDS *NO *YES, *NO
Target database file . . . . . . TOFILE > BOOKS Name
library . . . . . . . . . . . > QGPL Name, *LIBL, *CURLIB
Take default parsing options . . DFTOPTIONS *NO *YES, *NO
1.CCSID parsing option . . . . CCSID *BEST *BEST, *JOB, *UCS2
2.TRIM parsing option . . . . . TRIM *ALL *ALL, *NONE
3.ALLOWMISSING parsing option ALWMISSING *YES *YES, *NO
4.ALLOWEXTRA parsing option . . ALWEXTRA *YES *YES, *NO
Additional Parameters
Load from XML record number . . FROMRCD *START Number, *START
Load to XML record number . . . TORCD *END Number, *END
|
|
Figure 1 - Command SUPERPARSE |
Try it:
SUPERPARSE STMF('/ez4parse/examples/books.xml') MIDSTMF('/tmp/mybooks.xml') TOFILE(QGPL/BOOKS) |
- XML stream file (STMF):
Path and name of the original XML stream file whose data element ("field") names may need to be renamed.
Note: The size of this file cannot exceed 15 Mb.
- Path to the XML elements (XMLPTH):
See the explanations given for this same parameter in command XMLPARSE.
If a path (instead of *AUTO) is specified, some attention should be payed, as the path (example: Roset/Row)
is case sensitive and must perfectly match the corresponding HTML tags.
- Number of segments in XMLPTH (XMLPTHNBR):
See the explanations given for this same parameter in command XMLPARSE.
- Intermediate XML stream file (MIDSTMF):
Stream file to contain the copy of the original XML stream file where the XML fields have been renamed.
Note: This output stream file does not have to exist. If existing, it is deleted and is created from this command.
Note: If you leave the default *AUTO, the program creates a temporary stream file and deletes it when the work is done.
We recommend that for a given "original XML stream file" (parameter STMF) you always explicitly specify the same output XML stream file in parameter MIDSTMF.
In fact, by doing this the utility remembers the field renames previously performed and you do not to have to re-enter them, thus saving a lot of time.
- Edit DDS for TOFILE creation (EDTDDS):
Whether the DDS for creating the "TO" database file should be edited before it is created.
Note: Select *YES if you want to review the file specifications or add keywords.
- Target database file (TOFILE):
Qualified name of the database file intended to receive the XML data. If already existing, it is deleted before its creation.
- ... ... ... for the other parameters see command XMLPARSE ... ... ...
Command Entry EASY400
Request level: 4
Previous commands and messages:
> SUPERPARSE STMF('/ez4parse/examples/books.xml') MIDSTMF('/tmp/mybooks.xml
') TOFILE(QGPL/BOOKS)
--- Program SUPERPARSE started.
--- Program RNMXMLFLDS started.
--- Program RNMXMLFLDS successfully completed.
--- Program CRTTODBF started.
--- Program CRTTODBF successfully completed.
--- Program XLPARSE started.
12 records loaded to file QGPL/BOOKS, member BOOKS.
--- Program XLPARSE successfully completed.
--- Program SUPERPARSE successfully completed.
Bottom
Type command, press Enter.
===>
F3=Exit F4=Prompt F9=Retrieve F10=Include detailed messages
F11=Display full F12=Cancel F13=Information Assistant F24=More keys
|
|
3- SUPERPARSE examples
In order to get some practice, you may want to run the following examples (addlible ez4parse):
- SUPERPARSE STMF('/ez4parse/examples/simple.xml') TOFILE(QGPL/SIMPLE)
The following field properties are suggested (see CRTTODBF Figure 3):
Data Decimal
Field Name Length Type Positions
QTY 5 S 0
ID 15 A 0
COST 5 S 2 |
- SUPERPARSE STMF('/ez4parse/examples/books.xml') TOFILE(QGPL/BOOKS)
Suggested field properties:
Data Decimal
Field Name Length Type Positions
ID 5 A 0
AUTHOR 30 A 0
TITLE 50 A 0
GENRE 15 A 0
PRICE 5 S 2
PUBLISH_DA L 0
DESCRIPTIO 100 A 0 |
- SUPERPARSE STMF('/ez4parse/examples/breakfast.xml') TOFILE(QGPL/FOOD)
Suggested field properties:
Data Decimal
Field Name Length Type Positions
NAME 50 A 0
PRICE 8 A 0
DESCRIPTIO 300 A 0
CALORIES 5 S 0 |
- SUPERPARSE STMF('/ez4parse/examples/utils.xml') TOFILE(QGPL/UTILS)
Suggested field properties:
Data Decimal
Field Name Length Type Positions
NUMBER 3 S 0
UTISEQ 3 S 0
UTIDOWNERS 7 S 0
UTIITEM 20 A 0
UTILIB 10 A 0
UTITITLE 70 A 0
UTIURL 50 A 0
UTICHARGE 1 S 0 |
- SUPERPARSE STMF('/ez4parse/examples/utils2.xml') XMLPTH('QiwaResultSet/Rowset/Row') TOFILE(QGPL/UTILS2)
Suggested field properties:
Data Decimal
Field Name Length Type Positions
NUMBER 3 S 0
COLUMN1 3 S 0
COLUMN2 7 S 0
COLUMN3 20 A 0
COLUMN4 10 A 0
COLUMN5 70 A 0
COLUMN6 50 A 0
COLUMN7 1 S 0 |
|