1 <?xml version="1.0" encoding="utf-8"?>
4 This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
5 Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
8 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
9 xmlns:wl="http://wolnelektury.pl/functions"
10 xmlns:dc="http://purl.org/dc/elements/1.1/" >
12 <xsl:output encoding="utf-8" indent="yes" omit-xml-declaration = "yes" version="2.0" />
13 <xsl:strip-space elements="opowiadanie powiesc dramat_wierszowany_l dramat_wierszowany_lp dramat_wspolczesny liryka_l liryka_lp wywiad"/>
14 <xsl:template match="utwor">
16 <xsl:when test="@full-page">
19 <title>Książka z serwisu WolneLektury.pl</title>
20 <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
25 font: Georgia, "Times New Roman", serif;
32 text-decoration: none;
40 /* ================================== */
41 /* = Header with logo and menu = */
42 /* ================================== */
44 margin: 3.4em 0 0 1.4em;
80 #menu li a:hover, #menu li a:active {
82 background: #FFF url(/static/img/arrow-down.png) no-repeat center right;
87 background: #FFF url(/static/img/arrow-up.png) no-repeat center right;
105 #toc, #themes, #nota_red, #info {
112 border-bottom: 0.25em solid #DDD;
113 border-right: 0.25em solid #DDD;
122 #toc ol, #themes ol {
133 padding: 0 0 1.5em 1.5em;
158 /* =================================================== */
159 /* = Common elements: headings, paragraphs and lines = */
160 /* =================================================== */
193 /* ======================== */
194 /* = Footnotes and themes = */
195 /* ======================== */
197 border-left: 0.1em solid #DDDDDD;
204 font-variant: normal;
206 text-transform: none;
207 text-decoration: none;
211 margin-right: -9.5em;
212 margin-bottom: 0.5em;
228 #footnotes .annotation {
256 margin: -0.25em -0.5em;
262 padding: 0.25em 0.5em;
266 .anchor:hover, #book-text .anchor:active {
268 background-color: #CCC;
271 /* =================== */
272 /* = Custom elements = */
273 /* =================== */
278 margin-bottom: 0.25em;
285 margin-bottom: -0.25em;
304 margin: 0.5em 0 0 1.5em;
315 div.kwestia div.stanza {
336 border-bottom: 0.1em solid #999;
337 padding-bottom: 1.5em;
340 div.note p, div.dedication p, div.note p.paragraph, div.dedication p.paragraph {
353 border-bottom: 0.1em solid #000;
364 padding: 0 0 0 1.5em;
371 em.math, em.foreign-word, em.book-title, em.didaskalia {
376 letter-spacing: 0.1em;
381 font-variant: small-caps;
389 /* =================================== */
390 /* = Hide some elements for printing = */
391 /* =================================== */
394 #menu {display: none;}
398 <xsl:call-template name="book-text" />
403 <xsl:call-template name="book-text" />
408 <xsl:template name="book-text">
410 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
411 <xsl:if test="count(descendant::*[self::pe or self::pa or self::pr or self::pt][not(parent::extra)])">
414 <xsl:for-each select="descendant::*[self::pe or self::pa or self::pr or self::pt][not(parent::extra)]">
416 <a name="{concat('footnote-', generate-id(.))}" />
417 <a href="{concat('#anchor-', generate-id(.))}" class="annotation">[<xsl:number value="count(preceding::*[self::pa or self::pe or self::pr or self::pt]) + 1" />]</a>
419 <xsl:when test="count(akap|akap_cd|strofa) = 0">
420 <p><xsl:apply-templates select="text()|*" mode="inline" />
421 <xsl:if test="name()='pa'"> [przypis autorski]</xsl:if>
425 <xsl:apply-templates select="text()|*" mode="inline" />
436 <!-- ============================================================================== -->
437 <!-- = MASTER TAG = -->
438 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
439 <!-- ============================================================================== -->
440 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny">
441 <xsl:apply-templates select="nota_red" mode="special" />
442 <xsl:if test="nazwa_utworu">
444 <xsl:apply-templates select="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul" mode="header" />
445 <xsl:call-template name="translators" />
448 <xsl:apply-templates />
452 <!-- ==================================================================================== -->
453 <!-- = BLOCK TAGS = -->
454 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
455 <!-- ==================================================================================== -->
456 <xsl:template match="nota">
457 <div class="note"><xsl:apply-templates /></div>
460 <xsl:template match="lista_osob">
461 <div class="person-list">
462 <h3><xsl:value-of select="naglowek_listy" /></h3>
464 <xsl:apply-templates select="lista_osoba" />
469 <xsl:template match="dedykacja">
470 <div class="dedication"><xsl:apply-templates /></div>
473 <xsl:template match="ramka">
474 <div class="frame"><xsl:apply-templates /></div>
477 <xsl:template match="kwestia">
478 <div class="kwestia">
479 <xsl:apply-templates select="strofa|akap|didaskalia" />
483 <xsl:template match="dlugi_cytat|poezja_cyt">
484 <blockquote><xsl:apply-templates /></blockquote>
487 <xsl:template match="motto">
488 <div class="motto"><xsl:apply-templates mode="inline" /></div>
492 <xsl:template match="tabela">
493 <table><xsl:apply-templates /></table>
495 <xsl:template match="wiersz">
496 <tr><xsl:apply-templates /></tr>
498 <xsl:template match="kol">
499 <td><xsl:apply-templates mode="inline" /></td>
502 <xsl:template match="ilustr" mode="inline">
503 <xsl:apply-templates select="."/>
506 <xsl:template match="ilustr">
508 <xsl:attribute name="src">
509 <xsl:value-of select="@src" />
511 <xsl:attribute name="alt">
512 <xsl:value-of select="@alt" />
514 <xsl:attribute name="title">
515 <xsl:value-of select="@alt" />
521 <xsl:template match="lista[@typ='num']">
522 <ol><xsl:apply-templates /></ol>
524 <xsl:template match="lista[@typ='punkt']">
525 <ul><xsl:apply-templates /></ul>
527 <xsl:template match="punkt">
528 <li><xsl:apply-templates mode="inline" /></li>
535 <!-- ========================================== -->
536 <!-- = PARAGRAPH TAGS = -->
537 <!-- = (can contain inline and special tags) = -->
538 <!-- ========================================== -->
540 <xsl:template match="autor_utworu" mode="header">
541 <span class="author"><xsl:apply-templates mode="inline" /></span>
544 <xsl:template match="nazwa_utworu" mode="header">
545 <span class="title"><xsl:apply-templates mode="inline" /></span>
548 <xsl:template match="dzielo_nadrzedne" mode="header">
549 <span class="collection"><xsl:apply-templates mode="inline" /></span>
552 <xsl:template match="podtytul" mode="header">
553 <span class="subtitle"><xsl:apply-templates mode="inline" /></span>
556 <!-- Section headers (included in index)-->
557 <xsl:template match="naglowek_akt|naglowek_czesc">
558 <xsl:call-template name="section-anchor"/>
560 <xsl:apply-templates mode="inline" /></h2>
563 <xsl:template match="naglowek_scena|naglowek_rozdzial">
564 <xsl:call-template name="section-anchor"/>
565 <h3><xsl:apply-templates mode="inline" /></h3>
568 <xsl:template match="naglowek_osoba|naglowek_podrozdzial">
569 <xsl:call-template name="section-anchor"/>
570 <h4><xsl:apply-templates mode="inline" /></h4>
573 <xsl:template match="srodtytul">
574 <xsl:call-template name="section-anchor"/>
576 <xsl:apply-templates mode="inline" /></h5>
580 <!-- Other paragraph tags -->
581 <xsl:template match="miejsce_czas">
582 <xsl:call-template name="section-anchor"/>
583 <p class="place-and-time"><xsl:apply-templates mode="inline" /></p>
586 <xsl:template match="didaskalia">
587 <xsl:call-template name="section-anchor"/>
588 <div class="didaskalia"><xsl:apply-templates mode="inline" /></div>
591 <xsl:template match="lista_osoba">
592 <li><xsl:apply-templates mode="inline" /></li>
595 <xsl:template match="akap|akap_dialog|akap_cd">
596 <p class="paragraph">
597 <xsl:call-template name="section-anchor"/>
598 <xsl:apply-templates mode="inline" />
602 <xsl:template match="strofa">
604 <xsl:call-template name="section-anchor"/>
606 <xsl:when test="count(br) > 0">
607 <xsl:call-template name="verse">
608 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
609 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
611 <xsl:for-each select="br">
612 <!-- Each BR tag "consumes" text after it -->
613 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
614 <xsl:call-template name="verse">
615 <xsl:with-param name="verse-content"
616 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
617 <xsl:with-param name="verse-type" select="following-sibling::*[count(preceding-sibling::br) = $lnum+1 and (name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd')][1]" />
622 <xsl:call-template name="verse">
623 <xsl:with-param name="verse-content" select="text() | node()" />
624 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
631 <xsl:template name="verse">
632 <xsl:param name="verse-content" />
633 <xsl:param name="verse-type" />
636 <xsl:when test="name($verse-type) = 'wers_akap'">
637 <xsl:attribute name="style">padding-left: 1em</xsl:attribute>
639 <xsl:when test="name($verse-type) = 'wers_wciety'">
641 <xsl:when test="$verse-content/@typ">
642 <xsl:attribute name="style">padding-left: <xsl:value-of select="$verse-content/@typ" />em</xsl:attribute>
645 <xsl:attribute name="style">padding-left: 1em</xsl:attribute>
649 <xsl:when test="name($verse-type) = 'wers_cd'">
650 <xsl:attribute name="style">padding-left: 12em</xsl:attribute>
653 <xsl:apply-templates select="$verse-content" mode="inline" />
657 <xsl:template match="motto_podpis">
658 <p class="motto_podpis"><xsl:apply-templates mode="inline" /></p>
662 <!-- ================================================ -->
663 <!-- = INLINE TAGS = -->
664 <!-- = (contain other inline tags and special tags) = -->
665 <!-- ================================================ -->
667 <xsl:template match="pa|pe|pr|pt" mode="inline">
668 <a name="{concat('anchor-', generate-id(.))}" />
669 <a href="{concat('#footnote-', generate-id(.))}" class="annotation">[<xsl:number value="count(preceding::*[self::pa or self::pe or self::pr or self::pt]) + 1" />]</a>
672 <!-- Other inline tags -->
673 <xsl:template match="mat" mode="inline">
674 <em class="math"><xsl:apply-templates mode="inline" /></em>
677 <xsl:template match="didask_tekst" mode="inline">
678 <em class="didaskalia"><xsl:apply-templates mode="inline" /></em>
681 <xsl:template match="slowo_obce" mode="inline">
682 <em class="foreign-word"><xsl:apply-templates mode="inline" /></em>
685 <xsl:template match="tytul_dziela" mode="inline">
686 <em class="book-title">
687 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
691 <xsl:template match="wyroznienie" mode="inline">
692 <em class="author-emphasis"><xsl:apply-templates mode="inline" /></em>
695 <xsl:template match="osoba" mode="inline">
696 <em class="person"><xsl:apply-templates mode="inline" /></em>
699 <xsl:template match="www" mode="inline">
701 <xsl:attribute name="href">
702 <xsl:value-of select="text()"/>
704 <xsl:value-of select="text()"/>
708 <!-- ============================================== -->
709 <!-- = STANDALONE TAGS = -->
710 <!-- = (cannot contain any other tags) = -->
711 <!-- ============================================== -->
712 <xsl:template match="sekcja_swiatlo">
713 <hr class="spacer" />
716 <xsl:template match="sekcja_asterysk">
717 <p class="spacer-asterisk">*</p>
720 <xsl:template match="separator_linia">
721 <hr class="spacer-line" />
725 <!-- ================ -->
726 <!-- = SPECIAL TAGS = -->
727 <!-- ================ -->
729 <xsl:template match="begin" mode="inline">
730 <xsl:variable name="mnum" select="concat('m', substring(@id, 2))" />
731 <a name="m{substring(@id, 2)}" class="theme-begin" fid="{substring(@id, 2)}">
732 <xsl:value-of select="string(following::motyw[@id=$mnum]/text())" />
736 <xsl:template match="end" mode="inline">
737 <span class="theme-end" fid="{substring(@id, 2)}"> </span>
740 <xsl:template match="begin|end">
741 <xsl:apply-templates select='.' mode="inline" />
744 <xsl:template match="motyw" mode="inline" />
747 <xsl:template match="nota_red" mode="special">
749 <xsl:apply-templates />
754 <xsl:template name="translators">
755 <xsl:if test="//dc:contributor.translator">
756 <span class="translator">
757 <xsl:text>tłum. </xsl:text>
758 <xsl:for-each select="//dc:contributor.translator">
759 <xsl:if test="position() != 1">, </xsl:if>
760 <xsl:apply-templates mode="person" />
766 <xsl:template match="text()" mode="person">
767 <xsl:value-of select="wl:person_name(.)" />
771 <!-- ================ -->
772 <!-- = IGNORED TAGS = -->
773 <!-- ================ -->
774 <xsl:template match="extra|uwaga" />
775 <xsl:template match="extra|uwaga" mode="inline" />
777 <xsl:template match="nota_red" />
782 <xsl:template match="text()" />
783 <xsl:template match="text()" mode="inline">
784 <xsl:value-of select="wl:substitute_entities(.)" />
790 <xsl:template name="section-anchor">
792 this formula works as follows:
793 - get all ancestors including self
794 - choose the header (third one from root): utwor/book-type/header
795 - get all preceding siblings
797 - create an <a name="sec123"/> tag.
799 <a name="{concat('sec', count(ancestor-or-self::*[last()-2]/preceding-sibling::*) + 1)}" />