IC SunsetThe developerWorks Connections platform will be sunset on December 31, 2019. On January 1, 2020, this forum will no longer be available. More details available on our FAQ.
Topic
  • 10 replies
  • Latest Post - ‏2019-09-11T09:01:14Z by PederUdesen
davymartu
davymartu
6 Posts

Pinned topic XML-INTO reverse

‏2019-08-19T12:56:25Z | rpgle xml

Hello guys,

I'm searching a reverse operation of XML-INTO function:

1) I read an XML with XML-INTO in an intricate Data structure.

2) Manipulate DS values 

3) I want to convert my DS in an XML string

I not found a RPG  reverse function of XML-INTO (or DATA-INTO) but if XML-INTO works well, why there isn't its reverse?

 

If I want to write my own function, I can't do that because I would like to read names of DS subfield to create XML tag and place its value (reflection technique in OOP, or "stringify" in C++), but in RPGLE isn't possible (How does it XML-INTO? mistake...)

Any suggestion? 

  • JonParis
    JonParis
    346 Posts

    Re: XML-INTO reverse

    ‏2019-08-19T15:31:12Z  

    Yup - this is a problem I have tried to address several times. Here's a couple of the ideas I have explored.

     

    1) The closest to reflection/introspection that you can come in RPG is to include the target DS in a prototype for a dummy program and compile that program requesting PCML generation. You can then use the APIs to extract the PCML which will give you the field names. But there are many problems with this approach not the least of which being that PCML does not completely cover all the potential data types and situations you might encounter in your program.

     

    2) Have the target data structure in a /COPY member (for simplicity) and write a program that will generate source statements to build the XML from a scan of that source. Use the resulting /COPY member in the original program.

    Beyond that I haven't been able to come up with anything other than doing it the hard way by hand.

     

  • barbara_morris
    barbara_morris
    605 Posts

    Re: XML-INTO reverse

    ‏2019-08-19T17:47:42Z  

    There is an RFE for 'xml-into reverse' that you can vote for: http://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=94771

  • davymartu
    davymartu
    6 Posts

    Re: XML-INTO reverse

    ‏2019-08-20T16:42:01Z  

    Hi Jon and Barbara,
     

    @Jon

    Thanks for your reply, I'm not alone in this world...:)
    I have never seen PCML extract method. When I will try , I will keep your suggestions in my mind.

    Following your second solution, I have built a prototype of (Java) program that compose (or help me for very nested DS) an XML string after reading DS source member. 
    But it's not very automatic solution and so I've finished to write specific DS to XML conversion in annoying and very long time by hand.


    Would be nice to discover how to XML-INTO read data structures fields names (misterious API? Or at Compile time?)

    @Barbara
    Thanks for your RFE link, I voted it. Created on 2016???

     


     

  • barbara_morris
    barbara_morris
    605 Posts

    Re: XML-INTO reverse

    ‏2019-08-20T17:53:16Z  
    • davymartu
    • ‏2019-08-20T16:42:01Z

    Hi Jon and Barbara,
     

    @Jon

    Thanks for your reply, I'm not alone in this world...:)
    I have never seen PCML extract method. When I will try , I will keep your suggestions in my mind.

    Following your second solution, I have built a prototype of (Java) program that compose (or help me for very nested DS) an XML string after reading DS source member. 
    But it's not very automatic solution and so I've finished to write specific DS to XML conversion in annoying and very long time by hand.


    Would be nice to discover how to XML-INTO read data structures fields names (misterious API? Or at Compile time?)

    @Barbara
    Thanks for your RFE link, I voted it. Created on 2016???

     


     

    XML-INTO gets the subfield names at compile time. The information needed by XML-INTO is compiled into the program.

  • ScottKlement
    ScottKlement
    1 Post

    Re: XML-INTO reverse

    ‏2019-08-22T22:44:52Z  

    Is there a separate RFE for a "DATA-INTO reverse"?   I will vote for the XML-INTO reverse, but I would much prefer a DATA-INTO reverse since it's not limited to only XML.

  • barbara_morris
    barbara_morris
    605 Posts

    Re: XML-INTO reverse

    ‏2019-08-22T23:01:46Z  

    One of the IBM comments, from IBM_Systems_Developer (IBM) says

    If RPG implements this, it would be similar to DATA-INTO,where the the details of the XML (or other output format) would be left to a data-generator. The generator would get the subfield names (mixed-case similar to the *DCLCASE mechanism for PCML), plus human-readable values, and be free to format the data in any way.

    Unfortunately, that part of the earlier official response didn't get into the newest official response. Oops, my fault. I updated the official response, so that should eventually appear on the main page of the RFE, whenever they actually do the update.

  • RickyThompson
    RickyThompson
    3 Posts

    Re: XML-INTO reverse

    ‏2019-08-23T14:56:11Z  

    One of the IBM comments, from IBM_Systems_Developer (IBM) says

    If RPG implements this, it would be similar to DATA-INTO,where the the details of the XML (or other output format) would be left to a data-generator. The generator would get the subfield names (mixed-case similar to the *DCLCASE mechanism for PCML), plus human-readable values, and be free to format the data in any way.

    Unfortunately, that part of the earlier official response didn't get into the newest official response. Oops, my fault. I updated the official response, so that should eventually appear on the main page of the RFE, whenever they actually do the update.

    Just started working on a project that uses DATA-INTO to parse JSON and how I need this.  Also I wish Scotts JSON parser would be included with the OS.  I know that's a big ask, but can't convince management to allow me to install the OpenSource project.  

  • scott_klement
    scott_klement
    304 Posts

    Re: XML-INTO reverse

    ‏2019-08-23T15:29:32Z  

    Just started working on a project that uses DATA-INTO to parse JSON and how I need this.  Also I wish Scotts JSON parser would be included with the OS.  I know that's a big ask, but can't convince management to allow me to install the OpenSource project.  

    Posting it here is unlikely to get any action from IBM, you'd want to file it as an RFE or a requirement with the CAAC or similar.

     

    Also, FWIW, if IBM were to include it with the OS, it'd still be Open Source. (Including it would only change how it is installed, not the legal agreement that accompanies it.)   IBM already includes many open source tools with the OS, including things we use every day like BIND, Apache HTTPD, Eclipse, and much much more.   Windows and Mac also include a plethora of open source technology, as does Apple's iOS operating system for iPhone, iPad, etc.   (And, obviously, Android is a Linux operating system, so is almost entirely open source.)   Open Source is everywhere today, nobody out there is running a business without using it. 

     

    Your crusade should not be against Open Source, it should be against things that don't offer support.

  • _vlad_
    _vlad_
    87 Posts

    Re: XML-INTO reverse

    ‏2019-09-10T21:04:59Z  

    Posting it here is unlikely to get any action from IBM, you'd want to file it as an RFE or a requirement with the CAAC or similar.

     

    Also, FWIW, if IBM were to include it with the OS, it'd still be Open Source. (Including it would only change how it is installed, not the legal agreement that accompanies it.)   IBM already includes many open source tools with the OS, including things we use every day like BIND, Apache HTTPD, Eclipse, and much much more.   Windows and Mac also include a plethora of open source technology, as does Apple's iOS operating system for iPhone, iPad, etc.   (And, obviously, Android is a Linux operating system, so is almost entirely open source.)   Open Source is everywhere today, nobody out there is running a business without using it. 

     

    Your crusade should not be against Open Source, it should be against things that don't offer support.

    The issue is not with the license, but with  the internal security policies. I've been facing similar issues many times in different places. Basically, if an open source software is coming from IBM (or another trusted provider), then it is considered as secure. It you try downloading something (even exactly the same code or a tool) from GitHub or Sourceforge, then it is a violation of internal security policies which could be very difficult  to bypass. From another side, I understand the security people who establish such the measures.  
    So, the conclusion is: including an open source into the official provides repositories would simplify its use in many organisations.

  • PederUdesen
    PederUdesen
    24 Posts

    Re: XML-INTO reverse

    ‏2019-09-11T09:01:14Z  

    It might take a long time before we get an "XML-write" function.

     

    But in the meantime you could declare a 16Mb varying character string.

    Open the XML-file in the IFS and read the entire file into this string. I assume that the XML-file is smaller than 16Mb.

    Then you can scan for the tags in the XML data you want to manipulate and then modify the data
    between the start and end tags.

    When finished write the entire string to the IFS.

    This might be fairly simple to implement.

     

    Regards

    Peder