Skip to content

Instantly share code, notes, and snippets.

@mblakele
Created November 6, 2011 00:51
Show Gist options
  • Save mblakele/1342270 to your computer and use it in GitHub Desktop.
Save mblakele/1342270 to your computer and use it in GitHub Desktop.
W3C XQuery 3.0 - Documents for Group By Use Cases
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>
<name>toaster</name>
<category>kitchen</category>
<price>30</price>
<cost>10</cost>
</product>
<product>
<name>blender</name>
<category>kitchen</category>
<price>50</price>
<cost>25</cost>
</product>
<product>
<name>socks</name>
<category>clothes</category>
<price>5</price>
<cost>2</cost>
</product>
<product>
<name>shirt</name>
<category>clothes</category>
<price>10</price>
<cost>3</cost>
</product>
</products>)
,
xdmp:document-insert(
'sales-records.xml',
<sales xsi:noNamespaceSchemaLocation="sales.xsd">
<record>
<product-name>broiler</product-name>
<store-number>1</store-number>
<qty>20</qty>
</record>
<record>
<product-name>toaster</product-name>
<store-number>2</store-number>
<qty>100</qty>
</record>
<record>
<product-name>toaster</product-name>
<store-number>2</store-number>
<qty>50</qty>
</record>
<record>
<product-name>toaster</product-name>
<store-number>3</store-number>
<qty>50</qty>
</record>
<record>
<product-name>blender</product-name>
<store-number>3</store-number>
<qty>100</qty>
</record>
<record>
<product-name>blender</product-name>
<store-number>3</store-number>
<qty>150</qty>
</record>
<record>
<product-name>socks</product-name>
<store-number>1</store-number>
<qty>500</qty>
</record>
<record>
<product-name>socks</product-name>
<store-number>2</store-number>
<qty>10</qty>
</record>
<record>
<product-name>shirt</product-name>
<store-number>3</store-number>
<qty>10</qty>
</record>
</sales>)
,
xdmp:document-insert(
'stores.xml',
<stores xsi:noNamespaceSchemaLocation="stores.xsd">
<store>
<store-number>1</store-number>
<state>CA</state>
</store>
<store>
<store-number>2</store-number>
<state>CA</state>
</store>
<store>
<store-number>3</store-number>
<state>MA</state>
</store>
<store>
<store-number>4</store-number>
<state>WA</state>
</store>
</stores>)
,
xdmp:document-insert(
'books.xml',
<bib xsi:noNamespaceSchemaLocation="books.xsd">
<book>
<author>Jim Melton</author>
<author>Alan Simon</author>
<title>SQL:1999</title>
</book>
<book>
<author>Jim Melton</author>
<title>Advanced SQL:1999</title>
</book>
<book>
<author>Alan Simon</author>
<title>Strategic Database Technology</title>
</book>
<book>
<author>Jim Melton</author>
<author>Andrew Eisenberg</author>
<title>Understanding SQL and Java Together</title>
</book>
<book>
<author>Jim Melton</author>
<author>Stephen Buxton</author>
<title>Querying XML</title>
</book>
</bib>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment