Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add sundry xqueries
- Loading branch information
kthoden
committed
Aug 21, 2020
1 parent
24cda9d
commit 6325e78
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
xquery version "3.1"; | ||
|
||
|
||
declare namespace tei = "http://www.tei-c.org/ns/1.0"; | ||
|
||
|
||
<publications> | ||
{ | ||
for $book in collection('/db/xml_files/publications') | ||
let $series := $book//tei:seriesStmt/tei:title/text() | ||
let $number := xs:int($book//tei:seriesStmt/tei:idno/text()) | ||
let $title := $book//tei:titleStmt/tei:title[@type = 'main']/node() | ||
let $chapter := $book//tei:text//tei:div[@type = 'chapter'] | ||
for $bit in $chapter | ||
let $chaptertitle := $bit/tei:head/node() | ||
let $chapterlanguage := xs:string($bit/@xml:lang) | ||
let $chapterabstract := $bit/ab[@type='chapterabstract'] | ||
let $nonumber := $bit/@n | ||
let $order := index-of($chapter, $bit) | ||
let $resp := xs:string($bit/@resp) | ||
let $resplist := tokenize($resp, " ") | ||
order by $series, $number, $order | ||
return | ||
<pub>{ | ||
<title>{ $chaptertitle }</title>, <booktitle>{ $title }</booktitle>, <series>{ $series }</series>, | ||
<number>{ $number }</number>, <order>{ $order }</order>, <chapterlanguage>{$chapterlanguage}</chapterlanguage>, <chapterabstract>{$chapterabstract}</chapterabstract>,<creators>{$resplist}</creators>,<numbered>{if ($nonumber = 'nonumber') then ("false") else ("true")}</numbered>, | ||
<authors> | ||
{ | ||
for $pp in $resplist | ||
let $localname := xs:string($book/*//tei:respStmt[@xml:id = substring-after($pp, "#")]/tei:persName/@xml:lang) | ||
let $inbookid := xs:string($book/*//tei:respStmt[@xml:id = substring-after($pp, "#")]/@xml:id) | ||
let $firstname := | ||
$book/*//tei:respStmt[@xml:id = substring-after($pp, "#")]/tei:persName/tei:forename/node() | ||
let $lastname := | ||
$book/*//tei:respStmt[@xml:id = substring-after($pp, "#")]/tei:persName/tei:surname/node() | ||
return | ||
<author><fullname>{ | ||
if ($localname = "zh") then | ||
(concat($lastname, ' ', $firstname)) | ||
else | ||
(concat($firstname, ' ', $lastname)) | ||
}</fullname> | ||
<firstname>{$firstname}</firstname> | ||
<lastname>{$lastname}</lastname> | ||
<inbookid>{$inbookid}</inbookid> | ||
</author> | ||
} | ||
</authors>} | ||
</pub> | ||
} | ||
</publications> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
xquery version "3.1"; | ||
|
||
|
||
declare namespace tei = "http://www.tei-c.org/ns/1.0"; | ||
|
||
|
||
<publications> | ||
{ | ||
for $book in collection('/db/xml_files/publications') | ||
let $series := $book//tei:seriesStmt/tei:title/text() | ||
let $number := xs:int($book//tei:seriesStmt/tei:idno/text()) | ||
let $abstract := $book//tei:profileDesc/tei:abstract[@n = 'brief']/tei:p | ||
let $title := $book//tei:titleStmt/tei:title[@type = 'main']/node() | ||
let $coverimage := $book//tei:text/tei:front/tei:figure[@type = 'cover']/tei:graphic/@url | ||
return | ||
<pub>{ | ||
<title>{ $title }</title>, <series>{ $series }</series>, <number>{ $number }</number>, | ||
<abstract>{ $abstract }</abstract>, | ||
<coverpath>{ concat("/", lower-case($series), "/", $number, "/", $coverimage) }</coverpath> | ||
} | ||
</pub> | ||
} | ||
</publications> |