-
Notifications
You must be signed in to change notification settings - Fork 0
/
ead2grefine_xquery3-namespace.xq
32 lines (30 loc) · 1.79 KB
/
ead2grefine_xquery3-namespace.xq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
xquery version "3.0";
declare namespace ead = "urn:isbn:1-931666-22-9";
element names {
for $ead in /ead:ead
let $all_names := $ead//*[self::ead:persname or self::ead:corpname or self::ead:famname]
for $name in $all_names
let $collectiontitle := $ead/ead:archdesc/ead:did/ead:unittitle/descendant-or-self::*/text(),
$eadid := $ead/ead:eadheader/ead:eadid,
$publisher := $ead/ead:eadheader/ead:filedesc/ead:publicationstmt/ead:publisher,
$xpathNS := replace(fn:path($name), 'Q\{urn:isbn:1-931666-22-9\}', 'ead:'),
$orignationlabel := $name/parent::ead:origination/@label,
(: This should be updated, but for now I'm just grabbing the contents of the bioghist(s) if the "name" is a child of an origination element (i.e. it's NOT looking to see if there is a potentially related bioghist if the name occurs elsewhere). This text is then used to assist in Google Refine's reconcilation process :)
$bioghist := $name/parent::ead:origination/parent::ead:did/parent::ead:archdesc/ead:bioghist/descendant::*[not(name()='head')]/text()
where $name ne '' and not($name/parent::ead:repository/parent::ead:did/parent::ead:archdesc)
return
<name>
<namestring>{normalize-unicode(normalize-space($name))}</namestring>
<encodinganalog>{data($name/@encodinganalog)}</encodinganalog>
<normalattribute>{data($name/@normal)}</normalattribute>
<altrender>{data($name/@altrender)}</altrender>
<elementname>{name($name)}</elementname>
<orignationlabel>{data($orignationlabel)}</orignationlabel>
<bioghist>{data($bioghist)}</bioghist>
<parentcollection>{data($collectiontitle)}</parentcollection>
<parentID>{data($eadid)}</parentID>
<mainagencycode>{data($eadid/@mainagencycode)}</mainagencycode>
<publisher>{data($publisher)}</publisher>
<xpath>{$xpathNS}</xpath>
</name>
}