Code Snippets XQuery

Short texts XQuery 🧑‍💻 Code snippets XQuery ✍️ Reading lists XQuery 👀

Batch change permissions on resources and collections in eXist-db

xquery version “3.1”; import module namespace dbutil=”http://exist-db.org/xquery/dbutil”; dbutil:scan( xs:anyURI(“/db/apps/airlock-data”), function($col, $res) { if ($res) then (: Set permissions on resources here 🙂 ( sm:chgrp($res, “airlock”), sm:chmod($res, “rwxrwxr-x”) ) else (: Set permissions on collections here 🙂 ( sm:chgrp($col, “airlock”), sm:chmod($col, “rwxrwxr-x”) ) } )

Validate MTSU_16

xquery version “3.1”; declare variable $oai-resp := fetch:xml(“http://cdm15838.contentdm.oclc.org/oai/oai.php?verb=ListRecords&set=p15838coll16&metadataPrefix=oai_dc”); (: you’ll want to modify these paths if you want to double-check this 🙂 declare variable $xslt := “/home/bridger/Documents/metadata-notes/DLTN/XSLT/mtsup15838coll16dctomods.xsl”; declare variable $schema := “/home/bridger/Documents/metadata-notes/DLTN/tests/testSchemas/DLTN_oai_mods.xsd”; $oai-resp => xslt:transform($xslt) => validate:xsd-report(file:read-text($schema)), (: alternate method 🙂 file:write( “/tmp/mtsu_16.oai.xml”, $oai-resp, map {“method”: “xml” } ), file:write( “/tmp/mtsu_16.transformed.xml”, xslt:transform(“/tmp/mtsu_16.oai.xml”, $xslt), map { […]