Skip to content

Commit

Permalink
combining of entities also or *Name
Browse files Browse the repository at this point in the history
Cf. #24
  • Loading branch information
dariok committed Jun 4, 2023
1 parent 07f411c commit 7ea386e
Show file tree
Hide file tree
Showing 3 changed files with 229 additions and 24 deletions.
20 changes: 11 additions & 9 deletions combine-continued.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
<xd:doc>
<xd:desc>Combine continued rs</xd:desc>
</xd:doc>
<xsl:template match="tei:*[tei:rs[@continued]]" mode="continued">
<xsl:template match="tei:*[tei:*[@continued = 'true']]" mode="continued">
<xsl:copy>
<xsl:apply-templates select="@*" mode="continued" />
<xsl:for-each-group select="node()" group-starting-with="tei:rs[@continued eq 'true'
and preceding::text()[1]/normalize-space() != '']">
<xsl:for-each-group select="node()"
group-starting-with="tei:*[@continued eq 'true' and normalize-space(preceding::text()[1]) != '']">
<xsl:choose>
<xsl:when test="current-group()[1][@continued eq 'true']">
<xsl:variable name="final"
select="(current-group()[1]/following-sibling::tei:rs[@continued][last()], current-group()[1]/following-sibling::tei:rs[1])[1]" />
<xsl:variable name="last" select="index-of(current-group(), $final)"/>
<rs>
select="(current-group()[position() gt 1 and @continued = 'true'][last()], current-group()[4])[1]" />
<xsl:variable name="last" select="index-of(current-group(), $final)[1]"/>
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@*" mode="continued" />
<xsl:apply-templates select="current-group()[position() le $last]" mode="rs-continued" />
</rs>
</xsl:element>
<xsl:apply-templates select="current-group()[position() gt $last]" mode="continued" />
</xsl:when>
<xsl:otherwise>
Expand All @@ -46,13 +46,15 @@
<xd:desc>lb will be returned unaltered</xd:desc>
</xd:doc>
<xsl:template match="tei:lb" mode="rs-continued">
<xsl:sequence select="." />
<lb break="no">
<xsl:sequence select="@*" />
</lb>
</xsl:template>

<xd:doc>
<xd:desc>For continued rs, only return the content</xd:desc>
</xd:doc>
<xsl:template match="tei:rs[@continued]" mode="rs-continued">
<xsl:template match="*" mode="rs-continued">
<xsl:apply-templates select="node()" mode="continued" />
</xsl:template>

Expand Down
60 changes: 56 additions & 4 deletions test/combine-continued-result.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Test Report for /home/kampkaspar/git/page2tei/combine-continued.xsl (passed: 2 / pending: 0 / failed: 0 / total: 2)</title>
<title>Test Report for /home/kampkaspar/git/page2tei/combine-continued.xsl (passed: 4 / pending: 0 / failed: 0 / total: 4)</title>
<style type="text/css">/****************************************************************************/
/* File: test-report.css */
/* Author: Jeni Tennison */
Expand Down Expand Up @@ -592,7 +592,7 @@
<h1>Test Report</h1>
<p>Stylesheet: <a href="file:/home/kampkaspar/git/page2tei/combine-continued.xsl">/home/kampkaspar/git/page2tei/combine-continued.xsl</a></p>
<p>XSpec: <a href="file:/home/kampkaspar/git/page2tei/test/combine-continued.xspec">/home/kampkaspar/git/page2tei/test/combine-continued.xspec</a></p>
<p>Tested: 4 June 2023 at 16:15</p>
<p>Tested: 4 June 2023 at 21:20</p>
<h2>Contents</h2>
<table class="xspec">
<colgroup>
Expand All @@ -605,10 +605,10 @@ <h2>Contents</h2>
<thead>
<tr>
<th></th>
<th class="totals">passed: 2</th>
<th class="totals">passed: 4</th>
<th class="totals">pending: 0</th>
<th class="totals">failed: 0</th>
<th class="totals">total: 2</th>
<th class="totals">total: 4</th>
</tr>
</thead>
<tbody>
Expand All @@ -626,6 +626,20 @@ <h2>Contents</h2>
<th class="totals">0</th>
<th class="totals">1</th>
</tr>
<tr class="successful">
<th><a href="#top_scenario3">T3: rs</a></th>
<th class="totals">1</th>
<th class="totals">0</th>
<th class="totals">0</th>
<th class="totals">1</th>
</tr>
<tr class="successful">
<th><a href="#top_scenario4">T4: *Name</a></th>
<th class="totals">1</th>
<th class="totals">0</th>
<th class="totals">0</th>
<th class="totals">1</th>
</tr>
</tbody>
</table>
<div id="top_scenario1">
Expand Down Expand Up @@ -666,5 +680,43 @@ <h2 class="successful">T2<span class="scenario-totals">passed: 1 / pending: 0 /
</tbody>
</table>
</div>
<div id="top_scenario3">
<h2 class="successful">T3: rs<span class="scenario-totals">passed: 1 / pending: 0 / failed: 0 / total: 1</span></h2>
<table class="xspec" id="table_scenario3">
<colgroup>
<col style="width:75%" />
<col style="width:25%" />
</colgroup>
<tbody>
<tr class="successful">
<th>T3: rs</th>
<th>passed: 1 / pending: 0 / failed: 0 / total: 1</th>
</tr>
<tr class="successful">
<td>continued rs</td>
<td>Success</td>
</tr>
</tbody>
</table>
</div>
<div id="top_scenario4">
<h2 class="successful">T4: *Name<span class="scenario-totals">passed: 1 / pending: 0 / failed: 0 / total: 1</span></h2>
<table class="xspec" id="table_scenario4">
<colgroup>
<col style="width:75%" />
<col style="width:25%" />
</colgroup>
<tbody>
<tr class="successful">
<th>T4: *Name</th>
<th>passed: 1 / pending: 0 / failed: 0 / total: 1</th>
</tr>
<tr class="successful">
<td>continued rs</td>
<td>Success</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
Loading

0 comments on commit 7ea386e

Please sign in to comment.