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

    Posted Fri February 26, 2016 10:23 AM

    Hi.

    This is regarding namespaces in XML Generate in IBM Enterprise COBOL V4.2.

    I would like to be able to execute not one XML Generate to create a complete XML document in one go but instead execute a number of XML Generate and then "assemble" (by outputting each result) a XML result document "manually".

    My problem here is that if I need to specify more than one XML namespace then I would like to do the XML declaration manually and be able to specify an arbitrary number of xmlns attributes, one maybe default and the others with namespace prefixes.

    Then, when issuing the different XML Generate verbs, I would like to be able to just specify the NAMESPACE-PREFIX (with no NAMESPACE). In the COBOL 4.2 you need to specify the NAMESPACE to be able to specify the NAMESPACE-PREFIX but there is a possibility toe specify a null length or blank NAMESPACE. The sad thing about that is that, in that case, the entered NAMESPACE-PREFIX will not be honored so the resulting XML fragment will wind up in the default namespace.

    Now, this may seem unimportant, but my actual goal is to only need to specify the namespaces in question in the XML declaration and not repeat them all over the place, This is due to the fact that I am not able (almost never) to do the XML Generate on a group but I do it directly on individual items in the input structure and, if I need to do the namespace definition an every XML element generated then the resulting XML document will be unnecessary large and also considering the fact that the one-time definition and referencing by means of namespace-prefix is a XML standard it is a little annoying that I don´t seem to be able to do this.

    So, in conclusion:

    • Does anybody have an idea on how to achieve this or
    • Does V5.x or V6.y give any help

     Thank you in advance for any thoughts or ideas towards resolving my problem.

     

    Regards Lars

    lbjerges


  • 2.  Re: XML Generate

    Posted Thu March 10, 2016 02:50 AM

    Hi,

    With a generation by fragments it would be difficult to manage opening and closing Element surrounding the new fragment : a sequential generation would not be possible.

    To achieve the expected result it should be a method based on DOM with an API for inserting nodes in a document built in memory and then serialized at once :

    • Create new document, from scratch or from initial well formed xml text
    • Get an existing node in document
    • Add child node before / after 
    • Add attribute on node
    • Serialize document in a file or in a program variable

    Low-level calls to XML System Services or using XML Toolkit for z/os based on Apache XERCES can do this, but programming with these API is very difficult with Cobol.

    For our part, we have developped a subprogram formatting an xml flow based on events like those generated by xml parse.

    Kind regards.

     

    Denis

    DenisFALLAI


  • 3.  Re: XML Generate

    Posted Sat May 14, 2016 08:36 PM

    Pues si, API es muy difícil con Cobol. Peor que le vamos a hacer....

     

    Sidrería Parrilla Carnes

    RestauranteLaVeguca