Reputation: 4128
I am performing a query that works without HTML, but when I add HTML, to better organize the results. When I add in <div>
and </div>
tags, I get an error (see below). Here's the query:
let $doc := doc('test')
for $v in $doc//item
where $v/product_info/unit[.='9291']
return
<div>{ $v/seller_info/seller_company_id[position() lt 2]/text() }
</div>
<div>{ $v/seller_info/seller_rating[position() lt 3]/text()
</div>
On this document:
<item>
<item_number>1171270</item_number>
<seller_info>
<seller_company_id>6356</seller_company_id>
<seller_rating>C31</seller_rating>
<seller_rating>T150 hr.</seller_rating>
</seller_info>
<product_info>
<unit>2022</unit>
<sinfo>55 cases</sinfo>
<sinfo>Yu-gi-oh trading card pack</sinfo>
<sinfo>.45kg per unit</sinfo>
<sinfo>24.7500kg shipment</sinfo>
</product_info>
<product_info>
<unit>9291</unit>
<sinfo>7 units</sinfo>
<sinfo>Naruto, Classic, action figure</sinfo>
<sinfo>1.8kg per unit</sinfo>
<sinfo>12.6kg shipment</sinfo>
</product_info>
</item>
And the error I'm getting:
Stopped at line 4, column 85: [XPST0003] Unexpected end of query: '>{ $v/seller_in...'
Upvotes: 2
Views: 938
Reputation: 38662
When you want to return multiple elements, you will have to wrap them in a sequence. Additionally, you forgot the closing }
in the second <div/>
.
let $doc := doc('test')
for $v in $doc//item
where $v/product_info/unit[.='9291']
return
(
<div>{ $v/seller_info/seller_company_id[position() lt 2]/text() }
</div>,
<div>{ $v/seller_info/seller_rating[position() lt 3]/text() }
</div>
)
Upvotes: 2