Skip to content

Commit

Permalink
amélioration des index et travail sur rdf
Browse files Browse the repository at this point in the history
  • Loading branch information
emchateau committed Sep 13, 2019
1 parent 6d3a3dc commit 4d71a7a
Show file tree
Hide file tree
Showing 3 changed files with 249 additions and 38 deletions.
125 changes: 107 additions & 18 deletions _restxq/edition.xqm
Expand Up @@ -27,6 +27,7 @@ import module namespace gdp.models.tei = "gdp.models.tei" at '../models/tei.xqm'

import module namespace synopsx.mappings.htmlWrapping = 'synopsx.mappings.htmlWrapping' at '../../../mappings/htmlWrapping.xqm' ;
import module namespace gdp.mappings.jsoner = 'gdp.mappings.jsoner' at '../mappings/jsoner.xqm' ;
import module namespace gdp.mappings.tei2rdf = 'gdp.mappings.tei2rdf' at '../mappings/tei2rdf.xqm' ;

declare default function namespace 'gdp.edition' ;

Expand Down Expand Up @@ -423,12 +424,13 @@ function getHtmlFooter() {

(:~
: sommaire d‘un texte
: @todo
:)

(:~
: resource function for the indexLocorum
:
: @return a list of index entries
: @return an html list of indexes
:)
declare
%rest:path('/gdp/index')
Expand All @@ -455,7 +457,7 @@ function indexes() {
(:~
: resource function for the indexLocorum
:
: @return a json list of index entries
: @return a json list of indexLocorum entries
:)
declare
%rest:path('/gdp/index')
Expand All @@ -480,7 +482,7 @@ function indexesJson() {
(:~
: resource function for the indexLocorum
:
: @return a list of index entries
: @return an html list of indexLocorum entries
:)
declare
%rest:path('/gdp/indexLocorum')
Expand All @@ -507,7 +509,7 @@ function indexLocorum() {
(:~
: resource function for the indexLocorum
:
: @return a json list of index entries
: @return a json list of indexLocorum entries
:)
declare
%rest:path('/gdp/indexLocorum')
Expand All @@ -530,9 +532,65 @@ function indexLocorumJson() {
};

(:~
: resource function for the indexLocorum
: resource function for the indexLocorum item
:
: @return a list of index entries
: @param $itemId the item ID
: @return an html representation of an indexLocorum item
:)
declare
%rest:path('/gdp/indexLocorum/{$itemId}')
%rest:produces('text/html')
%output:method("html")
%output:html-version("5.0")
function indexLocorumItem($itemId) {
let $queryParams := map {
'project' : 'gdp',
'dbName' : 'gdp',
'model' : 'tei',
'function' : 'getIndexLocorumItem',
'itemId' : $itemId
}
let $function := synopsx.models.synopsx:getModelFunction($queryParams)
let $result := fn:function-lookup($function, 1)($queryParams)
let $outputParams := map {
'layout' : 'page.xhtml',
'pattern' : 'incIndexNominum.xhtml',
'xquery' : 'tei2html'
}
return synopsx.mappings.htmlWrapping:wrapper($queryParams, $result, $outputParams)
};

(:~
: resource function for the indexLocorum item
:
: @param $itemId the item ID
: @return a json representation of an indexLocorum item
:)
declare
%rest:path('/gdp/indexLocorum/{$itemId}')
%rest:produces('application/json')
%output:media-type('application/json')
%output:method('json')
function indexLocorumItemJson($itemId) {
let $queryParams := map {
'project' : 'gdp',
'dbName' : 'gdp',
'model' : 'tei',
'function' : 'getIndexLocorumItem',
'itemId' : $itemId
}
let $function := synopsx.models.synopsx:getModelFunction($queryParams)
let $result := fn:function-lookup($function, 1)($queryParams)
let $outputParams := map {
'xquery' : 'tei2html'
}
return gdp.mappings.jsoner:jsoner($queryParams, $result, $outputParams)
};

(:~
: resource function for the indexOperum
:
: @return an html list of indexOperum entries
:)
declare
%rest:path('/gdp/indexOperum')
Expand All @@ -557,9 +615,9 @@ function indexOperum() {
};

(:~
: resource function for the indexLocorum
: resource function for the indexOperum
:
: @return a json list of index entries
: @return a json list of indexOperum entries
:)
declare
%rest:path('/gdp/indexOperum')
Expand All @@ -582,9 +640,10 @@ function indexOperumJson() {
};

(:~
: resource function for the indexOperum item
: resource function for an indexOperum item
:
: @return a list of index entries
: @param $itemId the item ID
: @return an html reprenstation of an indexOperum item
:)
declare
%rest:path('/gdp/indexOperum/{$itemId}')
Expand All @@ -610,9 +669,10 @@ function indexOperumItem($itemId) {
};

(:~
: resource function for the indexOperum item
: resource function for an indexOperum item
:
: @return a json list of index entries
: @param $itemId the item ID
: @return a json reprenstation of an indexOperum item
:)
declare
%rest:path('/gdp/indexOperum/{$itemId}')
Expand All @@ -636,9 +696,9 @@ function indexOperumItemJson($itemId) {
};

(:~
: resource function for the indexLocorum
: resource function for the indexNominum
:
: @return a list of index entries
: @return a html list of indexNominum entries
:)
declare
%rest:path('/gdp/indexNominum')
Expand All @@ -663,9 +723,9 @@ function indexNominum() {
};

(:~
: resource function for the indexLocorum
: resource function for the indexNominum
:
: @return a json list of index entries
: @return a json list of indexNominum entries
:)
declare
%rest:path('/gdp/indexNominum')
Expand All @@ -690,7 +750,8 @@ function indexNominumJson() {
(:~
: resource function for the indexNominum item
:
: @return a list of index entries
: @param $itemId the item ID
: @return an html representation of an indexNominum item
:)
declare
%rest:path('/gdp/indexNominum/{$itemId}')
Expand Down Expand Up @@ -718,7 +779,8 @@ function indexNominumItem($itemId) {
(:~
: resource function for the indexNominum item
:
: @return a json list of index entries
: @param $itemId the item ID
: @return a json representation of an indexNominum item
:)
declare
%rest:path('/gdp/indexNominum/{$itemId}')
Expand All @@ -741,6 +803,33 @@ function indexNominumItemJson($itemId) {
return gdp.mappings.jsoner:jsoner($queryParams, $result, $outputParams)
};

(:~
: resource function for the indexNominum item
:
: @param $itemId the item ID
: @return a jsonLD representation of an indexNominum item
:)
declare
%rest:path('/gdp/indexNominum/{$itemId}/rdf')
%rest:produces('application/json')
%output:media-type('application/json')
%output:method('json')
function indexNominumItemRdf($itemId) {
let $queryParams := map {
'project' : 'gdp',
'dbName' : 'gdp',
'model' : 'tei',
'function' : 'getIndexNominumItem',
'itemId' : $itemId
}
let $function := synopsx.models.synopsx:getModelFunction($queryParams)
let $result := fn:function-lookup($function, 1)($queryParams)
let $outputParams := map {
'xquery' : 'tei2rdf'
}
return gdp.mappings.tei2rdf:tei2rdf($queryParams, $result, $outputParams)
};

(:~
: index œuvres
:)
Expand Down
111 changes: 111 additions & 0 deletions mappings/tei2rdf.xqm
@@ -0,0 +1,111 @@
xquery version '3.0' ;
module namespace gdp.mappings.tei2rdf = 'gdp.mappings.tei2rdf' ;

(:~
: This module is an RDF mapping for templating
:
: @version 3.0
: @date 2019-09
: @since 2019-09
: @author synopsx’s team
:
: This file is part of SynopsX.
: created by AHN team (http://ahn.ens-lyon.fr)
:
: SynopsX is free software: you can redistribute it and/or modify
: it under the terms of the GNU General Public License as published by
: the Free Software Foundation, either version 3 of the License, or
: (at your option) any later version.
:
: SynopsX is distributed in the hope that it will be useful,
: but WITHOUT ANY WARRANTY; without even the implied warranty of
: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
: See the GNU General Public License for more details.
: You should have received a copy of the GNU General Public License along
: with SynopsX. If not, see http://www.gnu.org/licenses/
:
:)

import module namespace G = "synopsx.globals" at '../../../globals.xqm' ;
import module namespace synopsx.models.synopsx = 'synopsx.models.synopsx' at '../../../models/synopsx.xqm' ;

declare namespace tei = 'http://www.tei-c.org/ns/1.0';

declare default function namespace 'gdp.mappings.tei2rdf' ;

(:~
: this function
:
: @param $queryParams the query params defined in restxq
: @param $data the result of the query
: @param $outputParams the serialization params
: @return an
:)
declare function tei2rdf($queryParams as map(*), $data as map(*), $outputParams as map(*)) {
let $contents := map:get($data, 'content')
let $meta := map:get($data, 'meta')
return ''
};

(:~
: this function
:)
declare
%output:indent('no')
function entry($node as node()*, $options as map(*)) as item()* {
for $i in $node return dispatch($i, $options)
};

(:~
: this function dispatches the treatment of the XML document
:)
declare function dispatch($node as node()*, $options as map(*)) as item()* {
typeswitch($node)
case text() return ''
case element(tei:biblStruct) return biblStruct($node, $options)
case element(tei:header) return header($node, $options)
case element(tei:person) return person($node, $options)
case element(tei:place) return place($node, $options)
case element(tei:object) return object($node, $options)
default return passthru($node, $options)
};

(:~
: This function pass through child nodes (xsl:apply-templates)
:)
declare
%output:indent('no')
function passthru($nodes as node(), $options as map(*)) as item()* {
for $node in $nodes/node()
return dispatch($node, $options)
};

declare function header($node, $options) {
''
};

declare function person($node, $options) {
if ($options) then
map {
'@context' : 'http://gdp',
'@id' : $node/@xml:id,
'_ee:e' : ''
}
else
' @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ex: <http://www.example.org/schemas/vehicles#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . '
|| $node/@xml:id || 'a .'
};

declare function place($node, $options) {
''
};

declare function object($node, $options) {
''
};

declare function biblStruct($node, $options) {
''
};

0 comments on commit 4d71a7a

Please sign in to comment.