Skip to content

Commit

Permalink
tei2html stylesheet: better debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
EsGeh authored and EsGeh committed Nov 6, 2019
1 parent ecee9a9 commit 410f9bb
Show file tree
Hide file tree
Showing 7 changed files with 235 additions and 97 deletions.
3 changes: 2 additions & 1 deletion tei2html/tei2html.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<xsl:include href="tei2html_chapter_utils.xsl"/>
<xsl:include href="utils/html_rules.xsl"/>
<xsl:include href="utils/common.xsl"/>
<xsl:include href="utils/print.xsl"/>

<xsl:param name="output_dir" as="xs:string" select="'.'"/>
<xsl:param name="static_dir" as="xs:string" select="'static'"/>
Expand All @@ -35,7 +36,7 @@
-->

<xsl:template match="/">
<xsl:message> domain: <xsl:value-of select="$domain"/> </xsl:message>
<xsl:sequence select="eoa:info(concat('domain: ', $domain))"/>
<xsl:variable name="output_subdir" as="xs:string">
<xsl:value-of select="concat($output_dir, '/', $series, '/', $publication_number)"/>
</xsl:variable>
Expand Down
6 changes: 2 additions & 4 deletions tei2html/tei2html_chapter.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@
<xsl:include href="tei2html_chapter_utils.xsl"/>

<xsl:template match="/">
<!--
<xsl:message> domain: <xsl:value-of select="$domain"/> </xsl:message>
-->
<xsl:sequence select="eoa:info(concat('domain: ', $domain))"/>
<xsl:for-each select="(//tei:div[@type='chapter'])[position() = $chapter_nr]">
<xsl:message>printing chapter <xsl:value-of select="$chapter_nr"/>. head: <xsl:value-of select="tei:head"/></xsl:message>
<xsl:sequence select="eoa:info(concat('printing chapter ', $chapter_nr, '. head: ', tei:head))"/>
<xsl:call-template name="render_chapter">
<xsl:with-param name="static_dir" select="$static_dir"/>
<xsl:with-param name="logo_dir" select="$logo_dir"/>
Expand Down
2 changes: 1 addition & 1 deletion tei2html/tei2html_chapter_utils.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
</xsl:with-param>
<xsl:with-param name="script">
<xsl:if test=".//tei:formula">
<xsl:message>putting in mathjax</xsl:message>
<xsl:sequence select="eoa:info('adding mathjax...')"/>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
Expand Down
9 changes: 4 additions & 5 deletions tei2html/tei2html_publ_frontpage_utils.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -499,14 +499,14 @@
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="eoa:debug(3, 'No book author. Exiting.', '')"/>
<xsl:sequence select="eoa:error('No book author.')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template name="create_index">
<xsl:param name="indextype"/>
<xsl:message>creating index...</xsl:message>
<xsl:sequence select="eoa:info('creating index')"/>
<!-- all index elements starting with the same letter: -->
<xsl:for-each-group select="//tei:index[lower-case(@indexName) = $indextype]" group-by="substring(if (exists(./tei:term/@sortKey)) then ./tei:term/@sortKey else ./tei:term/text(),1,1)">
<xsl:sort select="current-grouping-key()"/>
Expand All @@ -530,9 +530,7 @@
<xsl:variable name="paragraph_nr" select="index-of($chapter//tei:p/tei:index/generate-id(), generate-id(.))"/>
<xsl:variable name="local_uri" select="concat($series, '/', $publication_number, '/', $chapter_nr , '/index.html#', $paragraph_nr)"/>
<xsl:variable name="global_uri" select="concat($domain, '/', $local_uri)"/>
<xsl:message>
<xsl:value-of select="concat(current-grouping-key(), ': ', $global_uri)"/>
</xsl:message>
<xsl:sequence select="eoa:info(concat(current-grouping-key(), ': ', $global_uri))"/>
<li>
<a href="{$global_uri}"> <xsl:value-of select="position()"/></a>
</li>
Expand All @@ -550,6 +548,7 @@
</xsl:message>
-->
</xsl:for-each-group>
<xsl:sequence select="eoa:info('finished creating index')"/>
</xsl:template>

</xsl:stylesheet>
25 changes: 6 additions & 19 deletions tei2html/utils/common.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
indent="yes"
/>

<xsl:variable name="apos" as="xs:string">'</xsl:variable>

<!--
<xsl:param name="verbosity" as="xs:integer" required="no" select="0"/>
-->

<xsl:template name="website_meta_tags">
<xsl:param name="citation_title"/>
Expand Down Expand Up @@ -209,7 +213,7 @@
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="eoa:debug(3, 'No book author. Exiting.', '')"/>
<xsl:value-of select="eoa:error('No book author!')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Expand Down Expand Up @@ -248,26 +252,9 @@
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="eoa:debug(1, 'No chapter author: ', node())"/>
<xsl:value-of select="eoa:error('No chapter author: ', node())"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:function name="eoa:debug">
<xsl:param name="level" as="xs:integer"/>
<xsl:param name="message" as="xs:string"/>
<xsl:param name="node"/>
<xsl:choose>
<xsl:when test="$level = 1 and $verbosity &gt; 0">
<xsl:message terminate="no">[INFO]: <xsl:value-of select="$message"/> <xsl:value-of select="$node"/></xsl:message>
</xsl:when>
<xsl:when test="$level = 2 and $verbosity &gt; 1">
<xsl:message terminate="no">[WARNING]: <xsl:value-of select="$message"/> <xsl:value-of select="$node"/></xsl:message>
</xsl:when>
<xsl:when test="$level = 3 and $verbosity &gt; 2">
<xsl:message terminate="yes">[ERROR]: <xsl:value-of select="$message"/> <xsl:value-of select="$node"/>. Exiting.</xsl:message>
</xsl:when>
</xsl:choose>
</xsl:function>

</xsl:stylesheet>
Loading

0 comments on commit 410f9bb

Please sign in to comment.