diff --git a/scenarios/xslt/edxml2html/libs/html-philology.lib.xsl b/scenarios/xslt/edxml2html/libs/html-philology.lib.xsl index 87be5edea7fbe67a36a9ee49b58a0d5e653de3ba..ec137f785f6b05e49ab3c5ec2d0d42369fab35d0 100644 --- a/scenarios/xslt/edxml2html/libs/html-philology.lib.xsl +++ b/scenarios/xslt/edxml2html/libs/html-philology.lib.xsl @@ -1,155 +1,188 @@ <?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: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"> - <xsl:attribute name="data-lang"><xsl:value-of select="data(.)"/></xsl:attribute> + <xsl:attribute name="data-lang"> + <xsl:value-of select="data(.)"/> + </xsl:attribute> </xsl:template> - + <xsl:template match="@n"> - <xsl:attribute name="data-n"><xsl:value-of select="data(.)"/></xsl:attribute> + <xsl:attribute name="data-n"> + <xsl:value-of select="data(.)"/> + </xsl:attribute> <!--<xsl:attribute name="data-roman-n"><xsl:number value="data(.)" format="I"/></xsl:attribute>--> </xsl:template> - + <xsl:template match="philology"> - <div class="philology section" + <div class="philology section" id="{if(@xml:id) then (@xml:id) else ('facs_'||generate-id(.))}"> - <xsl:apply-templates /> + <xsl:apply-templates/> </div> </xsl:template> - + <xsl:template match="philology/units"> <div class="units"> - <xsl:apply-templates /> + <xsl:apply-templates/> <!--<table> <xsl:apply-templates mode="table"/> </table>--> </div> </xsl:template> - + <xsl:template match="philology//unit"> - <xsl:variable name="id" select="if(@xml:id) then (@xml:id) else ('facs_'||generate-id(.))"/> - <xsl:variable name="corresp" select="if(@corresp) then (tokenize(@corresp, ' ')) else (false())"/> + <xsl:variable name="id" select=" + if (@xml:id) then + (@xml:id) + else + ('facs_' || generate-id(.))"/> + <xsl:variable name="corresp" select=" + if (@corresp) then + (tokenize(@corresp, ' ')) + else + (false())"/> <div class="unit" id="{$id}" data-corresp="{$corresp}"> <div class="unit-container"> - <!--<div class="anchor-container"> - <a class="anchor" href="#{$id}"> - <span class="unit-label">Kolon</span> - <span class="unit-nr"> - <xsl:apply-templates select="@n"/> - <xsl:attribute name="data-count-preceding"><xsl:value-of select="count(preceding::unit)+1"/></xsl:attribute> - <xsl:attribute name="data-count-preceding-sibling"><xsl:value-of select="count(preceding-sibling::unit)+1"/></xsl:attribute> - </span> - <span class="unit-count"> - <xsl:value-of select="count(preceding::unit)+1"/> - </span> - </a> - </div>--> - <xsl:apply-templates /> - <xsl:if test="not(child::notes)"> - <div class="notes section-tab"/> - </xsl:if> + <xsl:apply-templates select="*[not(self::notes)]"/> + <div class="notes section-tab"> + <xsl:if test="child::notes"> + <xsl:variable name="noteIconId" select="uuid:randomUUID()"/> + <label for="{$noteIconId}" class="notes-icon"/> + <input type="checkbox" id="{$noteIconId}"/> + </xsl:if> + </div> + </div> + <div class="notes-container"> + <xsl:apply-templates select="notes"/> </div> </div> </xsl:template> - + <xsl:template match="philology//unit" mode="table"> - <xsl:variable name="id" select="if(@xml:id) then (@xml:id) else ('facs_'||generate-id(.))"/> - <xsl:variable name="corresp" select="if(@corresp) then (tokenize(@corresp, ' ')) else (false())"/> + <xsl:variable name="id" select=" + if (@xml:id) then + (@xml:id) + else + ('facs_' || generate-id(.))"/> + <xsl:variable name="corresp" select=" + if (@corresp) then + (tokenize(@corresp, ' ')) + else + (false())"/> <tr class="unit" id="{$id}" data-corresp="{$corresp}"> <td class="head hide"> <a class="anchor" href="#{$id}"> <span class="unit-label">Kolon</span> - <span class="unit-nr"><xsl:apply-templates select="@n"/></span> + <span class="unit-nr"> + <xsl:apply-templates select="@n"/> + </span> </a> </td> <xsl:apply-templates mode="table" select="transcription"/> <xsl:apply-templates mode="table" select="translation"/> </tr> </xsl:template> - - - - + + + + <xsl:template match="philology//transcription"> <div class="transcription section-tab"> - <xsl:apply-templates select="@*|node()"/> + <xsl:apply-templates select="@* | node()"/> </div> </xsl:template> - + <xsl:template match="transcription/@type"> - <xsl:attribute name="data-type"><xsl:value-of select="data(.)"/></xsl:attribute> + <xsl:attribute name="data-type"> + <xsl:value-of select="data(.)"/> + </xsl:attribute> </xsl:template> - + <xsl:template match="philology//transcription" mode="table"> <td class="transcription section-tab"> <xsl:apply-templates select="@*"/> <table> <tr> - <xsl:for-each select="node()[not(normalize-space(.)='')]"> - <xsl:apply-templates select="." mode="table-items"/> - </xsl:for-each> + <xsl:for-each select="node()[not(normalize-space(.) = '')]"> + <xsl:apply-templates select="." mode="table-items"/> + </xsl:for-each> </tr> </table> </td> </xsl:template> - - - - - - - + + + + + + + <xsl:template match="philology//translation"> <div class="translation section-tab"> - <xsl:apply-templates select="@*|node()"/> + <xsl:apply-templates select="@* | node()"/> </div> </xsl:template> - + <xsl:template match="philology//translation" mode="table"> <td class="translation section-tab"> - <xsl:apply-templates select="@*|node()"/> + <xsl:apply-templates select="@* | node()"/> </td> </xsl:template> - - <xsl:template match="translation/element()|transcription/element()"> + + <xsl:template match="translation/element() | transcription/element()"> <span class="{local-name()} item"> <span class="conti"> <xsl:apply-templates/> </span> </span> </xsl:template> - - <xsl:template match="translation/text()[not(normalize-space(.)='')]|transcription/text()[not(normalize-space(.)='')]"> + + <xsl:template + match="translation/text()[not(normalize-space(.) = '')] | transcription/text()[not(normalize-space(.) = '')]"> <span class="text item"> <xsl:value-of select="."/> </span> </xsl:template> - - + + <xsl:template match="philology//lb[@n]"> <span class="lb item"> <xsl:value-of select="data(@n)"/> </span> </xsl:template> - - + + <xsl:template match="philology//phr"> - <xsl:variable name="id" select="if(@xml:id) then (@xml:id) else ('facs_'||generate-id(.))"/> - <xsl:variable name="corresp" select="if(@corresp) then (tokenize(@corresp, ' ')) else (false())"/> + <xsl:variable name="id" select=" + if (@xml:id) then + (@xml:id) + else + ('facs_' || generate-id(.))"/> + <xsl:variable name="corresp" select=" + if (@corresp) then + (tokenize(@corresp, ' ')) + else + (false())"/> <span class="phr" id="{$id}"> <xsl:apply-templates/> </span> </xsl:template> - - + + <xsl:template match="philology//w"> - <xsl:variable name="id" select="if(@xml:id) then (@xml:id) else ('facs_'||generate-id(.))"/> - <xsl:variable name="corresp" select="if(@corresp) then (tokenize(@corresp, ' ')) else (false())"/> + <xsl:variable name="id" select=" + if (@xml:id) then + (@xml:id) + else + ('facs_' || generate-id(.))"/> + <xsl:variable name="corresp" select=" + if (@corresp) then + (tokenize(@corresp, ' ')) + else + (false())"/> <span class="w item" tabindex="1" id="{$id}"> <span class="body"> <xsl:apply-templates/> @@ -160,7 +193,9 @@ <xsl:when test="@ana"> <xsl:value-of select="@ana"/> </xsl:when> - <xsl:otherwise><xsl:text> </xsl:text></xsl:otherwise> + <xsl:otherwise> + <xsl:text> </xsl:text> + </xsl:otherwise> </xsl:choose> </span> <span class="lemma"> @@ -168,44 +203,80 @@ <xsl:when test="@lemma"> <xsl:value-of select="@lemma"/> </xsl:when> - <xsl:otherwise><xsl:text> </xsl:text></xsl:otherwise> + <xsl:otherwise> + <xsl:text> </xsl:text> + </xsl:otherwise> </xsl:choose> </span> </span> </span> </xsl:template> - + <xsl:template match="philology//notes"> - <div class="notes section-tab"> - <xsl:apply-templates/> - </div> + <xsl:variable name="targets" select="note/@target"/> + <xsl:variable name="targetsUnique" select="distinct-values($targets)"/> + <xsl:variable name="thisNotes" select="."/> + <ul> + <xsl:for-each select="$targetsUnique"> + <li class="note-list"> + <xsl:variable name="targetUnique" select="."/> + <xsl:variable name="noteListId" select="uuid:randomUUID()"/> + <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:for-each> + </label> + <input id="{$noteListId}" type="checkbox"/> + <ul> + <xsl:apply-templates + select="$thisNotes//note[@target = $targetUnique]"/> + </ul> + </li> + </xsl:for-each> + </ul> </xsl:template> - + <xsl:template match="philology//note"> - <span class="note">📌 - <span class="notetext"> + <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> - </span> + + </li> </xsl:template> - - + + <!-- TABLE ITEMS --> <xsl:template match="node()" mode="table-items"> <td class="{local-name()}"> <xsl:apply-templates/> </td> </xsl:template> - + <xsl:template match="philology//lb" mode="table-items"> <td class="lb"> <xsl:apply-templates select="@*"/> </td> </xsl:template> - + <xsl:template match="philology//phr" mode="table-items"> - <xsl:variable name="id" select="if(@xml:id) then (@xml:id) else ('facs_'||generate-id(.))"/> - <xsl:variable name="corresp" select="if(@corresp) then (tokenize(@corresp, ' ')) else (false())"/> + <xsl:variable name="id" select=" + if (@xml:id) then + (@xml:id) + else + ('facs_' || generate-id(.))"/> + <xsl:variable name="corresp" select=" + if (@corresp) then + (tokenize(@corresp, ' ')) + else + (false())"/> <td class="phr" id="{$id}"> <table> <tr> @@ -214,17 +285,27 @@ </table> </td> </xsl:template> - + <xsl:template match="philology//w" mode="table-items"> - <xsl:variable name="id" select="if(@xml:id) then (@xml:id) else ('facs_'||generate-id(.))"/> - <xsl:variable name="corresp" select="if(@corresp) then (tokenize(@corresp, ' ')) else (false())"/> + <xsl:variable name="id" select=" + if (@xml:id) then + (@xml:id) + else + ('facs_' || generate-id(.))"/> + <xsl:variable name="corresp" select=" + if (@corresp) then + (tokenize(@corresp, ' ')) + else + (false())"/> <td class="w item" tabindex="1" id="{$id}"> <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:otherwise> + <xsl:text> </xsl:text> + </xsl:otherwise> </xsl:choose> </span> <span class="lemma"> @@ -232,7 +313,9 @@ <xsl:when test="@lemma"> <xsl:value-of select="@lemma"/> </xsl:when> - <xsl:otherwise><xsl:text> </xsl:text></xsl:otherwise> + <xsl:otherwise> + <xsl:text> </xsl:text> + </xsl:otherwise> </xsl:choose> </span> <span class="value"> @@ -240,7 +323,7 @@ </span> </td> </xsl:template> - - - -</xsl:stylesheet> \ No newline at end of file + + + +</xsl:stylesheet>