Skip to content

Instantly share code, notes, and snippets.

View tuurma's full-sized avatar

Magdalena Turska tuurma

  • eXist solutions
  • United Kingdom
View GitHub Profile
@tuurma
tuurma / transform.xq
Created September 3, 2018 12:07
basic xquery typeswitch example, assumes play is encoded in TEI like http://firstfolio.bodleian.ox.ac.uk/download/xml/F-tem.xml
xquery version "3.1";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method "html5";
declare option output:media-type "text/html";
@tuurma
tuurma / ports.md
Last active February 11, 2019 10:53
exist contributions

sync develop branch with upstream by rebasing

git checkout develop
git fetch upstream develop
git rebase upstream/develop

check log to confirm commits correspond with the ones for exist/develop

@tuurma
tuurma / update.xql
Last active March 7, 2019 09:58
XQuery update examples
(: insert attribute :)
for $i in collection('/db/apps/my-data')//nym[not(@cert)]
return
update insert attribute cert {'high'} into $i
(: insert more than one node :)
update insert (<a/>, <b/>) into //foo
(: make sure to explicitly specify namespaces when inserting/replacing nodes :)
update insert <surname xmlns="http://www.tei-c.org/ns/1.0">Huo</surname> into //tei:name[.='Otmar']
@tuurma
tuurma / setup.xq
Created April 12, 2019 12:34
moving from xmldb:change-user to sm
xquery version "3.1";
sm:create-group('boys'),
sm:create-group('girls'),
sm:create-group('existsol'),
(: create 3 accounts with personal groups and additional group :)
sm:create-account('magda', 'm-pass', ('girls', 'existsol')),
sm:create-account('lars', 'l-pass', ('boys', 'existsol')),
sm:create-account('joern', 'l-pass', ('boys', 'existsol')),
@tuurma
tuurma / gist:d18b703e87ebb81af8e5a9de322759f9
Created June 6, 2019 11:14
extract individual images from pdf
convert -density 150 -antialias "49548.pdf" -resize 1024x -quality 100 "49548.png"
@tuurma
tuurma / i18n.xq
Last active July 8, 2020 20:26
synchronise Crowdin language files to pb-components
xquery version "3.1";
(:Bulgarian, Czech, Dutch, French, German, Greek, Italian, Norwegian, Polish, Portuguese, Romanian, Slovenian, Spanish, Swedish, Turkish, Ukrainian, Russian, Georgian:)
(:Cymru, Finnish, Hebrew, Hungarian, Japan:)
let $collection := '/db/apps/lang'
let $temp-target := '/db/apps/i18n/temp'
let $final-target := '/db/apps/i18n/common'
let $languages := ('bg', 'cs', 'nl', 'fr', 'de', 'el', 'it', 'no', 'pl', 'pt', 'ro', 'sl', 'es', 'sv', 'tr', 'uk', 'cy', 'fi', 'he', 'hu', 'ja', 'zh_CN', 'zh_TW', 'ka', 'ru')
return
@tuurma
tuurma / namespaces.xq
Created January 19, 2021 09:11
Namespace tricks
(: create an element in a particular namespace :)
element { QName("http://www.w3.org/1999/xhtml", local-name($node)) } {
$node/@*,
$node/node()
}