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:

<bibl xml:id="benesa-d-dmc">
  <author><ref target="benes01">Beneša, Damjan</ref></author>
  <editor><ref target="rezar01">Rezar, Vladimir</ref></editor>
  <editor><ref target="jovanovic01">Neven Jovanović</ref></editor>
  <title xml:lang="lat"><ref target="benes01-c01-153x">De morte Christi, versio electronica</ref></title>
  <pubPlace>Zagreb</pubPlace>
  <publisher>Profil hrvatskog latinizma 
  (<orgName xml:lang="hrv">Filozofski fakultet Sveučilišta u Zagrebu</orgName>)
  </publisher>
  <date when="2012">2012</date>
    <relatedItem type="internet">
      <ref type="croala" target="benesa-d-dmc">CroALa</ref>
    </relatedItem>
</bibl>

The relevant parts of headers in our XML documents should be structured like this:

<teiHeader>
 <fileDesc xml:id="benesa-d-dmc">
    <titleStmt>
	<title>De morte Christi, versio electronica</title>
	<author key="benes01">
		<name xml:lang="hr">Beneša, Damjan</name>
		<date>1476-1539</date>
	</author>
	<editor>Vladimir Rezar</editor>
	<respStmt>
		<resp>Hanc editionem electronicam curavit</resp>
		<name>Neven Jovanović</name>
	</respStmt>
     </titleStmt>
     <extent ana="C">Mg:C 8402 versus, verborum 61948</extent>
     <publicationStmt>
	<p>Izdanje priređeno u okviru znanstvenog projekta Profil hrvatskog latinizma,
	   (Filozofski fakultet Sveučilišta u Zagrebu, Hrvatska). <date>Siječanj
	    2012</date>
        </p>
     </publicationStmt>
(...)
  </fileDesc>
</teiHeader>

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" }
}
 }
 
z/croat-tyrol-biblio-xquery-croala.txt · Last modified: 30. 12. 2013. 13:26 by njovanov
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki