value compare in namespace

Friday, 18 August 2017 · 4 messages
R
radim-havlicek18 Aug 2017 10:49 #
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
CG
Christian Grün18 Aug 2017 10:51 #
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
Quoted text · radim-havlicek · 25 lines
On Fri, Aug 18, 2017 at 10:49 AM, <radim-havlicek at 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
CG
Christian Grünin reply to radim-havlicek, 18 Aug 2017, 10:4918 Aug 2017 11:41 #
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
LS
Leo Studerin reply to radim-havlicek, 18 Aug 2017, 10:4918 Aug 2017 12:02 #
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
Quoted text · radim-havlicek at post.cz · 21 lines
> On 18 Aug 2017, at 10:49, radim-havlicek at 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

⚡Generated with XQuery