Forum Discussion

CARQUESTTechnol's avatar
CARQUESTTechnol
Contributor
15 years ago

Trim Whitespace in an XPath Match statement

I have a JDBC step that retrieves information from a DB. This info has whitespace at the end but the WebService doesn't. How can I use the JDBC info for comparison to my Request's Response? I tired normalize-string() but it didn't seem to work. I tried a match() but when I try to put in the JDBC result the match fails.

I want to use a simple assertion instead of writing code. Can I use a XPath with RegEx? How do I use a RegEx with a JDBC Datasource?
  • Hello,

    If you are using assertions try contains or XPath assertion. In first one you can use regexp and in second wildcards. That should help.

    robert
  • I tried this with Xpath assertions but the Xpath assertions fail because the JDBC step returns data from the database with losts of white space. ie. "Test Data " != "Test Data". My goal was to somehow trim the JDBC results so I can do the correct comparison.

    For wild cards I notice that you cannot have part of the string set as a wild card ie "Test Data*" You have to have the whole element set as a wild card.
  • Posting an update that your suggestion worked. I don't know where I got normalize-string from but what I required was normalize-space. Here is the proper expected result:

    ${JDBC Request#ResponseAsXml#normalize-space(//Results[1]/ResultSet[1]/Row[1]/MAKENAME[1])}