<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
    version="2.0"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:emop="http://contraintes.inria.fr/emop/doc">
   <xsl:output
       indent="yes"
       encoding="utf-8"
       doctype-public="-//W3C//DTD XHTML 1.1//EN"
       doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" />
   <xsl:template match="/emop:file">
      <html xml:lang="en">
         <head>
            <meta http-equiv="Content-Language" content="en" />
            <meta
                http-equiv="Content-Type"
                content="text/xhtml; charset=UTF-8" />
            <title><xsl:value-of select="emop:module/@title" /></title>
            <style type="text/css">
body {
	font-family: serif;
}

em.math {
	font-family: serif;
}

sub, sup {
	font-size: 0.6em;
}

dl {
	padding-left: 1em;
	max-width: 35em;
	margin-top: 0.3em;
}

dt {
	font-style: italic;
	margin-top: 0;
	padding-top: 0;
}

dd {
	margin-left: 1em;
	text-align: justify;
	margin-top: 0.2em;
	margin-bottom: 0.8em;
}

h2 {
	font-size: 1.2em;
	margin-top: 1em;
	margin-bottom: 0.2em;
}

ul {
	padding-left: 1em;
}
            </style>
         </head>
         <body>
            <xsl:apply-templates mode="toc" />
            <xsl:apply-templates />
         </body>
      </html>
   </xsl:template>
   <xsl:template match="emop:module" mode="toc">
      <div>
         <xsl:choose>
            <xsl:when test="emop:predicate">
               <h1><code><xsl:value-of select="@title" /></code></h1>
               <ul>
                  <xsl:for-each select="emop:predicate">
                     <li>
                        <a href="#{@id}"><code><xsl:value-of select="@name" /></code></a>
                     </li>
                  </xsl:for-each>
               </ul>
            </xsl:when>
         </xsl:choose>
      </div>
   </xsl:template>
   <xsl:template match="emop:module">
      <div>
         <xsl:choose>
            <xsl:when test="emop:predicate">
               <h1><code><xsl:value-of select="@title" /></code></h1>
               <xsl:for-each select="emop:predicate">
                  <h2 id="{@id}"><code><xsl:value-of select="@name" /></code></h2>
                  <dl>
                     <xsl:choose>
                        <xsl:when test="emop:prerequisite">
                           <dt>Prerequisites</dt>
                           <dd>
                              <ul>
                                 <xsl:for-each select="emop:prerequisite">
                                    <li><xsl:apply-templates /></li>
                                 </xsl:for-each>
                              </ul>
                           </dd>
                        </xsl:when>
                     </xsl:choose>
                     <dt>Description</dt>
                     <dd>
                        <xsl:apply-templates />
                     </dd>
                  </dl>
               </xsl:for-each>
            </xsl:when>
         </xsl:choose>
      </div>
   </xsl:template>
   <xsl:template match="emop:prerequisite">
   </xsl:template>
   <xsl:template match="emop:code">
      <code><xsl:apply-templates /></code>
   </xsl:template>
   <xsl:template match="emop:sub">
      <sub><xsl:apply-templates /></sub>
   </xsl:template>
   <xsl:template match="emop:math">
      <em class="math"><xsl:apply-templates /></em>
   </xsl:template>
</xsl:stylesheet>
