Uniface User Forum

 View Only
  Thread closed by the administrator, not accepting new replies.
  • 1.  Uniface 9: Avoiding empty tags in structtoxml

    ROCKETEER
    Posted 11-19-2018 11:40
    No replies, thread closed.

    Avoiding empty tags in structtoxml

    Author: tneeskens@itblockz.nl (Theo Neeskens)

    Hi, I have a situation where I need to: - retrieve lots of related data in a Uniface service - create a struct using componenttostruct - create XML using structtoxml - dump the XML as a file on disk    It works fine so far, but I do not want empty XML tags in the output. - Is there a way to specify a switch on componenttostruct so I do not get the empty fields in the struct? - Is there a way to specify a switch on structtoxml so I do not get the empty fields in the XML?   NB: It needs to be fast, and the code needs to be kept extremely simple, so the answer "just iterate over the struct and remove them yourself" is not the answer that I am hoping for...



  • 2.  RE: Uniface 9: Avoiding empty tags in structtoxml

    ROCKETEER
    Posted 11-19-2018 11:40
    No replies, thread closed.

    Hi Theo, if such a switch can not be found in the current uniface version: what about creating a .RAW output file at first and then use a tiny AWK script which doesn't copy lines with empty tags to the real output file (and you delete the RAW file afterwards). I use GAWK.EXE and for simple tasks like this, it works pretty fast. BTW: this could process your "renaming elements requirement" as well


    Author: ulrich-merkel (ulrichmerkel@web.de)


  • 3.  RE: Uniface 9: Avoiding empty tags in structtoxml

    ROCKETEER
    Posted 11-19-2018 11:40
    No replies, thread closed.

    Hi Theo, my gotfeel is same as Uli:  the switch you are looking for is not available as of current U9.7 & U10.3 but I've read about a new switch structtoxml/schema that is promising a lot but I have not had yet time to dig it. My suggestion is simple: if you do not own an horse but just a donkey/ass, jump on your donkey/ass and go where you have to go! Is it less confortable, less elegant and less fast? yes! Could it bring you to your destination? yes! Let's iterate over the struct before converting to XML and apply there your business rules whatever they are! If you want to be future proof built your own functions to be reused next time you will find same requirement. My 2 cents... Gianni


    Author: gianni (gianni.sandigliano@unifacesolutions.com)


  • 4.  RE: Uniface 9: Avoiding empty tags in structtoxml

    ROCKETEER
    Posted 11-19-2018 11:40
    No replies, thread closed.

    Hi, a time ago i had a similar problem. This was my solution, for empty nodes in a struct. Maybe this could help to find your solution. entry en_cleanup params numeric lp_rc : OUT byref struct lp_struct : INOUT endparams variables numeric lv_rc numeric lv_counter endvariables for lv_counter = lp_struct->$membercount to 1 step -1 lv_rc = 0 if (!lp_struct->*{lv_counter}->$isScalar) call en_cleanup(lv_rc, lp_struct->*{lv_counter}) ; === handle sub-nodes if (lv_rc < 0) lp_struct->*{lv_counter}->$parent = "" ; === Remove node from struct endfor if (lp_struct->$membercount == 0) lp_rc = -1 ; === node is empty return(0) end


    Author: TK (klan@ahp-gmbh.de)


  • 5.  RE: Uniface 9: Avoiding empty tags in structtoxml

    ROCKETEER
    Posted 11-19-2018 11:40
    No replies, thread closed.

    Thanks all, If I can`t do this with a simple switch or setting, I will probably do this with xslt, as we need to perform many more transformations. I just tought it would be evident to have this in componenttostruct, as it will often deliver a much smaller struct that is faster to process. Regards, Theo Neeskens Consultant at ITBLOCKZ


    Author: Theo Neeskens (tneeskens@itblockz.nl)


  • 6.  RE: Uniface 9: Avoiding empty tags in structtoxml

    ROCKETEER
    Posted 11-19-2018 11:40
    No replies, thread closed.
    Theo Neeskens said ... I just tought it would be evident to have this in componenttostruct, as it will often deliver a much smaller struct that is faster to process. ... 

    Agreed. It's part of those (many) small things making the difference... Gianni


    Author: gianni (gianni.sandigliano@unifacesolutions.com)