Skip to content

Commit

Permalink
replace @dbkey with @codedval
Browse files Browse the repository at this point in the history
  • Loading branch information
peterstadler committed Mar 23, 2020
1 parent eeaf337 commit e4bcfd4
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions modules/app.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ declare
let $anonymusID := config:get-option('anonymusID')
let $authorElem :=
(: NB: there might be multiple anonymous authors :)
if ($authorID = $anonymusID) then (query:get-author-element($model?doc)[(count(@key | @dbkey) = 0) or ((@key, @dbkey) = $anonymusID)])[1]
if ($authorID = $anonymusID) then (query:get-author-element($model?doc)[(count(@key | @codedval) = 0) or ((@key, @codedval) = $anonymusID)])[1]
(: NB: there might be multiple occurences of the same person as e.g. composer and lyricist :)
else (query:get-author-element($model?doc)[(@key, @dbkey) = $authorID])[1]
else (query:get-author-element($model?doc)[(@key, @codedval) = $authorID])[1]
let $href :=
if ($authorID = $anonymusID) then ()
else app:createUrlForDoc(core:doc($authorID), $lang)
Expand Down Expand Up @@ -1899,7 +1899,7 @@ declare
%templates:default("lang", "en")
%templates:default("popover", "false")
function app:preview-relator-name($node as node(), $model as map(*), $lang as xs:string, $popover as xs:string) as element() {
let $key := $model('relator')/@dbkey | $model('relator')/@key
let $key := $model('relator')/@codedval | $model('relator')/@key
let $myPopover :=
if($popover castable as xs:boolean) then xs:boolean($popover)
else false()
Expand Down
10 changes: 5 additions & 5 deletions modules/query.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ declare function query:title($key as xs:string) as xs:string {
:)
declare function query:get-authorID($doc as document-node()?) as xs:string* {
let $author-element := query:get-author-element($doc)
let $id := $author-element/@key | $author-element/@dbkey
let $id := $author-element/@key | $author-element/@codedval
return
if(exists($doc) and count($id) gt 0) then $id ! string(.)
else if(exists($doc)) then config:get-option('anonymusID')
Expand Down Expand Up @@ -304,10 +304,10 @@ declare function query:get-facets($collection as node()*, $facet as xs:string) a
case 'placeOfAddressee' return $collection//tei:settlement[parent::tei:correspAction/@type='received']/@key
case 'journals' return $collection//tei:title[@level='j'][not(@type='sub')][ancestor::tei:sourceDesc]
case 'places' return $collection//tei:settlement[ancestor::tei:text or ancestor::tei:ab]/@key
case 'dedicatees' return $collection//mei:persName[@role='dte']/@dbkey
case 'lyricists' return $collection//mei:persName[@role='lyr']/@dbkey
case 'librettists' return $collection//mei:persName[@role='lbt']/@dbkey
case 'composers' return $collection//mei:persName[@role='cmp']/@dbkey
case 'dedicatees' return $collection//mei:persName[@role='dte']/@codedval
case 'lyricists' return $collection//mei:persName[@role='lyr']/@codedval
case 'librettists' return $collection//mei:persName[@role='lbt']/@codedval
case 'composers' return $collection//mei:persName[@role='cmp']/@codedval
case 'docSource' return $collection/tei:person/@source
case 'occupations' return $collection//tei:occupation
case 'residences' return $collection//tei:settlement[parent::tei:residence]/@key
Expand Down
8 changes: 4 additions & 4 deletions modules/wdt.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ declare function wdt:works($item as item()*) as map(*) {
$item/root()[mei:mei][descendant::mei:meiHead]
},
'filter-by-person' : function($personID as xs:string) as document-node()* {
$item/root()/descendant::mei:persName[@dbkey = $personID][@role=('cmp', 'lbt', 'lyr', 'aut', 'trl')][ancestor::mei:fileDesc]/root()
$item/root()/descendant::mei:persName[@codedval = $personID][@role=('cmp', 'lbt', 'lyr', 'aut', 'trl')][ancestor::mei:fileDesc]/root()
},
'filter-by-date' : function($dateFrom as xs:date?, $dateTo as xs:date?) as document-node()* {
if(empty(($dateFrom, $dateTo))) then $item/root()
Expand Down Expand Up @@ -746,7 +746,7 @@ declare function wdt:sources($item as item()*) as map(*) {
$item/root()[mei:source][descendant::mei:titleStmt][not(descendant::mei:annot[@type='no-ordinary-record'])]
},
'filter-by-person' : function($personID as xs:string) as document-node()* {
if(config:is-person($personID) or config:is-org($personID)) then $item/root()/descendant::mei:persName[@dbkey = $personID][@role=('cmp', 'lbt', 'lyr', 'aut', 'trl')][ancestor::mei:titleStmt]/root()
if(config:is-person($personID) or config:is-org($personID)) then $item/root()/descendant::mei:persName[@codedval = $personID][@role=('cmp', 'lbt', 'lyr', 'aut', 'trl')][ancestor::mei:titleStmt]/root()
else if(config:is-work($personID)) then $item/root()/descendant::mei:identifier[.=$personID][@type = 'WeGA']/root()
else ()
},
Expand Down Expand Up @@ -1019,7 +1019,7 @@ declare function wdt:backlinks($item as item()*) as map(*) {
core:data-collection('news')//tei:author[@key = $personID][ancestor::tei:fileDesc]/root() |
core:data-collection('thematicCommentaries')//tei:author[@key = $personID][ancestor::tei:fileDesc]/root() |
core:data-collection('documents')//tei:author[@key = $personID][ancestor::tei:fileDesc]/root() |
core:data-collection('works')//mei:persName[@dbkey = $personID][@role=('cmp', 'lbt', 'lyr', 'aut', 'trl')][ancestor::mei:fileDesc]/root()
core:data-collection('works')//mei:persName[@codedval = $personID][@role=('cmp', 'lbt', 'lyr', 'aut', 'trl')][ancestor::mei:fileDesc]/root()
let $docsMentioned :=
core:data-collection('letters')//tei:*[contains(@key,$personID)][not(ancestor::tei:publicationStmt)]/root() |
core:data-collection('diaries')//tei:*[contains(@key,$personID)]/root() |
Expand All @@ -1032,7 +1032,7 @@ declare function wdt:backlinks($item as item()*) as map(*) {
core:data-collection('thematicCommentaries')//tei:*[contains(@key,$personID)][not(ancestor::tei:publicationStmt)]/root() |
core:data-collection('documents')//tei:*[contains(@key,$personID)][not(ancestor::tei:publicationStmt)]/root() |
core:data-collection('var')//tei:*[contains(@key,$personID)][not(ancestor::tei:publicationStmt)]/root() |
core:data-collection('works')//mei:*[contains(@dbkey,$personID)][not(ancestor::mei:revisionDesc)]/root() |
core:data-collection('works')//mei:*[contains(@codedval,$personID)][not(ancestor::mei:revisionDesc)]/root() |
(: <ref target="wega:A002068"/> :)
core:data-collection('letters')//tei:*[contains(@target, 'wega:' || $personID)]/root() |
core:data-collection('diaries')//tei:*[contains(@target,'wega:' || $personID)]/root() |
Expand Down
2 changes: 1 addition & 1 deletion modules/wega-util.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ declare function wega-util:check-if-update-necessary($currentDateTimeOfFile as x
: @return xs:string
:)
declare function wega-util:print-forename-surname-from-nameLike-element($nameLikeElement as element()?) as xs:string? {
let $id := $nameLikeElement/(@key, @dbkey)
let $id := $nameLikeElement/(@key, @codedval)
return
(: the most specific case first: a reg-name with leading forename, e.g. `<persName type="reg"><forename>Eugen</forename> <forename>Friedrich</forename>…` :)
if(($nameLikeElement/element()[1])[self::tei:forename]) then str:normalize-space($nameLikeElement)
Expand Down
4 changes: 2 additions & 2 deletions xsl/common_funcs.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<xsl:choose>
<xsl:when test="wega:isWork($docID) and exists($doc)">
<xsl:choose>
<xsl:when test="$doc//mei:titleStmt/mei:respStmt/mei:persName[@role = 'cmp'][1]/@dbkey">
<xsl:value-of select="$doc//mei:titleStmt/mei:respStmt/mei:persName[@role = 'cmp'][1]/string(@dbkey)"/>
<xsl:when test="$doc//mei:titleStmt/mei:respStmt/mei:persName[@role = 'cmp'][1]/@codedval">
<xsl:value-of select="$doc//mei:titleStmt/mei:respStmt/mei:persName[@role = 'cmp'][1]/string(@codedval)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="wega:getOption('anonymusID')"/>
Expand Down
18 changes: 9 additions & 9 deletions xsl/common_link.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<!-- ********************************************* -->
<xsl:template match="tei:persName | tei:author | tei:orgName | mei:persName | tei:workName | tei:settlement | mei:geogName" mode="#all">
<xsl:choose>
<xsl:when test="@key or @dbkey">
<xsl:when test="@key or @codedval">
<xsl:call-template name="createLink"/>
</xsl:when>
<xsl:otherwise>
Expand Down Expand Up @@ -108,19 +108,19 @@
</xsl:attribute>
</xsl:template>

<xsl:template match="@key[not(matches(., '\s'))] | @dbkey[not(matches(., '\s'))]">
<xsl:template match="@key[not(matches(., '\s'))] | @codedval[not(matches(., '\s'))]">
<xsl:attribute name="href" select="wega:createLinkToDoc(., $lang)"/>
</xsl:template>

<xsl:template name="createLink">
<xsl:choose>
<xsl:when test="exists((@key, @dbkey, @target)) and not(descendant::*[local-name(.) = $linkableElements])">
<xsl:when test="exists((@key, @codedval, @target)) and not(descendant::*[local-name(.) = $linkableElements])">
<xsl:element name="a">
<xsl:attribute name="class">
<xsl:value-of select="wega:preview-class(.)"/>
</xsl:attribute>
<!--<xsl:attribute name="href" select="wega:createLinkToDoc((@key, @dbkey), $lang)"/>-->
<xsl:apply-templates select="@key | @dbkey | @target"/>
<!--<xsl:attribute name="href" select="wega:createLinkToDoc((@key, @codedval), $lang)"/>-->
<xsl:apply-templates select="@key | @codedval | @target"/>
<xsl:apply-templates mode="#current"/>
</xsl:element>
</xsl:when>
Expand All @@ -136,7 +136,7 @@
<xsl:apply-templates select="@xml:id"/>
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="exists((@key, @dbkey, @target))">
<xsl:when test="exists((@key, @codedval, @target))">
<xsl:value-of select="wega:preview-class(.)"/>
</xsl:when>
<xsl:otherwise>
Expand All @@ -147,9 +147,9 @@
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:if test="exists((@key, @dbkey, @target))">
<xsl:if test="exists((@key, @codedval, @target))">
<xsl:variable name="urls" as="xs:string+">
<xsl:for-each select="descendant-or-self::*/@key | descendant-or-self::*/@dbkey | descendant-or-self::*/@target[starts-with(., 'wega:')]">
<xsl:for-each select="descendant-or-self::*/@key | descendant-or-self::*/@codedval | descendant-or-self::*/@target[starts-with(., 'wega:')]">
<xsl:for-each select="tokenize(normalize-space(.), '\s+')">
<xsl:choose>
<xsl:when test="starts-with(.,'wega:')">
Expand All @@ -174,7 +174,7 @@
<xsl:function name="wega:preview-class" as="xs:string">
<xsl:param name="myNode" as="element()"/>
<xsl:variable name="keys" select="
for $key in tokenize(($myNode/@key, $myNode/@dbkey, $myNode/@target/replace(., 'wega:', '')), '\s+')
for $key in tokenize(($myNode/@key, $myNode/@codedval, $myNode/@target/replace(., 'wega:', '')), '\s+')
return substring($key, 1, 7)
" as="xs:string+"/>
<xsl:variable name="class" as="xs:string">
Expand Down

0 comments on commit e4bcfd4

Please sign in to comment.