nicer full html
[librarian.git] / librarian / xslt / book2html.xslt
index 10da3ec..c7b7215 100755 (executable)
@@ -10,6 +10,7 @@
     xmlns:dc="http://purl.org/dc/elements/1.1/" >
 
 <xsl:output encoding="utf-8" indent="yes" omit-xml-declaration = "yes" version="2.0" />
+<xsl:strip-space  elements="opowiadanie powiesc dramat_wierszowany_l dramat_wierszowany_lp dramat_wspolczesny liryka_l liryka_lp wywiad"/>
 <xsl:template match="utwor">
     <xsl:choose>
         <xsl:when test="@full-page">
@@ -17,8 +18,7 @@
             <head>
                 <title><xsl:apply-templates mode="inline" select="//nazwa_utworu" /></title>
                 <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
-            </head>
-            <style>
+                <style>
                 body {
                     font-size: 16px;
                     font: Georgia, "Times New Roman", serif;
@@ -45,6 +45,7 @@
 
                 img {
                     border: none;
+                    max-width: 100%;
                 }
 
 
                 @media print {
                     #menu {display: none;}
                 }
-            </style>
+                </style>
+            </head>
             <body>
                 <xsl:call-template name="book-text" />
             </body>
 
 <!-- Section headers (included in index)-->
 <xsl:template match="naglowek_akt|naglowek_czesc|srodtytul">
+  <xsl:call-template name="section-anchor"/>
     <h2><xsl:apply-templates mode="inline" /></h2>
 </xsl:template>
 
 <xsl:template match="naglowek_scena|naglowek_rozdzial">
+    <xsl:call-template name="section-anchor"/>
     <h3><xsl:apply-templates mode="inline" /></h3>
 </xsl:template>
 
 <xsl:template match="naglowek_osoba|naglowek_podrozdzial">
+      <xsl:call-template name="section-anchor"/>
     <h4><xsl:apply-templates mode="inline" /></h4>
 </xsl:template>
 
 <!-- Other paragraph tags -->
 <xsl:template match="miejsce_czas">
+      <xsl:call-template name="section-anchor"/>
     <p class="place-and-time"><xsl:apply-templates mode="inline" /></p>
 </xsl:template>
 
 <xsl:template match="didaskalia">
+      <xsl:call-template name="section-anchor"/>
     <div class="didaskalia"><xsl:apply-templates mode="inline" /></div>
 </xsl:template>
 
 </xsl:template>
 
 <xsl:template match="akap|akap_dialog|akap_cd">
-    <p class="paragraph"><xsl:apply-templates mode="inline" /></p>
+    <p class="paragraph">
+      <xsl:call-template name="section-anchor"/>
+       <xsl:apply-templates mode="inline" />
+    </p>
 </xsl:template>
 
 <xsl:template match="strofa">
     <div class="stanza">
+      <xsl:call-template name="section-anchor"/>
         <xsl:choose>
             <xsl:when test="count(br) > 0">
                 <xsl:call-template name="verse">
     <hr class="spacer-line" />
 </xsl:template>
 
+<xsl:template match="ilustr">
+    <div xmlns="http://www.w3.org/1999/xhtml" class="ilustr">
+      <img xmlns="http://www.w3.org/1999/xhtml" alt="ilustracja">
+        <xsl:attribute name="src">
+          <xsl:value-of select="@src" />
+        </xsl:attribute>
+        <xsl:attribute name="alt">
+          <xsl:apply-templates mode="inline" />
+        </xsl:attribute>
+        <xsl:attribute name="title">
+          <xsl:apply-templates mode="inline" />
+        </xsl:attribute>
+      </img>
+    </div>
+</xsl:template>
+
 
 <!-- ================ -->
 <!-- = SPECIAL TAGS = -->
     <xsl:value-of select="wl:substitute_entities(.)" />
 </xsl:template>
 
+<!-- ========= -->
+<!-- = utils = -->
+<!-- ========= -->
+<xsl:template name="section-anchor">
+  <!-- 
+       this formula works as follows:
+       - get all ancestors including self
+       - choose the header (third one from root): utwor/book-type/header
+       - get all preceding siblings
+       - count them
+       - create an <a name="sec123"/> tag.
+  -->
+        <a name="{concat('sec', count(ancestor-or-self::*[last()-2]/preceding-sibling::*) + 1)}" />
+</xsl:template>
 
-</xsl:stylesheet>
\ No newline at end of file
+</xsl:stylesheet>