View on GitHub

NEH Institute materials

July 2022

Home | Call | Admin | Week 1 | Week 2 | References | Slides | App development

TEI Graphing with eXist-db

Day 09 Session 01 slot 03

Background

Initially created for the project Dramawebben (The Swedish Drama Web).

Overview

We combine parts of the TEI namesdates module, like <listPerson> and <listOrg> with relations in <listRelation> elements to create graphs of relations between persons (cast and non-cast) and orgs or interaction on stage (cast only) sociograms.

Personal/organisational relations

Sociograms

Configuration parameters (a lot of them …)

Configuration parameters can be given as a parameters element fragment, eg <parameters><param name=’output’ value=’svg’/></parameters>. The current parameters are the following with the default given as first value:

Query 1: Create an SVG graph over the relations

xquery version "3.1";
import module namespace graphing="http://exist-db.org/xquery/tei-graphing";
declare namespace tei="http://www.tei-c.org/ns/1.0";
let $doc := doc("/db/data/dramawebben/StrindbergA_TillDamaskus/StrindbergA_TillDamaskus.xml")
(: doc("/db/data/dramawebben/HedbergF_Rospiggarna/HedbergF_Rospiggarna.xml") :)
return
graphing:relation-graph($doc//tei:listPerson[not(parent::tei:listPerson)], $doc//tei:listRelation,
                        <parameters><param name="output" value="svg"/></parameters>)

Remember the basic shapes from yesterday?

Let us quickly look at one more (text):

<g fill="rgb(51,51,51)" text-rendering="optimizeLegibility" font-family="sans-serif" 
   transform="translate(299,266)" stroke="rgb(51,51,51)">
    <text x="0" xml:space="preserve" y="12" clip-path="url(#clipPath79)" 
                stroke="none">FruÖsterberg</text>
</g>

Query 2: Create a graph over the relations, but in GraphML this time

xquery version "3.1";
import module namespace graphing="http://exist-db.org/xquery/tei-graphing";
declare namespace tei="http://www.tei-c.org/ns/1.0";
let $doc := doc("/db/data/dramawebben/StrindbergA_TillDamaskus/StrindbergA_TillDamaskus.xml")
(: doc("/db/data/dramawebben/HedbergF_Rospiggarna/HedbergF_Rospiggarna.xml") :)
return
graphing:relation-graph($doc//tei:listPerson[not(parent::tei:listPerson)], $doc//tei:listRelation, 
                        <parameters><param name="output" value="graphml"/></parameters>)

Query 3: Create a graph over the relations, but finally in gexf

xquery version "3.1";
import module namespace graphing="http://exist-db.org/xquery/tei-graphing";
declare namespace tei="http://www.tei-c.org/ns/1.0";
let $doc := doc("/db/data/dramawebben/StrindbergA_TillDamaskus/StrindbergA_TillDamaskus.xml")
(: doc("/db/data/dramawebben/HedbergF_Rospiggarna/HedbergF_Rospiggarna.xml") :)
return
graphing:relation-graph($doc//tei:listPerson[not(parent::tei:listPerson)], $doc//tei:listRelation, 
                        <parameters><param name="output" value="gexf"/></parameters>)

The updated app

and finally a w3c and exist-db example to show it can do other graphs than from full TEI documents

eXist-db related to XML and other W3C standards