XQuery doesn't execute
Posted: Wed Oct 05, 2022 7:19 am
I have an XQuery problem:
Executing this XQuery with Saxon9 yields the following Error:
Is anyone able to point me to where my mistake is ?
EDIT: But why does this work ok, then? :
Code: Select all
{
let $x := $document//AOSCAT_MetricDetail//table[@class="pretty-table"]
//tr/td[8]/text()
let $sum_of_statements_per_method := sum(
for $a at $i in $x where $a != 0.0 return $a
)
let $count_of_statements_per_method := count(
for $a at $i in $x where $a != 0.0 return $a
)
return
if ($count_of_statements_per_method != 0) then
return <average_statements_per_method>{
$sum_of_statements_per_method
div
$count_of_statements_per_method
}</average_statements_per_method>
else
return <average_statements_per_method>
No data available
</average_statements_per_method>
}
But i dont understand why. In the same File a have a very similar XQuery expression and there's no problem at all...Error on line 103 column 39 of transform_2.xq:
XPST0003: XQuery syntax error in #...verage_statements_per_method>{#:
expected "else", found ">"
Static error(s) in query
Is anyone able to point me to where my mistake is ?
EDIT: But why does this work ok, then? :
Code: Select all
{
let $content_check := $document//AOSCAT_MainReport//div[@class="reportpart"][4]/h2/text()
return
if($content_check="Abstraction analysis") then
let $abstraction := $document//AOSCAT_MainReport//div[@class="reportpart"][4]/table//tr[2]//td[5]
return <abstraction_level>{ fn:number(fn:normalize-space($abstraction))*100 }</abstraction_level>
else
let $abstraction := 0
return <abstraction_level>{ $abstraction }</abstraction_level>
}