story_html.xsl
author Fabien Ninoles <fabien@tzone.org>
Mon, 14 Sep 2015 11:30:58 -0400
branchstyles
changeset 19 42559b9800a7
parent 3 6e7e05c2ded6
permissions -rw-r--r--
Phony install

<?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"
  extension-element-prefixes="xt" 
  xmlns="http://www.w3.org/1999/xhtml">
  <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"/>
<!-- book processing -->
<xsl:param name="stylesheet"><xsl:text>contes.css</xsl:text></xsl:param>
<xsl:param name="pdf-filename"><xsl:text>contes.pdf</xsl:text></xsl:param>

<xsl:template match="story" mode="section-toc">
  <xsl:variable name="href">
    <xsl:call-template name="get-id"/>
  </xsl:variable>
  <li>
    <p><a href="{$href}.html"><xsl:value-of select="docinfo/title"/></a></p>
    <xsl:if test="nda">
      <xsl:apply-templates select="nda"/>
    </xsl:if>
  </li>
</xsl:template>

<xsl:template match="story" mode="get-story-link">
  <xsl:call-template name="get-id"/>
</xsl:template>
<xsl:template match="story" mode="get-story-name">
  <xsl:choose>
    <xsl:when test="docinfo/title">
      <xsl:value-of select="docinfo/title/text()"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="story/title/text()"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!-- navigation-bar of story and nda -->
<xsl:template name="links-story-link">
  <xsl:param name="prefix"></xsl:param>
  <link>
    <xsl:attribute name="href">
      <xsl:apply-templates select="." mode="get-story-link"/>
      <xsl:text>.html</xsl:text>
    </xsl:attribute>
    <xsl:attribute name="rel">
      <xsl:value-of select="$prefix"/>
    </xsl:attribute>
    <xsl:attribute name="title">
      <xsl:apply-templates select="." mode="get-story-name"/>
    </xsl:attribute>
  </link>
</xsl:template>
<xsl:template match="story" mode="links-prec">
  <xsl:call-template name="links-story-link">
    <xsl:with-param name="prefix">
      <xsl:text>previous</xsl:text>
    </xsl:with-param>
  </xsl:call-template>
</xsl:template>
<xsl:template match="story" mode="links-next">
  <xsl:call-template name="links-story-link">
    <xsl:with-param name="prefix">
      <xsl:text>next</xsl:text>
    </xsl:with-param>
  </xsl:call-template>
</xsl:template>
<xsl:template match="story" mode="links-story">
  <xsl:choose>
    <xsl:when test="preceding-sibling::story[1]">
      <xsl:apply-templates 
          select="preceding-sibling::story[1]"
          mode="links-prec"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:apply-templates 
        select="../preceding-sibling::*[1]/story[last()]"
          mode="links-prec"/>
    </xsl:otherwise>
  </xsl:choose>
  <xsl:choose>
    <xsl:when test="following-sibling::story[1]">
      <xsl:apply-templates 
          select="following-sibling::story[1]"
          mode="links-next"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:apply-templates 
        select="../following-sibling::*[1]/story[1]"
          mode="links-next"/>
    </xsl:otherwise>
  </xsl:choose>
  <xsl:variable name="section-ref">
    <xsl:call-template name="parent-id"/>
  </xsl:variable>
  <link href="index.html#{$section-ref}"
     rel="up" title="Table des matières"/>
</xsl:template>

<!-- navigation-bar of story and nda -->
<xsl:template name="navbar-story-link">
  <xsl:param name="prefix"></xsl:param>
  <a>
    <xsl:attribute name="href">
      <xsl:apply-templates select="." mode="get-story-link"/>
      <xsl:text>.html</xsl:text>
    </xsl:attribute>
    <xsl:value-of select="$prefix"/>
    <xsl:apply-templates select="." mode="get-story-name"/>
  </a><br/>
</xsl:template>
<xsl:template match="story" mode="navbar-prec">
  <xsl:call-template name="navbar-story-link">
    <xsl:with-param name="prefix">
      <xsl:text>Précédent: </xsl:text>
    </xsl:with-param>
  </xsl:call-template>
</xsl:template>
<xsl:template match="story" mode="navbar-next">
  <xsl:call-template name="navbar-story-link">
    <xsl:with-param name="prefix">
      <xsl:text>Suivant: </xsl:text>
    </xsl:with-param>
  </xsl:call-template>
</xsl:template>
<xsl:template match="story" mode="navbar-story">
  <xsl:choose>
    <xsl:when test="preceding-sibling::story[1]">
      <xsl:apply-templates 
          select="preceding-sibling::story[1]"
          mode="navbar-prec"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:apply-templates 
        select="../preceding-sibling::section[last()]"
          mode="navbar-prec"/>
    </xsl:otherwise>
  </xsl:choose>
  <xsl:choose>
    <xsl:when test="following-sibling::story[1]">
      <xsl:apply-templates 
          select="following-sibling::story[1]"
          mode="navbar-next"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:apply-templates 
        select="../following-sibling::*[1]"
          mode="navbar-next"/>
    </xsl:otherwise>
  </xsl:choose>
  <xsl:variable name="section-ref">
    <xsl:call-template name="parent-id"/>
  </xsl:variable>
  <a href="{$section-ref}.html">Retour à la section</a><br/>
</xsl:template>

<!-- story section -->
<xsl:template match="story">
  <xsl:variable name="href">
    <xsl:call-template name="get-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>
        <link href="{$css-base-dir}contes.css" media="screen"
          rel="stylesheet" type="text/css"/>
        <xsl:apply-templates select="../docinfo" mode="heading"/>
        <xsl:apply-templates select="." mode="links-story"/>
      </head>
      <body>
        <xsl:apply-templates/>
        <xsl:apply-templates select="../docinfo/date"/>
        <hr/>
        <address>
          <xsl:apply-templates select="../docinfo/copyright"/>
        </address>
        <xsl:apply-templates mode="navbar-story" select="."/>
      </body>
    </html>
  </xt:document>
</xsl:template>

<xsl:template match="story//section">
  <div class="section">
    <xsl:apply-templates/>
  </div>
</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:template match="dialog">
  <blockquote class="dialog">
    <xsl:apply-templates/>
  </blockquote>
</xsl:template
>
<xsl:template match="dialog/cite">
  <p><xsl:text>« - </xsl:text>
   <xsl:apply-templates/>
  <xsl:text> »</xsl:text></p>
</xsl:template>
<xsl:template match="cite/desc">
  <xsl:text> »</xsl:text>
   <xsl:apply-templates/>
  <xsl:text>« </xsl:text>
</xsl:template>

<xsl:template match="story/section/title">
  <h2><xsl:apply-templates/></h2>
</xsl:template>
<xsl:template match="story/section/section/title">
  <h3><xsl:apply-templates/></h3>
</xsl:template>
 
<xsl:template match="story/nda">
  <div class="nda">
    <xsl:apply-templates/>
  </div>
</xsl:template>

<xsl:template match="story" 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:template>

</xsl:stylesheet>