Skip to content

Commit

Permalink
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
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
51 changes: 51 additions & 0 deletions res/xml/xquery/allchapters.xq
@@ -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>
23 changes: 23 additions & 0 deletions res/xml/xquery/allpublications.xq
@@ -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>

0 comments on commit 6325e78

Please sign in to comment.