Skip to content
Snippets Groups Projects
Commit 736e1c08 authored by zeterberg's avatar zeterberg
Browse files

feat(commentaries): add new structure for commentaries

parent 2bb30f13
No related branches found
No related tags found
1 merge request!26Resolve "Move comments below unit lines"
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns:functx="http://www.functx.com" xmlns="http://www.w3.org/1999/xhtml"
xmlns="http://www.w3.org/1999/xhtml" xmlns:uuid="java:java.util.UUID" exclude-result-prefixes="xs" version="2.0"
exclude-result-prefixes="xs" xpath-default-namespace="http://sub.uni-goettingen.de/edxml#">
version="2.0" xpath-default-namespace="http://sub.uni-goettingen.de/edxml#">
<xsl:function name="functx:substring-before-if-contains" as="xs:string?">
<xsl:param name="arg" as="xs:string?"/>
<xsl:param name="delim" as="xs:string"/>
<xsl:sequence select="
if (contains($arg, $delim))
then
substring-before($arg, $delim)
else
$arg
"/>
</xsl:function>
<xsl:template match="facsimile"> <xsl:template match="facsimile">
<div class="facsimile section" <div class="facsimile section"
id="{if(@xml:id) then (@xml:id) else ('facs_'||generate-id(.))}"> id="{if(@xml:id) then (@xml:id) else ('facs_'||generate-id(.))}">
<xsl:apply-templates /> <xsl:apply-templates/>
</div> </div>
</xsl:template> </xsl:template>
<xsl:template match="surface"> <xsl:template match="surface">
<div class="surface" <div class="surface" id="{if(@xml:id) then (@xml:id) else ('surf_'||generate-id(.))}">
id="{if(@xml:id) then (@xml:id) else ('surf_'||generate-id(.))}"> <xsl:apply-templates/>
<xsl:apply-templates />
</div> </div>
</xsl:template> </xsl:template>
<xsl:template match="column"> <xsl:template match="column">
<xsl:variable name="nr" select="if(@n) then(@n) else(count(preceding::column)+1)"/> <xsl:variable name="nr" select="
<xsl:variable name="id" select="if(@xml:id) then (@xml:id) else ('colu_'||generate-id(.))"/> if (@n) then
<div class="column" (@n)
id="{$id}" else
data-n="{$nr}"> (count(preceding::column) + 1)"/>
<xsl:apply-templates /> <xsl:variable name="id" select="
if (@xml:id) then
(@xml:id)
else
('colu_' || generate-id(.))"/>
<div class="column" id="{$id}" data-n="{$nr}">
<xsl:apply-templates/>
</div> </div>
</xsl:template> </xsl:template>
<xsl:template match="line[not(@n)]|surface//note"> <!--<xsl:template match="line[not(@n)] | surface//note">
<div class="note" <div class="note" id="{if(@xml:id) then (@xml:id) else ('line_'||generate-id(.))}">
id="{if(@xml:id) then (@xml:id) else ('line_'||generate-id(.))}"> <xsl:apply-templates/>
<xsl:apply-templates />
</div> </div>
</xsl:template> </xsl:template>-->
<xsl:template match="line[@n]"> <xsl:template match="line[@n]">
<xsl:variable name="nr" select="@n"/> <xsl:variable name="nr" select="@n"/>
<xsl:variable name="auto-nr" select="if($nr) then($nr) else(count(preceding::line)+1)"/> <xsl:variable name="auto-nr" select="
<xsl:variable name="id" select="if(@xml:id) then (@xml:id) else ('line_'||generate-id(.))"/> if ($nr) then
<div class="line" ($nr)
id="{$id}"> else
<a href="#{$id}" class="line-anchor"> (count(preceding::line) + 1)"/>
<span> <xsl:variable name="id" select="
<xsl:choose> if (@xml:id) then
<xsl:when test="@n"> (@xml:id)
<xsl:attribute name="class">line-nr explicit</xsl:attribute> else
</xsl:when> ('line_' || generate-id(.))"/>
<xsl:otherwise> <xsl:variable name="targetIds" select=".//@xml:id"/>
<xsl:attribute name="class">line-nr calculated</xsl:attribute> <xsl:variable name="allFollowingNotes"
</xsl:otherwise> select="./ancestor::surface/following-sibling::notes/note"/>
</xsl:choose>
<xsl:value-of select="$auto-nr"/> <xsl:variable name="correspondingNotes">
<xsl:for-each select="$allFollowingNotes">
<xsl:if
test="substring-after(functx:substring-before-if-contains(@target, ' '), '#') = $targetIds">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<div class="line-container">
<div class="line" id="{$id}">
<a href="#{$id}" class="line-anchor">
<span>
<xsl:choose>
<xsl:when test="@n">
<xsl:attribute name="class">line-nr explicit</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class">line-nr calculated</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="$auto-nr"/>
</span>
</a>
<span class="line-body">
<xsl:apply-templates/>
</span> </span>
</a> <xsl:if test="$correspondingNotes != ''">
<span class="line-body"> <span>
<xsl:apply-templates /> <xsl:variable name="noteIconId" select="uuid:randomUUID()"/>
</span> <label for="{$noteIconId}" class="notes-icon"/>
<input type="checkbox" id="{$noteIconId}"/>
</span>
</xsl:if>
</div>
<xsl:if test="$correspondingNotes != ''">
<div class="note-container">
<ul>
<xsl:for-each select="$correspondingNotes">
<xsl:apply-templates/>
</xsl:for-each>
</ul>
</div>
</xsl:if>
</div> </div>
</xsl:template> </xsl:template>
<!-- LINE-PARTS --> <!-- LINE-PARTS -->
<xsl:template match="g[not(@cert)]"> <xsl:template match="g[not(@cert)]">
<span class="g" <span class="g" id="{if(@xml:id) then (@xml:id) else ('part_'||generate-id(.))}">
id="{if(@xml:id) then (@xml:id) else ('part_'||generate-id(.))}">
<xsl:apply-templates/> <xsl:apply-templates/>
</span> </span>
</xsl:template> </xsl:template>
<xsl:template match="g[@cert]"> <xsl:template match="g[@cert]">
<span class="g" <span class="g" data-cert="{@cert}"
data-cert="{@cert}"
id="{if(@xml:id) then (@xml:id) else ('part_'||generate-id(.))}"> id="{if(@xml:id) then (@xml:id) else ('part_'||generate-id(.))}">
<xsl:apply-templates/> <xsl:apply-templates/>
</span> </span>
</xsl:template> </xsl:template>
<xsl:template match="metamark[contains(@rend, 'Line') or contains(@rend, 'line')]"> <xsl:template match="metamark[contains(@rend, 'Line') or contains(@rend, 'line')]">
<xsl:variable name="rend" select="@rend"/> <xsl:variable name="rend" select="@rend"/>
<hr class="metamark-line {$rend}" data-rend="{$rend}"/> <hr class="metamark-line {$rend}" data-rend="{$rend}"/>
</xsl:template> </xsl:template>
<xsl:template match="line//part"> <xsl:template match="line//part">
<span class="part" <span class="part" id="{if(@xml:id) then (@xml:id) else ('part_'||generate-id(.))}">
id="{if(@xml:id) then (@xml:id) else ('part_'||generate-id(.))}"> <xsl:apply-templates/>
<xsl:apply-templates />
</span> </span>
</xsl:template> </xsl:template>
<xsl:template match="line//seg"> <xsl:template match="line//seg">
<span class="seg" <span class="seg" id="{if(@xml:id) then (@xml:id) else ('part_'||generate-id(.))}">
id="{if(@xml:id) then (@xml:id) else ('part_'||generate-id(.))}"> <xsl:apply-templates/>
<xsl:apply-templates />
</span> </span>
</xsl:template> </xsl:template>
</xsl:stylesheet> <!-- notes -->
\ No newline at end of file
<xsl:template match="facsimile/notes"/>
<xsl:template match="note">
<li class="note-item">
<xsl:variable name="noteItemId" select="uuid:randomUUID()"/>
<label for="{$noteItemId}">
<xsl:value-of select="@type"/>
</label>
<input id="{$noteItemId}" type="checkbox"/>
<span>
<xsl:apply-templates/>
</span>
</li>
</xsl:template>
</xsl:stylesheet>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment