Hello, I want to count failed reports in DB, it means where outcome value of report is "Failed".
declare namespace TestResults='urn:IEEE-1671:2009.04:TestResults';
declare namespace Common='urn:IEEE-1671:2010:Common';
let $DocumentNames := (db:list("ASC", "Report"))
for $DocumentName in $DocumentNames
let $Document := db:open('ASC',$DocumentName)
let $FailedTests := $Document/TestResults:TestResults/TestResults:ResultSet/ TestResults:TestGroup/TestResults:TestGroup/TestResults:TestGroup/ TestResults:TestGroup/TestResults:Test/TestResults:Outcome/data(@value)
where $FailedTests="Failed"
return count($FailedTests)
However, it counts all reports, no matter if the value is "Passed" or "Failed". If I change the end to: return $FailedTests, it displays both "Failed" and "Passed" values. If I change it to: where $FailedTests="Test", it displays correctly 0 reports. What am I doing wrong?
Thank you in advance for your reply.
Radim Havlicek
Hi Radim,
could you please provide me with a little test document that allows us to reproduce the behavior? The GUI InfoView output (or the output triggered by -V on command-line) would be helpful, too.
Thanks in advance, Christian
On Fri, Aug 18, 2017 at 10:49 AM, radim-havlicek@post.cz wrote:
Hello, I want to count failed reports in DB, it means where outcome value of report is "Failed".
declare namespace TestResults='urn:IEEE-1671:2009.04:TestResults'; declare namespace Common='urn:IEEE-1671:2010:Common';
let $DocumentNames := (db:list("ASC", "Report")) for $DocumentName in $DocumentNames let $Document := db:open('ASC',$DocumentName)
let $FailedTests := $Document/TestResults:TestResults/TestResults:ResultSet/TestResults:TestGroup/TestResults:TestGroup/TestResults:TestGroup/TestResults:TestGroup/TestResults:Test/TestResults:Outcome/data(@value) where $FailedTests="Failed" return count($FailedTests)
However, it counts all reports, no matter if the value is "Passed" or "Failed". If I change the end to: return $FailedTests, it displays both "Failed" and "Passed" values. If I change it to: where $FailedTests="Test", it displays correctly 0 reports. What am I doing wrong?
Thank you in advance for your reply.
Radim Havlicek
Hi Radim (and thanks to Michael in our team for noting this),
It’s actually your query that needs to be fixed. $FailedTests contains all data values, and you are counting this total number in the last step. You will need to rewrite your query to…
return count( for $FailedTests in $Document/.../data(@value) where $FailedTests = "Failed" return $FailedTests )
…or…
let $FailedTests := $Document/.../TestResults:Outcome[@value = "Failed"] return $FailedTests
Cheers Christian
Hello Radim
Your WHERE clause is either true or false depending whether “Failed” is in $FailedTests sequence or not. With ‘=‘ you compare sequences and not values. If one item matches it is true.
let $FailedTests:=… return count($FailedTests[. eq ‘Failed’])
Cheers Leo
On 18 Aug 2017, at 10:49, radim-havlicek@post.cz wrote:
Hello, I want to count failed reports in DB, it means where outcome value of report is "Failed".
declare namespace TestResults='urn:IEEE-1671:2009.04:TestResults'; declare namespace Common='urn:IEEE-1671:2010:Common';
let $DocumentNames := (db:list("ASC", "Report")) for $DocumentName in $DocumentNames let $Document := db:open('ASC',$DocumentName)
let $FailedTests := $Document/TestResults:TestResults/TestResults:ResultSet/TestResults:TestGroup/TestResults:TestGroup/TestResults:TestGroup/TestResults:TestGroup/TestResults:Test/TestResults:Outcome/data(@value) where $FailedTests="Failed" return count($FailedTests)
However, it counts all reports, no matter if the value is "Passed" or "Failed". If I change the end to: return $FailedTests, it displays both "Failed" and "Passed" values. If I change it to: where $FailedTests="Test", it displays correctly 0 reports. What am I doing wrong?
Thank you in advance for your reply.
Radim Havlicek
basex-talk@mailman.uni-konstanz.de