Iteration of Columns in Data Bank

Hi,

I have some 25 coulmn names in my XML data bank and I need to use all the column names in a Jython script. I do not want to write context.getValue("Genearted Data Source","Column_1") ,..... upto Column_25. How can I iterate through the names in the XML data bank??

Thanks

Comments

  • keegan_chankeegan_chan Posts: 56

    The method context.getGeneratedDataSourceValues() would return a map of all the data source variables and their values.

  • benken_parasoftbenken_parasoft Posts: 671 ✭✭✭

    From the public API docs for the class com.parasoft.api.ScriptingContext:

    /**
     * @return a map of generated data source values.  The Map
     * keys are the column names.  This will typically be used to extract all
     * values from an XML Data Bank.
     */
    Map<String, String> getGeneratedDataSourceValues();
    
  • nsfmost2005nsfmost2005 Posts: 8

    Thank you guys.
    I would try this and keep you posted.
    I also have one more doubt, its as follows:
    I have 25 different variables in my XML data bank and every variable is associated to a XPath (ResultSet[1]/Rows[1]/Items[1]/item1). I have to perform String-join & normalize-space to all the 25 variables. I am right now doing it manually, but is there a way to modify all the xpaths at once i.e.
    1. String-join(ResultSet[]/Rows[]/Items[]/normalize-space(item1),',') - This is for one variable
    2. String-join(ResultSet[
    ]/Rows[]/Items[]/normalize-space(item2),',') - This is for second variable. so on..

    any possible way to pull it ?

    Thanks

  • benken_parasoftbenken_parasoft Posts: 671 ✭✭✭
    edited October 2018

    In case this helps, you can use the Search dialog to perform a search-and-replace. The "Parasoft Search" tab lets you do this for fields in Parsoft tools, including XML Data Bank XPath fields:

    Please note that the "Containing text" field supports a regular expression if "Regular expression" is selected. So, you could probably write a regular expression to match and perform the replacement you require.

    Perhaps like this:

Sign In or Register to comment.