title: Modern XML usefull resources
author: @emchateau, @sardinecan
since: 2020-06-24
description: Selected XML resources from the ANR Experts projet for the NA+DAH Getty advanced workshop.
map:keys($map)[exists($map(.)[?prop2 = 17])] |
for $a in (1,2,3,5) | |
where $a = (1,3,2,3) | |
group by $k := $a | |
return $a |
(: https://codereview.stackexchange.com/questions/214571/xquery-compare-order-of-two-sequences :) | |
declare function local:testOrder2($baseSequence, $testSequence) { | |
let $positions := $testSequence ! index-of($baseSequence, .) | |
return min(for $pos at $index in tail($positions) return $pos - $positions[$index]) ge 0 | |
}; |
(: @see https://stackoverflow.com/questions/62844910/how-to-deep-compare-maps-to-filter-distinct-items-in-xquery :) | |
declare function local:getDistinctMaps($maps as map(*)*) as map(*)* { | |
fold-left( | |
$maps, | |
(), | |
function($distinct-maps, $new-map) { | |
if (some $map in $distinct-maps satisfies deep-equal($map, $new-map)) | |
then $distinct-maps else ($distinct-maps, $new-map) | |
} | |
) |
<xsl:template match="Person"> | |
<xsl:for-each-group select="Student/Info" group-by="@Country"> | |
<country name="{current-grouping-key()}"> | |
</country> | |
</xsl:for-each-group> | |
</xsl:template> |
var element = document.evaluate( '//body//form/p/textarea' ,document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; | |
if (element != null) { | |
element.value = '...'; | |
} |
<books> | |
<book> | |
<title>XML in 24 hours</title> | |
<author>Some Guy</author> | |
</book> | |
<book> | |
<title>Food in Seattle</title> | |
<author>Some Guy2</author> | |
</book> | |
<book> |
title: Modern XML usefull resources
author: @emchateau, @sardinecan
since: 2020-06-24
description: Selected XML resources from the ANR Experts projet for the NA+DAH Getty advanced workshop.
xquery version "3.1"; | |
declare namespace xpr = "xpr"; | |
declare default element namespace "eac"; | |
declare function local:pairsCombinations($seq) { | |
if (fn:count($seq) = 1) then | |
map{ | |
'source' : $seq | |
} | |
else for $i at $pos in $seq |
xquery version "3.1" ; | |
(:~ | |
: Pairs combinations in a sequence | |
: Unique pairs in a sequence (where order is irrelevant) | |
:) | |
let $seq := ("a", "b", "b", "d") | |
for $i at $pos in $seq | |
for $j in fn:subsequence($seq, $pos+1, fn:count($seq)) | |
return <result>{$i, $j}</result> |