XQuery Tag-We have the xQuery assertions in which we make some predefined tags like result and then we can define like this
<Result> //this can be any name
{data(//item)} //all items with data tag
{data(//item[product_name='harley'])} //items with product name as harley
{data(//item[price>150])} //items with price greater than 150
</Result>
Or we can go through all the item tags to print the product name using a for loop
<Result>
{
for $x in //item
return <product_name>{data($x/product_name)}</product_name>
}
</Result>
Or we can further filter the assertion ie go through all item tags but display only the one where price is less than 200
<Result>
{
for $x in //item
where $x/price<200
return <product_name>{data($x/product_name)}</product_name>
}
</Result>
We can use further Xquery assertions like this below.
Below are three separate queries. We can’t put all of them in same assertion. We have to put them in separate Xquery assertions.
<Result>{data(//item[product_name='puma'])}</Result>
<Result>{data(//item[price>50])}</Result>
<Result>{data(//item)}</Result>
Or we can use all the assertions together like one below.i.e put all in one result tag<Result>
{data(exists(//item[1]/product_name))}
{data(count(//item))}
{data(//item[1]/product_name)}
</Result>