Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
wikidata to dracor
xquery version "3.1";
import module namespace functx="";
declare namespace tei="";
let $path := "......../dlina/GerDraCor and Wikidata.csv"
let $rows :=
=> util:binary-to-string()
=> tokenize("\n"))[position() gt 1]
let $collection-uri := "/db/gerdracorQ"
let $read-in :=
let $directory := "......../dlina/dracor-ger/tei/"
xmldb:create-collection("/db", "gerdracorQ"),
xmldb:store-files-from-pattern($collection-uri, $directory, "*.xml")
for $row in $rows
(: parse CSV :)
let $tokenzzzzz := tokenize($row, ",")
let $filename := $tokenzzzzz[1] || ".xml"
let $wikidataUrl := $tokenzzzzz[2]
let $Q := substring-after($wikidataUrl, "/wiki/")
let $idno := <tei:idno type="wikidata" xml:base="">{$Q}</tei:idno>
=> functx:change-element-ns-deep("", "")
let $tei := doc($collection-uri || "/" || $filename)/*
let $do := update insert $idno into $tei//tei:publicationStmt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment