poetry_html.xsl
author Fabien Ninoles <fabien@tzone.org>
Sun, 24 Jan 2016 17:26:15 -0500
branchstyles
changeset 25 ed59e6e7fad0
parent 15 27a2a404231e
permissions -rw-r--r--
More reasonable spacing for list.

<?xml version="1.0"?>
<xsl:stylesheet version="1.1"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xt="http://www.jclark.com/xt"
  xmlns="http://www.w3.org/1999/xhtml"
  extension-element-prefixes="xt">
  <xsl:import href="html.xsl"/>
  <xsl:output method="xml"
	encoding="utf-8"
        doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
        doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
        indent="yes"/>

<xsl:param name="stylesheet"><xsl:text>poetry.css</xsl:text></xsl:param>
<xsl:param name="pdf-filename"><xsl:text>poetry.pdf</xsl:text></xsl:param>

<xsl:template match="poetry" mode="xref">
  <xsl:variable name="href">
    <xsl:call-template name="get-id"/>
  </xsl:variable>
  <a href="{$href}.html"><xsl:value-of select="docinfo/title"/></a>
  <xsl:if test="nda">
    [<a href="{$href}_nda.html">NdA</a>]
  </xsl:if>
</xsl:template>

<xsl:template match="section[@role='null']" mode="book-toc"/>
<xsl:template match="section[@role='null']">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="book/section" mode="navbar-section">
  <xsl:variable name="section-ref">
    <xsl:call-template name="get-id"/>
  </xsl:variable>
  <a href="index.html#{$section-ref}">Retour à la table des matières</a><br/>
</xsl:template>

<xsl:template match="poetry" mode="navbar-name">
  <xsl:choose>
    <xsl:when test="docinfo/title">
      <xsl:value-of select="docinfo/title/text()"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="poem/title/text()"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template match="poetry" mode="navbar-poetry">
  <xsl:variable name="my-id">
    <xsl:value-of select="@id"/>
  </xsl:variable>
  <ul class="navbar">
    <xsl:for-each select="//xref[@linkend=$my-id]">
      <li>
	    <xsl:variable name="mysection" select="ancestor::section[last()]/@id"/>
	    <xsl:for-each select="ancestor::section">
	      <xsl:apply-templates select="." mode="xref"/>
	      <xsl:if test="descendant::section">
	        <xsl:text> : </xsl:text>
	      </xsl:if>
	    </xsl:for-each>
	    <ul>
	      <xsl:if test="preceding::xref[1]/ancestor::section[last()]/@id=$mysection">
	        <li><xsl:text>Précédent: </xsl:text>
	        <xsl:apply-templates select="preceding::xref[1]"/>
	        </li>
	      </xsl:if>
	      <xsl:if test="following::xref[1]/ancestor::section[last()]/@id=$mysection">
	        <li><xsl:text>Suivant: </xsl:text>
	        <xsl:apply-templates select="following::xref[1]"/>
	        </li>
	      </xsl:if>
	    </ul>
      </li>
    </xsl:for-each>
  </ul>
</xsl:template>

<!-- poetry section -->
<xsl:template match="poetry/poem">
  <xsl:variable name="href">
    <xsl:call-template name="parent-id"/>
  </xsl:variable>
  <xt:document href="{$href}.html" method="xml" encoding="utf-8"
        doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
        doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
        indent="yes">
    <html>
      <head>
        <xsl:apply-templates select="../docinfo" mode="heading"/>
        <link href="{$css-base-dir}{$stylesheet}" media="screen" rel="stylesheet" type="text/css"/>
      </head>
      <body>
        <xsl:apply-templates/>
        <xsl:apply-templates select="../docinfo/date"/>
        <hr/>
        <address>
          <xsl:apply-templates select="../docinfo/copyright"/>
        </address>
        <xsl:if test="../nda">
          <a href="{$href}_nda.html">Notes de l'auteur.</a><br/>
        </xsl:if>
        <xsl:apply-templates mode="navbar-poetry" select=".."/>
      </body>
    </html>
  </xt:document>
</xsl:template>

<xsl:template match="poetry/nda">
  <xsl:variable name="href">
    <xsl:call-template name="parent-id"/>
  </xsl:variable>
  <xt:document method="xml" encoding="utf-8" href="{$href}_nda.html"
        doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
        doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
        indent="yes">
    <html>
      <head>
        <xsl:apply-templates select="../docinfo" mode="heading-nda"/>
      <link href="{$css-base-dir}{$stylesheet}" media="screen" rel="stylesheet" type="text/css"/>
      </head>
      <body>
        <xsl:apply-templates/>
        <hr/>
        <address>
          <xsl:apply-templates select="../docinfo/copyright"/>
        </address>
        <a href="{$href}.html">Retour au poème.</a><br/>
        <xsl:apply-templates mode="navbar-poetry" select=".."/>
      </body>
    </html>
  </xt:document>
</xsl:template>

<!-- strophe -->
<xsl:template match="strophe">
  <p><xsl:apply-templates/></p>
</xsl:template>

<!-- verse -->
<xsl:template match="verse">
  <xsl:apply-templates/><br/>
</xsl:template>

<!-- cue -->
<xsl:template match="cue">
  <p><xsl:apply-templates/></p>
</xsl:template>
<xsl:template match="caracter">
  <strong class="caracter">
    <xsl:apply-templates/>
  </strong><xsl:text>: </xsl:text>
</xsl:template>
<xsl:template match="cue/para">
  <xsl:apply-templates/>
</xsl:template>

</xsl:stylesheet>