Structuring a query to iterate results with HTML between?

Bardic

New Member
The most recent successful query I ran was this one:\[code\]let $doc := doc('test') for $v in $doc//item where $v/product_info/unit[.='9291']return ( <div class="seller_company">{ $v/seller_info/seller_company_id[position() lt 2]/text() } </div>, <div class="seller_rating">{ $v/seller_info/seller_rating[position() lt 3]/text() } </div> )\[/code\]But it seems it's structured incorrectly because I receive 2 results in the second div rather than two seller_rating-classed div's with one result per each. Looking at the code, it makes sense that I get these results. Trying to restructure the query, I'm perplexed. Here's my progress:\[code\]let $doc := doc('test')//itemfor $v in $docwhere $v/product_info/unit[.='9291'] let $x := return $v/seller_info/seller_company_id, $y := return $v/seller_info/seller_rating for $resultx in $x/text() return <div id="seller_company_id>{ $resultx }</div> for $resulty in $y/text() return <div id="seller_rating">{ $resulty }</div>\[/code\]The xml file being:\[code\]<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>\[/code\]I can't help but feel that this is the wrong way to structure the query because when I don't believe that the results can be ordered well/without the addition of a further-complex structure. If anyone is able to understand the desired output, please help me restructure my query.Current output:\[code\]<div>6356</div><div>C31T150 hr.</div>\[/code\]Desired output:\[code\]<div class="seller_company_id">6356</div><div class="seller_rating">C31</div><div class="seller_rating">T150 hr.</div>\[/code\]
 
Back
Top