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"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="xs"
version="2.0" xpath-default-namespace="http://sub.uni-goettingen.de/edxml#">
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns:functx="http://www.functx.com" xmlns="http://www.w3.org/1999/xhtml"
xmlns:uuid="java:java.util.UUID" exclude-result-prefixes="xs" 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">
<div class="facsimile section"
<div class="facsimile section"
id="{if(@xml:id) then (@xml:id) else ('facs_'||generate-id(.))}">
<xsl:apply-templates />
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="surface">
<div class="surface"
id="{if(@xml:id) then (@xml:id) else ('surf_'||generate-id(.))}">
<xsl:apply-templates />
<div class="surface" id="{if(@xml:id) then (@xml:id) else ('surf_'||generate-id(.))}">
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="column">
<xsl:variable name="nr" select="if(@n) then(@n) else(count(preceding::column)+1)"/>
<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 />
<xsl:variable name="nr" select="
if (@n) then
(@n)
else
(count(preceding::column) + 1)"/>
<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>
</xsl:template>
<xsl:template match="line[not(@n)]|surface//note">
<div class="note"
id="{if(@xml:id) then (@xml:id) else ('line_'||generate-id(.))}">
<xsl:apply-templates />
<!--<xsl:template match="line[not(@n)] | surface//note">
<div class="note" id="{if(@xml:id) then (@xml:id) else ('line_'||generate-id(.))}">
<xsl:apply-templates/>
</div>
</xsl:template>
</xsl:template>-->
<xsl:template match="line[@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="id" select="if(@xml:id) then (@xml:id) else ('line_'||generate-id(.))"/>
<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"/>
<xsl:variable name="auto-nr" select="
if ($nr) then
($nr)
else
(count(preceding::line) + 1)"/>
<xsl:variable name="id" select="
if (@xml:id) then
(@xml:id)
else
('line_' || generate-id(.))"/>
<xsl:variable name="targetIds" select=".//@xml:id"/>
<xsl:variable name="allFollowingNotes"
select="./ancestor::surface/following-sibling::notes/note"/>
<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>
</a>
<span class="line-body">
<xsl:apply-templates />
</span>
<xsl:if test="$correspondingNotes != ''">
<span>
<xsl:variable name="noteIconId" select="uuid:randomUUID()"/>
<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>
</xsl:template>
<!-- LINE-PARTS -->
<xsl:template match="g[not(@cert)]">
<span class="g"
id="{if(@xml:id) then (@xml:id) else ('part_'||generate-id(.))}">
<xsl:template match="g[not(@cert)]">
<span class="g" id="{if(@xml:id) then (@xml:id) else ('part_'||generate-id(.))}">
<xsl:apply-templates/>
</span>
</span>
</xsl:template>
<xsl:template match="g[@cert]">
<span class="g"
data-cert="{@cert}"
<xsl:template match="g[@cert]">
<span class="g" data-cert="{@cert}"
id="{if(@xml:id) then (@xml:id) else ('part_'||generate-id(.))}">
<xsl:apply-templates/>
</span>
</span>
</xsl:template>
<xsl:template match="metamark[contains(@rend, 'Line') or contains(@rend, 'line')]">
<xsl:variable name="rend" select="@rend"/>
<hr class="metamark-line {$rend}" data-rend="{$rend}"/>
</xsl:template>
<xsl:template match="line//part">
<span class="part"
id="{if(@xml:id) then (@xml:id) else ('part_'||generate-id(.))}">
<xsl:apply-templates />
<span class="part" id="{if(@xml:id) then (@xml:id) else ('part_'||generate-id(.))}">
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template match="line//seg">
<span class="seg"
id="{if(@xml:id) then (@xml:id) else ('part_'||generate-id(.))}">
<xsl:apply-templates />
<span class="seg" id="{if(@xml:id) then (@xml:id) else ('part_'||generate-id(.))}">
<xsl:apply-templates/>
</span>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
<!-- notes -->
<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