-
Notifications
You must be signed in to change notification settings - Fork 0
/
ead2grefine_xquery1-no-namespace.xq
42 lines (38 loc) · 1.96 KB
/
ead2grefine_xquery1-no-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
33
34
35
36
37
38
39
40
41
42
declare namespace mdc = "http://mdc.functions";
declare function mdc:xpath
($nodes as node()*) as xs:string* {
for $node in $nodes/ancestor-or-self::*
let $numPrecSiblings := count($node/preceding-sibling::*[name()=name($node)])
for $number in $numPrecSiblings
let $position := $number
return
concat('/', name($node), '[', $position + 1, ']')
};
element names {
for $ead in /ead
let $all_names := $ead//*[self::persname or self::corpname or self::famname]
for $name in $all_names
let $collectiontitle := $ead/archdesc/did/unittitle/descendant-or-self::*/text(),
$eadid := $ead/eadheader/eadid,
$publisher := $ead/eadheader/filedesc/publicationstmt/publisher,
$xpath := string-join(mdc:xpath($name), ''),
$orignationlabel := $name/parent::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::origination/parent::did/parent::archdesc/bioghist/descendant::*[not(name()='head')]/text()
where $name ne '' and not($name/parent::repository/parent::did/parent::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>{$xpath}</xpath>
</name>
}