====== Creating a bibliographical record for texts in CroALa via XQuery ====== Every digital text in the CroALa collection has a TEI Header. From this header, we want to produce a bibliographical record, in the following format: Beneša, Damjan Rezar, Vladimir Neven Jovanović <ref target="benes01-c01-153x">De morte Christi, versio electronica</ref> Zagreb Profil hrvatskog latinizma (Filozofski fakultet Sveučilišta u Zagrebu) 2012 CroALa The relevant parts of headers in our XML documents should be structured like this: De morte Christi, versio electronica Beneša, Damjan 1476-1539 Vladimir Rezar Hanc editionem electronicam curavit Neven Jovanović Mg:C 8402 versus, verborum 61948

Izdanje priređeno u okviru znanstvenog projekta Profil hrvatskog latinizma, (Filozofski fakultet Sveučilišta u Zagrebu, Hrvatska). Siječanj 2012

(...)
This is the XQuery to be applied: for $i in //*:teiHeader order by $i/*:fileDesc/@xml:id return element bibl { attribute xml:id { $i/*:fileDesc/@xml:id } , (: autora može biti više :) for $a in $i/*:fileDesc/*:titleStmt/*:author return element author { element ref { attribute target { $a/@key } , data($a/*:name|*:persName) } } , (: izdavača može biti više :) for $e in $i/*:fileDesc/*:titleStmt/*:editor return element editor { element ref { data($e) } }, (: naslov :) element title { element ref { data($i/*:fileDesc/*:titleStmt/*:title[1]) } } , (: mjesto izdanja, uvijek isto :) element pubPlace { "Zagreb" } , element publisher { $i/*:fileDesc/*:publicationStmt/*:p[1]/text() } , (: datum digitalnog izdanja :) element date { attribute when { replace($i/*:fileDesc/*:publicationStmt/*:p[1]/*:date[1], '[^0-9]' , '') } , replace(data($i/*:fileDesc/*:publicationStmt/*:p[1]/*:date[1]), '[^0-9]', '') } , (: poveznica na datoteku na internetu :) element relatedItem { attribute type { "internet" }, element ref { attribute type { "croala" } , attribute target { $i/*:fileDesc/@xml:id } , "CroALa" } } }