Skip to content

Commit

Permalink
Switch testimony metadata namespace away from default faustedition.
Browse files Browse the repository at this point in the history
  • Loading branch information
thvitt committed Apr 2, 2019
1 parent 798075b commit 90c7c7e
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 68 deletions.
12 changes: 6 additions & 6 deletions exist/testimony.xql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ xquery version "3.1";

declare default element namespace "http://www.w3.org/1999/xhtml";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
declare namespace f = "http://www.faustedition.net/ns";
declare namespace t = "http://www.faustedition.net/ns/testimony";

declare option exist:serialize "method=xhtml enforce-xhtml=yes";

Expand All @@ -16,16 +16,16 @@ declare variable $data := collection((if ($xmlpath) then $xmlpath else '/db/apps


let $query := request:get-parameter('q', 'hauptgeschäft'),
$matches := $data//(tei:text|f:field)[ft:query(., $query)],
$matches := $data//(tei:text|t:field)[ft:query(., $query)],
$hitcount := count($matches)
return <article class="results" data-hits="{$hitcount}">
<h2>{$hitcount} Treffer</h2>{
for $match in $matches
let $root := root($match),
$id := $root//f:testimony/@id,
$id := $root//t:testimony/@id,
$title := $root//tei:title,
$nr := number($root//f:field[@name='lfd-nr-neu-2']),
$hit := if ($match[self::f:field])
$nr := number($root//t:field[@name='lfd-nr-neu-2']),
$hit := if ($match[self::t:field])
then <dl><dt>{data($match/@label)}</dt><dd>{data($match)}</dd></dl>
else kwic:summarize($match, <config xmlns="" width="75" link="/testimony/{$id}#{$id}"/>)
order by $nr
Expand All @@ -34,4 +34,4 @@ return <section class="hit metadata-container">
<h3><a href="/testimony/{$id[1]}">{data($title[1])}</a></h3>
{$hit}
</section>
}</article>
}</article>
2 changes: 1 addition & 1 deletion testimonies.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def improve_testimony_table(testimonies):
return testimonies

def to_xml(testimony_df, orignames, output_file=None):
ns = "http://www.faustedition.net/ns"
ns = "http://www.faustedition.net/ns/testimony"
NS = "{"+ns+"}"
nsmap = {None : ns}
root = etree.Element(NS + "testimonies", nsmap=nsmap)
Expand Down
8 changes: 5 additions & 3 deletions testimony.xpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xmlns:c="http://www.w3.org/ns/xproc-step"
xmlns:cx="http://xmlcalabash.com/ns/extensions" xmlns:f="http://www.faustedition.net/ns"
xmlns:cx="http://xmlcalabash.com/ns/extensions" xmlns:f="http://www.faustedition.net/ns"
xmlns:t="http://www.faustedition.net/ns/testimony"
xmlns:pxf="http://exproc.org/proposed/steps/file"
xmlns:l="http://xproc.org/library" type="f:testimony" name="main" version="1.0">

Expand Down Expand Up @@ -74,6 +75,7 @@
<p:pipe port="secondary" step="split-testimony"/>
</p:iteration-source>
<p:variable name="base-uri" select="p:base-uri()"/>
<p:variable name="html-file" select="p:resolve-uri(replace(p:base-uri(), '.*/([^/.]*)\.xml$', '$1.html'), $testihtml)"/>

<p:identity name="single-testimony-tei"/>

Expand All @@ -89,7 +91,7 @@
</p:xslt>

<p:store encoding="utf-8" method="xhtml" include-content-type="false" indent="true">
<p:with-option name="href" select="p:resolve-uri(replace(p:base-uri(), '.*/([^/.]*)\.xml$', '$1.html'), $testihtml)"/>
<p:with-option name="href" select="$html-file"/>
</p:store>

<!-- For search, we skip the context data -->
Expand All @@ -99,7 +101,7 @@
<p:inline>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xpath-default-namespace="http://www.tei-c.org/ns/1.0">
<xsl:import href="xslt/testimony-common.xsl"/>
<xsl:template match="f:field">
<xsl:template match="t:field">
<xsl:variable name="spec" select="f:fieldspec(@name)"/>
<xsl:choose>
<xsl:when test="$spec/@ignore='yes'"/>
Expand Down
37 changes: 19 additions & 18 deletions xslt/single-testimony-html.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:f="http://www.faustedition.net/ns"
xmlns:t="http://www.faustedition.net/ns/testimony"
xmlns="http://www.w3.org/1999/xhtml"
xpath-default-namespace="http://www.tei-c.org/ns/1.0"
exclude-result-prefixes="xs"
version="2.0">

<xsl:import href="testimony2html.xsl"/>

<xsl:variable name="id" select="data(//f:testimony/@id)"/>
<xsl:variable name="id" select="data(//t:testimony/@id)"/>



Expand All @@ -31,7 +32,7 @@
<xsl:with-param name="content">
<div class="testimony pure-g-r">
<div class="pure-u-5-12">
<xsl:apply-templates select="//f:testimony"/>
<xsl:apply-templates select="//t:testimony"/>
</div>
<div class="pure-u-5-12">
<xsl:apply-templates select="//text//text[not(@copyOf)]"/>
Expand All @@ -43,72 +44,72 @@
</xsl:template>


<xsl:template match="f:testimony">
<xsl:template match="t:testimony">
<dl class="metadata-container testimony-metadata">
<xsl:apply-templates/>
<dd><a href="#{$id}">zum Entstehungszeugnis im Text <i class="fa fa-right-dir"></i></a></dd>
</dl>
<xsl:if test="descendant::f:field[@name='zuordnung-zu-wanderjahren-trunz-aber-vgl-quz-ii-s-477f-anm-2'][normalize-space(lower-case(.)) = 'x']">
<xsl:if test="descendant::t:field[@name='zuordnung-zu-wanderjahren-trunz-aber-vgl-quz-ii-s-477f-anm-2'][normalize-space(lower-case(.)) = 'x']">
<p>
Dieses Zeugnis ist in der älteren Forschung auf <em>Faust</em> bezogen worden; wahrscheinlich gehört es in einen anderen Zusammenhang.
</p>
</xsl:if>
</xsl:template>

<xsl:template match="f:field[starts-with(@name, 'lfd-nr')][1]" priority="1">
<xsl:template match="t:field[starts-with(@name, 'lfd-nr')][1]" priority="1">
<dt>Zeugnis-Nr.</dt>
<dd><xsl:value-of select="."/></dd>
</xsl:template>

<xsl:template match="f:field[starts-with(@name, 'lfd-nr')]"/>
<xsl:template match="t:field[starts-with(@name, 'lfd-nr')]"/>

<xsl:template match="f:field[@name='datum-von']">
<xsl:template match="t:field[@name='datum-von']">
<dt>Datum</dt>
<dd>
<xsl:choose>
<xsl:when test="../f:field[@name='datum-bis']">zwischen <xsl:value-of select="."/> und <xsl:value-of select="../f:field[@name='datum-bis']"/></xsl:when>
<xsl:when test="../t:field[@name='datum-bis']">zwischen <xsl:value-of select="."/> und <xsl:value-of select="../t:field[@name='datum-bis']"/></xsl:when>
<xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
</xsl:choose>
<xsl:if test="../f:field[@name='intervall-erschlossen']"> (erschlossen)</xsl:if>
<xsl:if test="../t:field[@name='intervall-erschlossen']"> (erschlossen)</xsl:if>
</dd>
</xsl:template>

<xsl:template match="f:field[@name='dokumenttyp']">
<xsl:template match="t:field[@name='dokumenttyp']">
<dt><xsl:value-of select="f:fieldlabel(@name)"/></dt>
<dd><xsl:call-template name="render-dokumenttyp"/></dd>
</xsl:template>

<xsl:template match="f:field[@name='druckort']">
<xsl:template match="t:field[@name='druckort']">
<dt><xsl:value-of select="f:fieldlabel(@name)"/></dt>
<dd>
<xsl:value-of select="."/>
<xsl:if test="../f:field[@name='alternativer-druckort']">; <xsl:value-of select="../f:field[@name='alternativer-druckort']"/></xsl:if>
<xsl:if test="../t:field[@name='alternativer-druckort']">; <xsl:value-of select="../t:field[@name='alternativer-druckort']"/></xsl:if>
</dd>
</xsl:template>

<xsl:template match="f:field[@name='h-sigle']">
<xsl:template match="t:field[@name='h-sigle']">
<dt><xsl:value-of select="f:fieldlabel(@name)"/></dt>
<dd><xsl:sequence select="f:sigil-links(.)"/></dd>
</xsl:template>

<xsl:function name="f:fieldlabel">
<xsl:param name="fieldname"/>
<xsl:variable name="spec" select="$fields//f:fieldspec[@name = $fieldname]"/>
<xsl:variable name="spec" select="$fields//t:fieldspec[@name = $fieldname]"/>
<xsl:value-of select="if (normalize-space($spec)) then $spec else $spec/@spreadsheet"/>
</xsl:function>

<xsl:template match="f:field[f:fieldspec(@name)/@ignore='yes']" priority="0.1"/>
<xsl:template match="t:field[f:fieldspec(@name)/@ignore='yes']" priority="0.1"/>

<xsl:template match="f:field">
<xsl:template match="t:field">
<dt><xsl:value-of select="f:fieldlabel(@name)"/></dt>
<dd><xsl:value-of select="."/></dd>
</xsl:template>

<xsl:template match="f:biburl">
<xsl:template match="t:biburl">
<xsl:variable name="citation" select="f:cite(., false())"/>
<xsl:if test="starts-with($citation, 'faust://')"><xsl:message select="concat('WARNING: Citation ', ., ' missing in testimony ', $id)"/></xsl:if>
<dt>Quelle</dt>
<dd><xsl:sequence select="$citation"/></dd>
</xsl:template>

</xsl:stylesheet>
</xsl:stylesheet>
9 changes: 5 additions & 4 deletions xslt/testimony-common.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
xpath-default-namespace="http://www.tei-c.org/ns/1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://www.faustedition.net/ns"
exclude-result-prefixes="xs"
xmlns:t="http://www.faustedition.net/ns/testimony"
exclude-result-prefixes="xs f t"
version="2.0">

<!--
Expand Down Expand Up @@ -32,7 +33,7 @@
- text content: The label, if present; otherwise @spreadsheet is used
-->
<xsl:variable name="fields" xmlns="http://www.faustedition.net/ns">
<xsl:variable name="fields" xmlns="http://www.faustedition.net/ns/testimony">
<!--These fields have been found in the excel table:-->
<fieldspec name="status" spreadsheet="Status" ignore="yes"/><!-- raus -->
<fieldspec name="lfd-nr-neu-2" spreadsheet="lfd. Nr. (neu-2)">Zeugnis-Nr.</fieldspec>
Expand Down Expand Up @@ -87,7 +88,7 @@

<xsl:function name="f:fieldspec" as="element()?">
<xsl:param name="name"/>
<xsl:sequence select="$fields//f:fieldspec[@name=$name]"/>
<xsl:sequence select="$fields//t:fieldspec[@name=$name]"/>
</xsl:function>

<!-- ### Rendering of the field 'dokumenttyp' -> 'beschreibung'. -->
Expand Down Expand Up @@ -119,7 +120,7 @@
<!-- This is the spec:
If the field has the value from the name attribute, use the corresponding template.
Replace $verfasser with the value of f:field[@name='verfasser'] from the table and so on.
Replace $verfasser with the value of t:field[@name='verfasser'] from the table and so on.
-->
<xsl:variable name="beschreibung" xmlns="http://www.faustedition.net/ns">
<template name="Brief">Brief von $verfasser an $adressat</template>
Expand Down
12 changes: 7 additions & 5 deletions xslt/testimony-split.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
xmlns="http://www.tei-c.org/ns/1.0"
xpath-default-namespace="http://www.tei-c.org/ns/1.0"
xmlns:f="http://www.faustedition.net/ns"
exclude-result-prefixes="xs xi svg math xd f"
xmlns:t="http://www.faustedition.net/ns/testimony"
exclude-result-prefixes="xs xi svg math xd f t"
version="2.0">

<xsl:import href="bibliography.xsl"/>
Expand Down Expand Up @@ -60,7 +61,7 @@
<xsl:variable name="last-milestone" select="$chain[position() = last()]"/>
<xsl:variable name="last-div" select="$last-milestone/ancestor::div[not(ancestor::div)]"/>
<xsl:variable name="context" select="$div, $div/following::node() except ($div/following::*//node(), $last-div/following::node())"/>
<xsl:variable name="metadata0" select="$table//f:testimony[@id=$id]"/>
<xsl:variable name="metadata0" select="$table//t:testimony[@id=$id]"/>
<xsl:variable name="metadata" as="element()?">
<xsl:choose>
<xsl:when test="count($metadata0) > 1">
Expand All @@ -70,7 +71,7 @@
<xsl:when test="$metadata0"><xsl:sequence select="$metadata0"/></xsl:when>
<xsl:otherwise>
<xsl:variable name="id_parts" select="tokenize($id, '_')"/>
<xsl:variable name="matching-md" as="element()*" select="$table//f:testimony[f:field[@name = $id_parts[1] and . = $id_parts[2]]]"/>
<xsl:variable name="matching-md" as="element()*" select="$table//t:testimony[t:field[@name = $id_parts[1] and . = $id_parts[2]]]"/>
<xsl:choose>
<xsl:when test="count($matching-md) = 1">
<xsl:for-each select="$matching-md">
Expand All @@ -91,7 +92,8 @@
then $metadata/@id
else $id"/>

<xsl:result-document href="{resolve-uri(concat($basename, '.xml'), $output)}" exclude-result-prefixes="xs xi svg math xd f">
<xsl:result-document href="{resolve-uri(concat($basename, '.xml'), $output)}" exclude-result-prefixes="xs xi svg math xd f">

<TEI>
<xsl:for-each select="/TEI/teiHeader">
<teiHeader>
Expand All @@ -112,7 +114,7 @@
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:copy-of select="*"/>
<biburl xmlns="http://www.faustedition.net/ns"><xsl:value-of select="$biburl"/></biburl>
<biburl xmlns="http://www.faustedition.net/ns/testimony"><xsl:value-of select="$biburl"/></biburl>
</xsl:copy>
</xsl:for-each>
</xenoData>
Expand Down
2 changes: 1 addition & 1 deletion xslt/testimony-table.rnc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
default namespace = "http://www.faustedition.net/ns"
default namespace = "http://www.faustedition.net/ns/testimony"

start =
element testimonies {
Expand Down
2 changes: 1 addition & 1 deletion xslt/testimony-table.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--This document is sporadically re-generated from an Excel sheet in the wiki. Please don't edit it directly-->
<?xml-model href="testimony-table.rnc" type="application/relax-ng-compact-syntax"?>
<testimonies xmlns="http://www.faustedition.net/ns">
<testimonies xmlns="http://www.faustedition.net/ns/testimony">
<header>
<!--These fields have been found in the excel table:-->
<fieldspec name="status" spreadsheet="Status"/>
Expand Down
Loading

0 comments on commit 90c7c7e

Please sign in to comment.