webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

How to suppress empty tags in an XML

webMethods Community Member

webMethods Community MemberFri July 19, 2013 07:28 AM

  • 1.  How to suppress empty tags in an XML

    Posted Thu July 18, 2013 06:28 AM

    Hi all!

    I am converting from one XML format into another XML format, where my XML structure is as follows.

    Hello
    199



    CAI - CASH AGAINST

    I want to suppress the empty values. My output structure should be

    Hello
    199
    CAI - CASH AGAINST

    I am using loop over RefTypeCd which has (19,WS,V0,TT,4B,BLT). I have tried by changing genearteRequiredTags value to false in documentToXMLString, but it does not help me. Does anyone has a solution. Any help would be appreciated. Thanks.


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 2.  RE: How to suppress empty tags in an XML

    Posted Thu July 18, 2013 11:15 AM

    Are you passing the documentTypeName in the documenttoxmlstring service? Can you try not to set any input to that which will suppress it?

    HTH,
    RMG


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 3.  RE: How to suppress empty tags in an XML

    Posted Thu July 18, 2013 05:57 PM

    generateRequiredTag is the right option that would help you to remove empty tags. This requires documentTypeName to be passed. If it still doesn’t happen, the way you are passing input to this service might not be right. Check for the root node whether it is mapped to document or under document

    -Senthil


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 4.  RE: How to suppress empty tags in an XML

    Posted Thu July 18, 2013 06:16 PM

    Mr.Senthil it should work both ways and giving required tags to false and document type name some times works unexpected due to the underlying schema/DTD elements forces to be present for null/empty values.

    I would say he can try both options with and with out setting docTypeName:


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 5.  RE: How to suppress empty tags in an XML

    Posted Fri July 19, 2013 07:28 AM


  • 6.  RE: How to suppress empty tags in an XML

    Posted Fri July 19, 2013 07:37 AM

    I am unable to suppress them tried both the ways. :frowning:


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 7.  RE: How to suppress empty tags in an XML

    Posted Fri July 19, 2013 11:15 AM

    What exactly you tried can you elaborate the trying please?

    How ever I know there are some rude ways to remove from the xmldata but its all depends on the requirement always required vs not required in the output data.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 8.  RE: How to suppress empty tags in an XML

    Posted Mon July 22, 2013 04:57 AM

    Hi RMG/Senthil, I am attaching the generated sample XML file can you please provide me the sample code to remove empty XML tags from it as in your previous posts you have mentioned that documentTypeName is not mandatory. Thanks.
    Sample.xml (6.65 KB)


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 9.  RE: How to suppress empty tags in an XML

    Posted Mon July 22, 2013 05:03 AM

    I found an alternate solution by mapping them conditionally I think that is not the right approach, tomorrow if we want the null tags to be generated it will become a problem. So I want to see how can we make use of the property generateRequiredTags. Thanks. :slight_smile:


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 10.  RE: How to suppress empty tags in an XML

    Posted Mon July 22, 2013 12:47 PM

    OK sure as long it works custom way:

    But these settings are tricky depends on how is your Schema/DTD is defined for the XML.

    I will try on the XML if my time allows to test:


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 11.  RE: How to suppress empty tags in an XML

    Posted Thu July 25, 2013 04:03 AM

    Hi RMG!

    Could you please provide me the sample code to suppress the empty tags by making use of the property generateRequiredTags. At least for the following sample code in the above XML document.

    Hello
    199



    CAI - CASH AGAINST

    Thanks. :slight_smile:


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services