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
senders = ['paul', 'frank'] | |
recipients = ['joe', 'al', 'peter', 'chris'] | |
print [(sender, recipient) for sender in senders for recipient in recipients] |
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
let $_ := xdmp:document-insert('/test/test1.xml', <root/>) | |
return if (fn:doc-available('/test/test1.xml')) then "YES" else "NO" |
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
multiples = [i*10 for i in integers] |
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
let $multiples := (for $i in $integers return $i * 10) |
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
List<Integer> multiples = new ArrayList<Integer>(); | |
for (Integer i : integers) { | |
multiples.add(i * 10); | |
} |
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
Map<String, String> namespaces = new HashMap<String, String>(); | |
namespaces.put("search", "http://marklogic.com/appservices/search"); | |
namespaces.put("wiki", "http://marklogic.com/wikipedia"); | |
StructuredQueryBuilder queryBuilder = new StructuredQueryBuilder("all"); | |
StructuredQueryDefinition queryDef = queryBuilder.term(query); | |
SearchHandle results = markLogicService.search(queryDef); | |
for (MatchDocumentSummary result : results.getMatchResults()) { | |
String year = XPath.selectText("/search:metadata/search:attribute-meta[@name='year' and @parent-name='nominee']", result.getMetadata(), namespaces); | |
// ... |
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
xquery version "1.0-ml"; | |
<sales-qty-by-product> | |
{ | |
for $prod in cts:element-values(xs:QName('product-name')) | |
order by $prod | |
return | |
<product name="{$prod}"> | |
{ | |
cts:sum-aggregate(cts:element-reference(xs:QName("qty")), 'document', cts:element-range-query(xs:QName('product-name'), '=', $prod)) | |
} |
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
let $sales := <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> |
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
if (xdmp:log-level() = 'debug') then | |
xdmp:log("This is a test debug message", "debug") | |
else () |