Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Return Comment in the node in form XML input view

meghana1
meghana1 Posts: 29

we are using xml based req res pairs. We have choose Form XML input mode for response. also we have selected use data source node exclude empty values at node tree level . But we need to return comment out for this nodes if there are no values
For example
how do we configure it as its returning null values which is not accepted in xsd. so we need to remove those nodes or return comment for the same nodes in which we don't have data.
we are using java for coding.

Comments

  • meghana1
    meghana1 Posts: 29

    we have Form XML input mode. we want to remove or replace the element in response with comment or remove the element as per values in request using java coding.

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭
    edited July 2018

    Tools chained to the outgoing message output (response message in this case) can be used to transform the message before it is sent. One such tool that can do this is the Extension tool. If you chain an Extension tool then the "input" argument of our script will have the outgoing message. You would make your script insert the comment and return the modified XML as a string. Another tool that can do this is the XSLT Tool, in case you prefer to modify the outgoing message using XSLT instead of a script.

  • meghana1
    meghana1 Posts: 29

    we use parasoft virtualize 9.10. Also we cant see input tab in extension tool. we have Form XML response in which some of the fields are mapped from incoming request parameters. Also we have "item" elements means tags which are having start and end tag with namespace. we have item whole element data in request we have to modify response as per request. means if the request has 5 items then we have to enter those item data in response items. but remaining extra "items" tags / elements which are in response have to be removed or comment out.

  • meghana1
    meghana1 Posts: 29

    In response we have item tags

    we have extracted item element from request to data bank in datasource column "item"
    as per the request we have to fill response items with data from req. but there are extra items in res so we have to remove or comment out and namespace should be remove or comment out as below -

  • keegan_chan
    keegan_chan Posts: 59 ✭✭

    As @benken_parasoft said, an Extension tool attached to the response payload would take the outgoing message as the input. It doesn't necessarily have an input tab. You can use the Extension tool to modify the outgoing message in whatever way you need.
    And just like he said, you can also use an XSLT Tool to transform the outgoing message if you're more familiar with xslt.

  • meghana1
    meghana1 Posts: 29

    But we are suing Form XML response. So some of the elements are static, Soem are from req data bank , some have script so how to modify just one element scripting in extension tool

  • keegan_chan
    keegan_chan Posts: 59 ✭✭

    The outgoing message is a string when it becomes the input in the extension tool. So one possible way is for you to replace whatever substrings that you need to.

  • meghana1
    meghana1 Posts: 29

    but we are not sending response is in one string .. In the response,there are few elements fetched from the request and few are kept static
    In the response , we have multiple “item” elements which have name spaces, which are empty
    After processing the db connectivity and java code, data will be fetched from file and paste in each “item” element.
    We need to keep the “item” elements count same as in request or we need to comment out (<!-- -> ) the extra “item” elements from response
    We have choose Form XML response output so that each element has static value or script or mapped from request. so how to send 'item' in a single string to extension tool to process it.

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭
    edited July 2018

    but we are not sending response is in one string

    As mentioned, chained tools will receive the outgoing message as a string. In your case, the string that was built from your Form XML view.

    We need to keep the “item” elements count same as in request or we need to comment out (<!-- -> ) the extra “item” elements from response

    Processing the response with a chained tool could do this as previously described. If you need better clarification or an expedited resolution then you may consider contacting Parasoft Support.

  • meghana1
    meghana1 Posts: 29

    thanks it worked with XSLT tool