COBOL

COBOL

COBOL

COBOL is responsible for the efficient, reliable, secure, and unseen day-to-day operations of the world's economy.

 View Only
  • 1.  XML GENERATE with supression

    Posted Wed June 15, 2016 08:06 PM

    The following is a very simple program to generate an XML document ("base") with two elements ("one" and "two"), each having attributes "a1" and "a2".

    I want each attribute to be suppressed when they have a value of low-values.  However what I am getting is that if only one of the attributes is suppressed then the entire element is suppressed.  Am I missing something??

     identification division.                             program-id. xmlgen.                                  data division.                                       working-storage section.                             01  doc-out                     pic x(5000).         01  doc-len                     pic s9(4) comp-5.    01  base.                                                05  one.                                                 10  one-a1              pic x.                       10  one-a2              pic x.                   05  two.                                                 10  two-a1              pic x.                       10  two-a2              pic x.                                                                    procedure division.                                      move low-values to base                              move 'A' to one-a1                                   move 'Q' to one-a2                                   move 'Z' to two-a1                                   move 'X' to two-a2                                   perform generate-base                                move low-values to two-a2                            perform generate-base                                goback.                                                                                               generate-base.                                           xml generate doc-out from base count in doc-len          with attributes                                      name one-a1 is 'a1', two-a1 is 'a1'                       one-a2 is 'a2', two-a2 is 'a2'                  suppress when low-values                         display doc-out (1:doc-len)                          exit paragraph.                                  end program xmlgen.                                
    <base><one a1="A" a2="Q"></one><two a1="Z" a2="X"></two></base><base><one a1="A" a2="Q"></one></base>

    I also tried explicitly naming each attribute field in the object of a suppress when low-values and got the same results.

    fswarbrick


  • 2.  Re: XML GENERATE with supression

    Posted Thu June 16, 2016 09:24 AM

    I can't tell where in the manual exactly what is coded is covered. I'd try with ATTRIBUTE or CONTENT. If that didn't work, I'd put "everything" in to be certain of nailing it, and then take bits out until it fails.

    As far as I can tell from the documentation your code is valid (syntax diagram), but it does not fit into the text of the documentation.

    I was first suspicious that you may be getting an "exception", but I don't think so, as you have the </base>. I think I'd still put an ON EXCEPTION ... with END-XML. I've checked the V6..1 manuals as well, and they offer no further clarity.

     

    BillWoodger


  • 3.  Re: XML GENERATE with supression

    Posted Thu June 16, 2016 08:36 PM

    I did try ON EXCEPTION / NOT ON EXCEPTION, and no exception is being generated.

    WITH ATTRIBUTES, all fields not low-values:

    <base>  <one a1="A" a2="Q" />  <two a1="Z" a2="X" /></base>

    Results as expected.


    All field as elements, all fields not low-values:

    <base>  <one>    <a1>A</a1>    <a2>Q</a2>  </one>  <two>    <a1>Z</a1>    <a2>X</a2>  </two></base>

    Results as expected.


    WITH ATTRIBUTES, two-a2 is low-values:

    <base>  <one a1="A" a2="Q" /></base>

    Results not as expected.  I expected a "two" element as follows, following the "one" element:

      <two a1="Z" />

    All fields as elements, two-a2 is low-values:

    <base>  <one>    <a1>A</a1>    <a2>Q</a2>  </one>  <two>    <a1>Z</a1>  </two></base>

    These results are as expected.  So the only difference between this one and the one that has unexpected results is the "WITH ATTRIBUTES" is present for the bad one.

    Sounds like its PMR time...

    Thanks for the guidance, Bill!  I wasn't sure yesterday where to start.

    fswarbrick


  • 4.  Re: XML GENERATE with supression

    Posted Fri June 17, 2016 01:17 AM

    No problem, Frank. Pleas include the documentary aspect. XML GENERATE is complex, and the documentation is already long, but it is not clear. Very not clear.

    BillWoodger


  • 5.  Re: XML GENERATE with supression

    Posted Fri June 17, 2016 01:51 PM

    I have sent the information to my system programmer to open a PMR on this item.

    And I did include a note about the really very unclear documentation for the SUPPRESS clause.

    fswarbrick


  • 6.  Re: XML GENERATE with supression

    Posted Wed December 14, 2016 02:52 PM

    Update:  This issue was opened as APAR PI71169 and closed with PTFs UI42659 and UI42660 (LE run-times for v2.1 and 2.2) in November 2016.

    Interestingly, this was not technically a bug but was actually a design decision.  They were not aware that the behavior I was looking for was actual proper behavior for XML!

    Frank

     

    fswarbrick