Rocket jBASE

 View Only

A new way to access a XML file

  • 1.  A new way to access a XML file

    Posted 05-10-2022 08:02

    A new jEDI that allows you to access the XML file (currently read-only) as if it was a standard jBASE hashed file with the key being the row of the XML file.

    XMLJEDI is the JEDI program.

    MAKEXML will generate a sample XML item with however many data items you want.

    TEXTXML allows you to test for best blocksize for the XML file.



    With this new JEDI, you can add dict= portion of param and it will create DICT items when the XML is first mapped.  You can also specify the blocksize. 

     

    When run against a 500,000 record XML file with a size of 94Mb, it can LIST the file in 3 minutes and 24 seconds.

     

    Here is an example of the jEDI stub for a sample xml file called /big/tmp/SampleLarge.xml :

    jsh>ED . SAMPLE.XML<Enter>
    New Record

    SAMPLE.XML

    TOP

    I<Enter>

    001+ JBC__SOB JediInitSUB XMLJEDI filename=/big/tmp/SampleLarge.xml,xmlmap=SAMPLE.MAP,dict=SAMPLE.XML]D,blocksize=63488<Enter>

    002+<Enter>

    FI<Enter>

     

    After you add the jEDI stub to the current directory, you create the DICT portion

     

    jsh> CREATE-FILE DICT SAMPLE.XML<Enter>

     

    The only other thing needed is a XML.MAPS file and item for the XML file containing the element that defines each record.

     

    jsh>CREATE-FILE XML.MAPS<Enter>

     

    jsh>ED XML.MAPS SAMPLE.MAP<Enter>

    New Record
    SAMPLE.MAP
    TOP

    .I<Enter>

    001+ Large Sample XML record<Enter>

    002+ PLANT<Enter>                                     <-- In this sample, <PLANT> and </PLANT> envelope the data "rows"

    003+<Enter>

    .FI<Enter>

     

    Now that the jEDI stub is in place and the supporting XML.MAPS item, the first access of the file will create the DICT items.  After that you can adjust field 4 of the XML.MAPS item to apply conversions to the data before being presented.

     

    jsh> ED SAMPLE.XML 1<Enter>
    1

    TOP

    .P<Enter>

    TOP

    001 1

    002 Buttercup

    003 Erythronium americanum

    004 21

    005 Mostly Shady

    006 $12.59                                       <-- In the next step you will remove the $ and comma for fields 6 and 7

    007 12,599

    BOTTOM

    .EX<Enter>

    Record '1' exited from file 'SAMPLE.XML'

     

    jsh>ED XML.MAPS SAMPLE.MAP<Enter>

    SAMPLE.MAP
    TOP
    .P<Enter>

    TOP

    001 Large Sample XML record

    002 PLANT

    003 XMLROW]COMMON]BOTANICAL]ZONE]LIGHT]PRICE]AVAILABILITY

    BOTTOM

    .I<Enter>

    004+ ]]]]]MCN]MCN<Enter>                                 <-- Adding the internal conversion of MCN for PRICE and AVAILABILTY
    005+ <Enter>                                                                                So, the ] are actually value marks (^]).

    BOTTOM                                                                                        This can also be CALL XXXX where XXXX is a subroutine with arguments of indata,outdata that
    .FI<Enter>                                                                                      can manipulate the data based on the indata passed and return outdata for this field.

     

    jsh> ED SAMPLE.XML 1<Enter>

    1

    TOP

    .P<Enter>

    TOP

    001 1

    002 Buttercup

    003 Erythronium americanum

    004 21

    005 Mostly Shady

    006 1259                                           <-- Now presented as "multi-value style" ICONV data for PRICE and AVAILABILITY

    007 12599

    BOTTOM

    .EX<Enter>

    Record '1' exited from file 'SAMPLE.XML'

     

    Now fix the DICT items which are the number of the value and the data content of field 3 of XML.MAPS

     

    ED DICT SAMPLE.XML 6 PRICE 7 AVAILABILITY

    6

    TOP

    .P<Enter>

    TOP

    001 A

    002 6

    003 PRICE

    004

    005

    006

    007

    008

    009 L

    010 10

    BOTTOM

    .7<Enter>

    007

    .R<Enter>

    007+MR2,$<Enter>

    .FI<Enter>

    Record '6' written to file 'DICT SAMPLE.XML'

    PRICE

    TOP

    .7<Enter>

    007

    .R<Enter>

    007+MR2,$<Enter>

    .FI<enter>

    Record 'PRICE' written to file 'DICT SAMPLE.XML'

    7<Enter>

    TOP

    .P<Enter>

    TOP

    001 A

    002 7

    003 AVAILABILITY

    004

    005

    006

    007

    008

    009 L

    010 10

    BOTTOM

    .7<Enter>

    007

    .R

    007+MR0,<Enter>

    .FI<Enter>

    Record '7' written to file 'DICT SAMPLE.XML'

    AVAILABILITY

    TOP

    .7<Enter>

    007

    .R<Enter>

    007+MR0,<Enter>

    .FI<Enter>

    Record 'AVAILABILITY' written to file 'DICT SAMPLE.XML'


    jsh> LIST SAMPLE.XML '1'<Enter>

     

    PAGE    1                                                                                    06:59:59  10 MAY 2022

     

    SAMPLE.XML....    XMLROW....    COMMON....    BOTANICAL.    ZONE......    LIGHT.....    PRICE.....    AVAILABILITY

     

    1                 1             Buttercup     Erythroniu    21            Mostly Sha    $12.59        12,599

                                                  m american                  dy

                                                  um

     

     

     

     

     



    ------------------------------
    Dan Ell
    Senior Software Engineer
    Rocket Internal - All Brands
    ------------------------------