Skip to content

Commit

Permalink
templates and more xquery
Browse files Browse the repository at this point in the history
  • Loading branch information
martinascholger committed Sep 22, 2024
1 parent b236c48 commit d391b20
Show file tree
Hide file tree
Showing 4 changed files with 10,886 additions and 0 deletions.
105 changes: 105 additions & 0 deletions docs/xquery2.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,79 @@ eXist unterstützt diese Kommentare mit der App "XQuery Function
Documentation", siehe <https://exist-db.org/exist/apps/fundocs/index.html>


## Auflistung aller Brieftitel

```xquery
xquery version "3.1";
(:
: Namespace declarations
:)
declare namespace ess="https://exist.edirom.de";
declare namespace xhtml="http://www.w3.org/1999/xhtml";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace js="http://exist-db.org/xquery/javascript";
(:~
: Returns an HTML list of the letter's titles.
: Calls ess:letter2tr#1 to process the individual letter
:
: @param $letters the TEI letters to process
: @return the table (xhtml:table) with one row for every letter
:)
declare function ess:letters2list($letters as document-node()*) as element(table) {
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Listing</title>
<link rel="stylesheet" href="tei.css" media="screen"/>
</head>
<body>
<ul>
{
$letters ! ess:letter2list(.)
}
</ul>
</body>
</html>};
(:~
: Returns a HTML list with the title of the letter linking to the full letter
:)
declare function ess:letter2list($letter as document-node()?) as element(li)? {
let $id := $letter/tei:TEI/@xml:id => string()
let $title := $letter//tei:title[@level='a'][1]
let $string := string-join(
for $node in $title/node()
return if ($node/name() = 'lb') then ' ' else $node, ''
)
order by $title
return
if ($id != "" and $string != "")
then
<li xmlns="http://www.w3.org/1999/xhtml"><a href="/exist/apps/WeGA-data/tei2html.xq?{$id}">{$string}</a></li>
else()
};
collection('/db/apps/WeGA-data/letters') => ess:letters2list()
```

## Ausführen von XSLT-Stylesheets innerhalb eines XQuery

eXist stellt die Funktion transform zur Verfügung:
```xquery
transform:transform($node-tree as node()*, $stylesheet as item(), $parameters as node()?) as node()?
```



### Beispiel

```xquery
Expand Down Expand Up @@ -155,6 +221,45 @@ declare option output:omit-xml-declaration "yes";
</html>
```

### XSLT zur Transformation der Briefe
```xml
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:math="http://www.w3.org/2005/xpath-functions/math"
xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="tei xs math"
version="3.0">

<xsl:template match="/">
<div>
<xsl:apply-templates select="tei:TEI/tei:text/tei:body/tei:div[@type='writingSession']" />
</div>
</xsl:template>

<xsl:template match="tei:opener | tei:closer | tei:p">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>

<xsl:template match="tei:choice">
<xsl:apply-templates select="tei:expan"/>
</xsl:template>

<xsl:template match="tei:abbr"/>

<xsl:template match="tei:persName">
<a href="{@ref}">
<xsl:apply-templates/>
</a>
</xsl:template>


</xsl:stylesheet>
```

Some example XSL:

```xml
Expand Down
62 changes: 62 additions & 0 deletions scripts/briefmetadaten.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!DOCTYPE html>
<!-- Vorlage für die Erstellung von Tabellen in HTML und Einbindung der Javascript-Bibliothek DataTables zur Integration von Interaktivität in statische HTML-Tabellen.
Für die Dokumentaiton siehe https://datatables.net/ -->
<html>
<head>
<title>Briefmetadaten</title>
<link rel="stylesheet" href="https://cdn.datatables.net/2.1.4/css/dataTables.dataTables.css" />
<script src="js/jquery-3.7.1.js"></script>
<script src="https://cdn.datatables.net/2.1.4/js/dataTables.js"></script>
<script src="js/ready.js"></script>
</head>
<body>
<table id="myTable" class="display">
<thead>
<tr>
<th>Identifikator</th>
<th>Sender:in</th>
<th>Empfänger:in</th>
<th>Absendeort</th>
<th>Datierung</th>
</tr>
</thead>
<tbody>
<tr>
<td>A040000</td>
<td>Förster, Karl</td>
<td>Friedländer, Ludwig Hermann</td>
<td>Dresden</td>
<td>1820-07-25, not after</td>
</tr>
<tr>
<td>A040046</td>
<td>Weyrauch, Jeanette</td>
<td>Vigitill, Elise</td>
<td>Nürnberg</td>
<td>1792-09-08</td>
</tr>
<tr>
<td>A040091</td>
<td>Weber, Adelheid</td>
<td>Weber, Fridolin</td>
<td>München</td>
<td>1799-08-29</td>
</tr>
<tr>
<td>A040096</td>
<td>Härtel, Gottfried Christoph</td>
<td>Weber, Franz Anton von</td>
<td>Leipzig</td>
<td>1800-09-27</td>
</tr>
<tr>
<td>A040099</td>
<td>Rochlitz, Johann Friedrich</td>
<td>Apel, August</td>
<td>Stuttgart</td>
<td>1800-05-21</td>
</tr>
</tbody>
</table>
</body>
</html>
Loading

0 comments on commit d391b20

Please sign in to comment.