Skip to content

Commit

Permalink
refactor: render insertion mark and info correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
babslgam committed Sep 16, 2024
1 parent c74b4f9 commit 467c882
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 6 deletions.
38 changes: 32 additions & 6 deletions xslt/editions.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,21 @@
</xsl:variable>
<xsl:for-each select="$regrefs//@target">
<xsl:variable name="target" select="current()"/>
<xsl:apply-templates select="doc('../data/editions/Gesamt.xml')//*[@xml:id=$target]" mode="short_info"/>
<xsl:choose>
<xsl:when test="starts-with($target,'insertionstart')">
<xsl:apply-templates select="doc('../data/editions/Gesamt.xml')//*[@target=replace($target,'insertionstart_','#')]" mode="short_info">
<xsl:with-param name="reftype" select="'insertionstart'"/>
</xsl:apply-templates>
</xsl:when>
<xsl:when test="starts-with($target,'insertionend')">
<xsl:apply-templates select="doc('../data/editions/Gesamt.xml')//*[@target=replace($target,'insertionend_','#')]" mode="short_info">
<xsl:with-param name="reftype" select="'insertionend'"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="doc('../data/editions/Gesamt.xml')//*[@xml:id=$target]" mode="short_info"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</div>
</wpn-text-view>
Expand Down Expand Up @@ -111,8 +125,9 @@
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="tei:pb">
<span class="pagebreaks entity" id="{'pb'||@n}" style="display:none;">||</span>
<xsl:template match="tei:pb[matches(@n,'.*_[a-z].*')]"/>
<xsl:template match="tei:pb[not(matches(@n,'.*_[a-z].*'))]">
<span class="pagebreaks entity" id="{'pb'||@n}">||</span>
</xsl:template>
<xsl:template match="tei:pb" mode="raw">
<ref target="{@xml:id}">
Expand Down Expand Up @@ -264,9 +279,20 @@
</xsl:template>
<xsl:template match="tei:metamark[@function=('insertion') and matches(@target,'(note)+.*([a-z])_')]">
<xsl:variable name="target" select="replace(@target,'#','')"/>
<wpn-entity>
<xsl:apply-templates select="doc('../data/editions/Gesamt.xml')//tei:note[@xml:id=$target]" mode="render"/>
</wpn-entity>
<span>
<span class="pagebreaks entity" id="{'insertionstart_'||$target}">||</span>
<xsl:apply-templates select="doc('../data/editions/Gesamt.xml')//tei:note[@xml:id=$target]" mode="render"/>
<span class="pagebreaks entity" id="{'insertionend_'||$target}">||</span>
</span>
</xsl:template>
<xsl:template match="tei:metamark[@function=('insertion') and matches(@target,'(note)+.*([a-z])_')]" mode="raw">
<xsl:variable name="target" select="replace(@target,'#','')"/>
<ref target="{'insertionstart_'||replace(@target,'#','')}">
<xsl:apply-templates select="doc('../data/editions/Gesamt.xml')//tei:note[@xml:id=$target]" mode="raw"/>
<xsl:if test="@n='last'">
<ref target="{'insertionend_'||replace(@target,'#','')}"></ref>
</xsl:if>
</ref>
</xsl:template>
<xsl:template match="tei:metamark[@function=('printInstruction','undefined','progress')]"/>
<xsl:template match="tei:mod[@style=('noLetterSpacing') and not(parent::tei:restore)]">
Expand Down
27 changes: 27 additions & 0 deletions xslt/partials/short-infos.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,33 @@
<span><xsl:value-of select="'Beginn Seite '||(if (@n castable as xs:integer) then number(@n) else replace(@n,'[_]',' '))"/></span>
</div>
</xsl:template>
<xsl:template match="tei:metamark[@function='insertion' and matches(@target,'(note)+.*([a-z])_')]" mode="short_info">
<xsl:param name="reftype"/>
<xsl:variable name="description">
<xsl:choose>
<xsl:when test="$reftype='insertionstart'">
<xsl:text>Beginn des Einschubs von Seite</xsl:text>
</xsl:when>
<xsl:when test="$reftype='insertionend'">
<xsl:text>Fortsetzung Seite</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="target" select="@target"/>
<xsl:variable name="preceding_pb_val">
<xsl:choose>
<xsl:when test="$reftype='insertionstart'">
<xsl:value-of select="doc('../../data/editions/Gesamt.xml')//tei:note[@xml:id=replace($target,'#','')]/preceding::tei:pb[1]/replace(replace(@n,'_',' '),'^0+','')"/>
</xsl:when>
<xsl:when test="$reftype='insertionend'">
<xsl:value-of select="doc('../../data/editions/Gesamt.xml')//tei:metamark[@target=$target]/preceding::tei:pb[1]/replace(replace(@n,'_',' '),'^0+','')"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<div class="fs-6 ps-3 text-dark-grey pagebreaks" data-xmlid="{$reftype||'_'||replace($target,'#','')}" style="display:none">
<span><xsl:value-of select="$description||' '||$preceding_pb_val"/></span>
</div>
</xsl:template>
<xsl:template match="tei:app" mode="short_info">
<xsl:variable name="xmlid" select="@xml:id"/>
<div class="fs-6 ps-3 text-dark-grey d-none" data-xmlid="{$xmlid}" data-entity-type="fkl">
Expand Down

0 comments on commit 467c882

Please sign in to comment.