XQuery doesn't execute
Issues related to W3C XQuery.
-
- Posts: 2
- Joined: Tue Aug 02, 2022 3:33 pm
XQuery doesn't execute
Post by DeepMohinman »
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>
}
-
- Posts: 101
- Joined: Tue Aug 19, 2014 12:04 pm
Re: XQuery doesn't execute
Post by Martin Honnen »
The syntax of an `if` expression in XQuery is simply e.g. `if (condition-expression) then expression1 else expression2`, there is no `return` involved, neither in the `then expression1` nor in the `else expression2`.
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service