From e28d5696cacbc91ded9060c3a4cecc235a13c113 Mon Sep 17 00:00:00 2001
From: Max-Ferdinand Zeterberg <zeterberg@sub.uni-goettingen.de>
Date: Wed, 17 Apr 2024 16:59:24 +0200
Subject: [PATCH] feat(g,w,translation): implement @cert in HTML serialization

---
 .../edxml2html/libs/html-facsimile.lib.xsl    | 21 +++--
 .../edxml2html/libs/html-philology.lib.xsl    | 82 +++++++++++--------
 2 files changed, 63 insertions(+), 40 deletions(-)

diff --git a/scenarios/xslt/edxml2html/libs/html-facsimile.lib.xsl b/scenarios/xslt/edxml2html/libs/html-facsimile.lib.xsl
index b0d0981..02c4899 100644
--- a/scenarios/xslt/edxml2html/libs/html-facsimile.lib.xsl
+++ b/scenarios/xslt/edxml2html/libs/html-facsimile.lib.xsl
@@ -118,18 +118,27 @@
     </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:apply-templates/>
-        </span>
+    <xsl:template match="g">
+        <xsl:element name="span">
+            <xsl:attribute name="class">g</xsl:attribute>
+            <xsl:attribute name="id">
+                <xsl:value-of select="if(@xml:id) then (@xml:id) else ('part_'||generate-id(.))"/>
+            </xsl:attribute>
+            <xsl:if test=".[@cert]">
+                <xsl:attribute name="data-cert">
+                    <xsl:value-of select="./@cert"/>
+                </xsl:attribute>
+            </xsl:if>            
+                <xsl:apply-templates/>
+        </xsl:element>
     </xsl:template>
-
+<!--
     <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>
-    </xsl:template>
+    </xsl:template>-->
 
     <xsl:template match="metamark[contains(@rend, 'Line') or contains(@rend, 'line')]">
         <xsl:variable name="rend" select="@rend"/>
diff --git a/scenarios/xslt/edxml2html/libs/html-philology.lib.xsl b/scenarios/xslt/edxml2html/libs/html-philology.lib.xsl
index ec137f7..49b0e32 100644
--- a/scenarios/xslt/edxml2html/libs/html-philology.lib.xsl
+++ b/scenarios/xslt/edxml2html/libs/html-philology.lib.xsl
@@ -1,7 +1,8 @@
 <?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:uuid="java:java.util.UUID"
-    xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="xs" version="2.0"
+    xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tei="http://www.tei-c.org/ns/1.0"
+    xmlns:uuid="java:java.util.UUID" xmlns="http://www.w3.org/1999/xhtml"
+    exclude-result-prefixes="xs" version="2.0"
     xpath-default-namespace="http://sub.uni-goettingen.de/edxml#">
 
     <xsl:template match="@xml:lang">
@@ -121,9 +122,15 @@
 
 
     <xsl:template match="philology//translation">
-        <div class="translation section-tab">
+        <xsl:element name="div">
+            <xsl:attribute name="class">translation section-tab</xsl:attribute>
+            <xsl:if test=".[@cert]">
+                <xsl:attribute name="data-cert">
+                    <xsl:value-of select="./@cert"/>
+                </xsl:attribute>
+            </xsl:if>
             <xsl:apply-templates select="@* | node()"/>
-        </div>
+        </xsl:element>
     </xsl:template>
 
     <xsl:template match="philology//translation" mode="table">
@@ -183,33 +190,41 @@
                     (tokenize(@corresp, ' '))
                 else
                     (false())"/>
-        <span class="w item" tabindex="1" id="{$id}">
-            <span class="body">
-                <xsl:apply-templates/>
-            </span>
-            <span class="annotation">
-                <span class="ana">
-                    <xsl:choose>
-                        <xsl:when test="@ana">
-                            <xsl:value-of select="@ana"/>
-                        </xsl:when>
-                        <xsl:otherwise>
-                            <xsl:text> </xsl:text>
-                        </xsl:otherwise>
-                    </xsl:choose>
+        <xsl:element name="span">
+            <xsl:attribute name="class">w item</xsl:attribute>
+            <xsl:attribute name="tabindex">1</xsl:attribute>
+            <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
+            <xsl:if test=".[@cert]">
+                <xsl:attribute name="data-cert">
+                    <xsl:value-of select="./@cert"/>
+                </xsl:attribute>
+            </xsl:if>
+                <span class="body">
+                    <xsl:apply-templates/>
                 </span>
-                <span class="lemma">
-                    <xsl:choose>
-                        <xsl:when test="@lemma">
-                            <xsl:value-of select="@lemma"/>
-                        </xsl:when>
-                        <xsl:otherwise>
-                            <xsl:text> </xsl:text>
-                        </xsl:otherwise>
-                    </xsl:choose>
+                <span class="annotation">
+                    <span class="ana">
+                        <xsl:choose>
+                            <xsl:when test="@ana">
+                                <xsl:value-of select="@ana"/>
+                            </xsl:when>
+                            <xsl:otherwise>
+                                <xsl:text> </xsl:text>
+                            </xsl:otherwise>
+                        </xsl:choose>
+                    </span>
+                    <span class="lemma">
+                        <xsl:choose>
+                            <xsl:when test="@lemma">
+                                <xsl:value-of select="@lemma"/>
+                            </xsl:when>
+                            <xsl:otherwise>
+                                <xsl:text> </xsl:text>
+                            </xsl:otherwise>
+                        </xsl:choose>
+                    </span>
                 </span>
-            </span>
-        </span>
+        </xsl:element>
     </xsl:template>
 
     <xsl:template match="philology//notes">
@@ -224,14 +239,13 @@
                     <label for="{$noteListId}">
                         <xsl:variable name="targetIds" select="tokenize($targetUnique, ' ')"/>
                         <xsl:for-each select="$targetIds">
-                            <xsl:variable name="targetId" select="substring(., 2)"/>                            
-                            <xsl:apply-templates select="root($thisNotes)//*[@xml:id = $targetId]"/>                            
+                            <xsl:variable name="targetId" select="substring(., 2)"/>
+                            <xsl:apply-templates select="root($thisNotes)//*[@xml:id = $targetId]"/>
                         </xsl:for-each>
                     </label>
                     <input id="{$noteListId}" type="checkbox"/>
                     <ul>
-                        <xsl:apply-templates
-                            select="$thisNotes//note[@target = $targetUnique]"/>
+                        <xsl:apply-templates select="$thisNotes//note[@target = $targetUnique]"/>
                     </ul>
                 </li>
             </xsl:for-each>
@@ -248,7 +262,7 @@
             <span>
                 <xsl:apply-templates/>
             </span>
-            
+
         </li>
     </xsl:template>
 
-- 
GitLab