Maintain integrity with data using writable data source
Hi Team,
To maintain integrity of data while putting in writable data source.
While extracting to databank, There should be an option to be given to replace "null" string where the node doesn't have value in it or the node is not present for given array path.
For Example,
I am trying to get 10 rows from Response/Database, when there is no presence of data for 4 rows and 6 has the value in that specified data for the path. The specified column will not maintain integrity with other column.
So looking for a feature request to handle this.
for $item in (/root/item[*])
return
if ($item/products[1]/text()= "") then
"null"
else
$item1/products[1]/text()
Regards
Udaya
Comments
-
Unfortunately this for loop method is not working when there is empty string or node is not present.
0 -
Hello Uday,
Have you tried enabling the databank or transformer option to "Extract empty elements as" ?
Admittedly, the "Extract missing elements as" option may not work as well for you. You may need to use the XLST tool to handle missing elements.Take a look at doc for reference:
https://docs.parasoft.com/display/SOAVIRT9103/XML+Data+Bank#XMLDataBank-HandlingEmptyHandlingEmpty/MissingElementstoMaintaintheIntegrityoftheXMLResponse1 -
SOAtest does evaluate XPaths correctly, following the spec. In this case, I think the XPath you mention is not what you want. Instead, you probably want something like this:
for $item in (/root/item) return if ($item/products and $item/products/text() != "") then $item/products/text() else parse-xml("<error>null</error>")/error/text()
Also see the following for reference:
https://forums.parasoft.com/discussion/2848/soatest-returning-error-when-trying-to-update-the-xpath-with-string-functions
https://forums.parasoft.com/discussion/3148/witabledatasource-options-to-put-null-value-when-element-is-not-there1 -
I want to clarify something I mentioned in the other post I referenced earlier.
"Extract missing element as" is for XPaths that return an empty node list.
"Extract empty element as" is for XPaths that return empty string.Neither is what you want in this case. These options do not change how XPaths are evaluated, as that is always done according to spec.
Instead, you need an XPath that returns "null" (or some placeholder) for missing things. Using a for-loop like what you describe is definitely what you want. Your XPath just needed to be improved like in the example I provided in my earlier comment.
0 -
Gotcha, Thanks.
@benken_parasoft
For array of response tool option is not working. But the code that you provided is working..Note: For single extraction tool option is working, not for the array of response.
0