This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xdmp:invoke( | |
'xqut.xqy', | |
(xs:QName('SUITE'), | |
xdmp:document-get( | |
"/Users/mblakele/Source/mblakele-xqut/test/test.xml")), | |
<options xmlns="xdmp:eval"> | |
<root>/Users/mblakele/Source/mblakele-xqut/src/</root> | |
</options>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<suite xmlns="com.blakeley.xqut"> | |
<unit result="1">1 + 1</unit> | |
<unit> | |
<expr>1 + 1</expr> | |
<result>2</result> | |
</unit> | |
</suite> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xdmp:document-insert( | |
'products.xml', | |
<products xsi:noNamespaceSchemaLocation="products.xsd"> | |
<product> | |
<name>broiler</name> | |
<category>kitchen</category> | |
<price>100</price> | |
<cost>70</cost> | |
</product> | |
<product> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<sales-qty-by-product>{ | |
for $sales in doc("sales-records.xml")/*/record | |
let $pname := $sales/product-name | |
group by $pname | |
order by $pname | |
return | |
<product name="{$pname}">{ | |
sum($sales/qty) | |
}</product> | |
}</sales-qty-by-product> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<sales-qty-by-product> | |
<product name="blender">250</product> | |
<product name="broiler">20</product> | |
<product name="shirt">10</product> | |
<product name="socks">510</product> | |
<product name="toaster">200</product> | |
</sales-qty-by-product> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<sales-qty-by-product>{ | |
for $pname in distinct-values( | |
doc("sales-records.xml")/*/record/product-name) | |
order by $pname | |
return | |
<product name="{$pname}">{ | |
sum( | |
doc("sales-records.xml")/*/record[ | |
product-name eq $pname ]/qty) | |
}</product> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<sales-qty-by-product>{ | |
let $m := map:map() | |
let $build := | |
for $sales in doc("sales-records.xml")/*/record | |
let $pname := $sales/product-name | |
return map:put( | |
$m, $pname, sum(( | |
map:get($m, $pname), | |
$sales/qty))) | |
for $pname in map:keys($m) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<result>{ | |
for $sales in doc("sales-records.xml")/*/record | |
let $state := doc("stores.xml")/*/store[store-number = $sales/store-number]/state | |
let $category := doc("products.xml")/*/product[name = $sales/product-name]/category | |
group by $state, $category | |
order by $state, $category | |
return | |
<group> | |
{$state, $category} | |
<total-qty>{sum($sales/qty)}</total-qty> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<result> | |
<group> | |
<state>CA</state> | |
<category>clothes</category> | |
<total-qty>510</total-qty> | |
</group> | |
<group> | |
<state>CA</state> | |
<category>kitchen</category> | |
<total-qty>170</total-qty> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<result>{ | |
let $m := map:map() | |
let $build := | |
for $sales in doc("sales-records.xml")/*/record | |
let $state := doc("stores.xml")/*/store[ | |
store-number = $sales/store-number]/state | |
let $category := doc("products.xml")/*/product[ | |
name = $sales/product-name]/category | |
let $key := concat($state, '|', $category) | |
return map:put( |
OlderNewer